WingMan – Diff between revs 32 and 33
?pathlinks?
Rev 32 | Rev 33 | |||
---|---|---|---|---|
Line 22... | Line 22... | |||
22 | |
22 | |
|
23 | namespace WingMan |
23 | namespace WingMan |
|
24 | { |
24 | { |
|
25 | public partial class WingManForm : Form |
25 | public partial class WingManForm : Form |
|
- | 26 | { |
||
- | 27 | private const int tabControlDetachPixelOffset = 20; |
||
26 | { |
28 | |
|
27 | public WingManForm() |
29 | public WingManForm() |
|
28 | { |
30 | { |
|
Line 29... | Line 31... | |||
29 | InitializeComponent(); |
31 | InitializeComponent(); |
|
Line 129... | Line 131... | |||
129 | |
131 | |
|
Line 130... | Line 132... | |||
130 | public KeyInterceptor KeyInterceptor { get; set; } |
132 | public KeyInterceptor KeyInterceptor { get; set; } |
|
Line -... | Line 133... | |||
- | 133 | |
||
- | 134 | public KeySimulator KeySimulator { get; set; } |
||
- | 135 | |
||
- | 136 | private static Point tabControlClickStartPosition { get; set; } |
||
131 | |
137 | private static TabControl DetachedTabControl { get; set; } |
|
132 | public KeySimulator KeySimulator { get; set; } |
138 | private static Form DetachedForm { get; set; } |
|
133 | |
139 | |
|
134 | public void OnDiscoveryPortMapFailed(object sender, DiscoveryFailedEventArgs args) |
140 | public void OnDiscoveryPortMapFailed(object sender, DiscoveryFailedEventArgs args) |
|
135 | { |
141 | { |
|
Line 750... | Line 756... | |||
750 | } |
756 | } |
|
Line 751... | Line 757... | |||
751 | |
757 | |
|
752 | await SaveLocalMouseKeyBindings(); |
758 | await SaveLocalMouseKeyBindings(); |
|
Line -... | Line 759... | |||
- | 759 | } |
||
- | 760 | |
||
- | 761 | private void WingManTabControlMouseDown(object sender, MouseEventArgs e) |
||
- | 762 | { |
||
- | 763 | if (e.Button != MouseButtons.Left) return; |
||
- | 764 | |
||
- | 765 | tabControlClickStartPosition = e.Location; |
||
- | 766 | } |
||
- | 767 | |
||
- | 768 | private void WingManTabControlMouseMove(object sender, MouseEventArgs e) |
||
- | 769 | { |
||
- | 770 | if (e.Button == MouseButtons.Left) |
||
- | 771 | { |
||
- | 772 | var mouseOffsetX = tabControlClickStartPosition.X - e.X; |
||
- | 773 | var mouseOffsetY = tabControlClickStartPosition.Y - e.Y; |
||
- | 774 | |
||
- | 775 | if (mouseOffsetX <= tabControlDetachPixelOffset && mouseOffsetY <= tabControlDetachPixelOffset) |
||
- | 776 | return; |
||
- | 777 | |
||
- | 778 | tabControl1.DoDragDrop(tabControl1.SelectedTab, DragDropEffects.Move); |
||
- | 779 | tabControlClickStartPosition = new Point(); |
||
- | 780 | |
||
- | 781 | return; |
||
- | 782 | } |
||
- | 783 | |
||
- | 784 | tabControlClickStartPosition = new Point(); |
||
- | 785 | } |
||
- | 786 | |
||
- | 787 | private void WingManTabControlGiveFeedback(object sender, GiveFeedbackEventArgs e) |
||
- | 788 | { |
||
- | 789 | e.UseDefaultCursors = false; |
||
- | 790 | } |
||
- | 791 | |
||
- | 792 | private void WingManTabControlQueryContinueDrag(object sender, QueryContinueDragEventArgs e) |
||
- | 793 | { |
||
- | 794 | if (MouseButtons != MouseButtons.Left) |
||
- | 795 | { |
||
- | 796 | e.Action = DragAction.Cancel; |
||
- | 797 | |
||
- | 798 | DetachedForm = new Form |
||
- | 799 | { |
||
- | 800 | Size = new Size( |
||
- | 801 | // Width = tab control width + tab control left and right margins + x-padding |
||
- | 802 | tabControl1.Width + |
||
- | 803 | tabControl1.Margin.Right + |
||
- | 804 | tabControl1.Margin.Left + |
||
- | 805 | tabControl1.Padding.X, |
||
- | 806 | // Tab Height = tab control height - tab control tab page height |
||
- | 807 | // Height = tab control height + Tab Height + top and bottom margin + x-padding |
||
- | 808 | 2 * tabControl1.Height - |
||
- | 809 | tabControl1.SelectedTab.Height + |
||
- | 810 | tabControl1.Margin.Top + |
||
- | 811 | tabControl1.Margin.Bottom + |
||
- | 812 | tabControl1.Padding.Y), |
||
- | 813 | StartPosition = FormStartPosition.Manual, |
||
- | 814 | Location = MousePosition, |
||
- | 815 | MaximizeBox = false, |
||
- | 816 | SizeGripStyle = SizeGripStyle.Hide, |
||
- | 817 | FormBorderStyle = FormBorderStyle.FixedSingle |
||
- | 818 | }; |
||
- | 819 | |
||
- | 820 | DetachedTabControl = new TabControl |
||
- | 821 | { |
||
- | 822 | Dock = DockStyle.Fill, |
||
- | 823 | SizeMode = TabSizeMode.Fixed |
||
- | 824 | }; |
||
- | 825 | DetachedTabControl.TabPages.Add(tabControl1.SelectedTab); |
||
- | 826 | DetachedForm.Controls.Add(DetachedTabControl); |
||
- | 827 | DetachedForm.FormClosing += DetachedFormOnFormClosing; |
||
- | 828 | DetachedForm.Show(); |
||
- | 829 | Cursor = Cursors.Default; |
||
- | 830 | return; |
||
- | 831 | } |
||
- | 832 | |
||
- | 833 | e.Action = DragAction.Continue; |
||
- | 834 | Cursor = Cursors.SizeAll; |
||
- | 835 | } |
||
- | 836 | |
||
- | 837 | private void DetachedFormOnFormClosing(object sender, FormClosingEventArgs e) |
||
- | 838 | { |
||
- | 839 | tabControl1.TabPages.Insert(DetachedTabControl.SelectedTab.TabIndex, DetachedTabControl.SelectedTab); |
||
- | 840 | DetachedForm.FormClosing -= DetachedFormOnFormClosing; |
||
753 | } |
841 | } |
|
Line 754... | Line 842... | |||
754 | |
842 | |
|
755 | #region Saving and loading |
843 | #region Saving and loading |
|
756 | |
844 | |