/trunk/WingMan/WingManForm.Designer.cs |
@@ -377,21 +377,27 @@ |
this.tabControl1.Controls.Add(this.tabPage1); |
this.tabControl1.Controls.Add(this.tabPage2); |
this.tabControl1.Controls.Add(this.tabPage3); |
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; |
this.tabControl1.Cursor = System.Windows.Forms.Cursors.PanNorth; |
this.tabControl1.Location = new System.Drawing.Point(3, 90); |
this.tabControl1.Name = "tabControl1"; |
this.tabControl1.SelectedIndex = 0; |
this.tabControl1.Size = new System.Drawing.Size(538, 363); |
this.tabControl1.Size = new System.Drawing.Size(538, 358); |
this.tabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; |
this.tabControl1.TabIndex = 5; |
this.tabControl1.GiveFeedback += new System.Windows.Forms.GiveFeedbackEventHandler(this.WingManTabControlGiveFeedback); |
this.tabControl1.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.WingManTabControlQueryContinueDrag); |
this.tabControl1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.WingManTabControlMouseDown); |
this.tabControl1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.WingManTabControlMouseMove); |
// |
// tabPage1 |
// |
this.tabPage1.Controls.Add(this.groupBox5); |
this.tabPage1.Controls.Add(this.groupBox4); |
this.tabPage1.Cursor = System.Windows.Forms.Cursors.Arrow; |
this.tabPage1.Location = new System.Drawing.Point(4, 22); |
this.tabPage1.Name = "tabPage1"; |
this.tabPage1.Padding = new System.Windows.Forms.Padding(3); |
this.tabPage1.Size = new System.Drawing.Size(530, 337); |
this.tabPage1.Size = new System.Drawing.Size(530, 332); |
this.tabPage1.TabIndex = 0; |
this.tabPage1.Text = "Connection"; |
this.tabPage1.UseVisualStyleBackColor = true; |
@@ -420,6 +426,7 @@ |
// |
this.tabPage2.Controls.Add(this.groupBox1); |
this.tabPage2.Controls.Add(this.groupBox3); |
this.tabPage2.Cursor = System.Windows.Forms.Cursors.Arrow; |
this.tabPage2.Location = new System.Drawing.Point(4, 22); |
this.tabPage2.Name = "tabPage2"; |
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); |
@@ -431,6 +438,7 @@ |
// tabPage3 |
// |
this.tabPage3.Controls.Add(this.groupBox2); |
this.tabPage3.Cursor = System.Windows.Forms.Cursors.Arrow; |
this.tabPage3.Location = new System.Drawing.Point(4, 22); |
this.tabPage3.Name = "tabPage3"; |
this.tabPage3.Size = new System.Drawing.Size(530, 337); |
/trunk/WingMan/WingManForm.cs |
@@ -24,6 +24,8 @@ |
{ |
public partial class WingManForm : Form |
{ |
private const int tabControlDetachPixelOffset = 20; |
|
public WingManForm() |
{ |
InitializeComponent(); |
@@ -131,6 +133,10 @@ |
|
public KeySimulator KeySimulator { get; set; } |
|
private static Point tabControlClickStartPosition { get; set; } |
private static TabControl DetachedTabControl { get; set; } |
private static Form DetachedForm { get; set; } |
|
public void OnDiscoveryPortMapFailed(object sender, DiscoveryFailedEventArgs args) |
{ |
switch (args.Type) |
@@ -752,6 +758,88 @@ |
await SaveLocalMouseKeyBindings(); |
} |
|
private void WingManTabControlMouseDown(object sender, MouseEventArgs e) |
{ |
if (e.Button != MouseButtons.Left) return; |
|
tabControlClickStartPosition = e.Location; |
} |
|
private void WingManTabControlMouseMove(object sender, MouseEventArgs e) |
{ |
if (e.Button == MouseButtons.Left) |
{ |
var mouseOffsetX = tabControlClickStartPosition.X - e.X; |
var mouseOffsetY = tabControlClickStartPosition.Y - e.Y; |
|
if (mouseOffsetX <= tabControlDetachPixelOffset && mouseOffsetY <= tabControlDetachPixelOffset) |
return; |
|
tabControl1.DoDragDrop(tabControl1.SelectedTab, DragDropEffects.Move); |
tabControlClickStartPosition = new Point(); |
|
return; |
} |
|
tabControlClickStartPosition = new Point(); |
} |
|
private void WingManTabControlGiveFeedback(object sender, GiveFeedbackEventArgs e) |
{ |
e.UseDefaultCursors = false; |
} |
|
private void WingManTabControlQueryContinueDrag(object sender, QueryContinueDragEventArgs e) |
{ |
if (MouseButtons != MouseButtons.Left) |
{ |
e.Action = DragAction.Cancel; |
|
DetachedForm = new Form |
{ |
Size = new Size( |
// Width = tab control width + tab control left and right margins + x-padding |
tabControl1.Width + |
tabControl1.Margin.Right + |
tabControl1.Margin.Left + |
tabControl1.Padding.X, |
// Tab Height = tab control height - tab control tab page height |
// Height = tab control height + Tab Height + top and bottom margin + x-padding |
2 * tabControl1.Height - |
tabControl1.SelectedTab.Height + |
tabControl1.Margin.Top + |
tabControl1.Margin.Bottom + |
tabControl1.Padding.Y), |
StartPosition = FormStartPosition.Manual, |
Location = MousePosition, |
MaximizeBox = false, |
SizeGripStyle = SizeGripStyle.Hide, |
FormBorderStyle = FormBorderStyle.FixedSingle |
}; |
|
DetachedTabControl = new TabControl |
{ |
Dock = DockStyle.Fill, |
SizeMode = TabSizeMode.Fixed |
}; |
DetachedTabControl.TabPages.Add(tabControl1.SelectedTab); |
DetachedForm.Controls.Add(DetachedTabControl); |
DetachedForm.FormClosing += DetachedFormOnFormClosing; |
DetachedForm.Show(); |
Cursor = Cursors.Default; |
return; |
} |
|
e.Action = DragAction.Continue; |
Cursor = Cursors.SizeAll; |
} |
|
private void DetachedFormOnFormClosing(object sender, FormClosingEventArgs e) |
{ |
tabControl1.TabPages.Insert(DetachedTabControl.SelectedTab.TabIndex, DetachedTabControl.SelectedTab); |
DetachedForm.FormClosing -= DetachedFormOnFormClosing; |
} |
|
#region Saving and loading |
|
private async Task SaveLocalMouseKeyBindings() |