Skip to content

Commit e9fc0ad

Browse files
committed
TabControl improvements
1 parent 0a2c8ab commit e9fc0ad

10 files changed

+45
-9
lines changed

.vs/QuickLibrary/v16/.suo

-512 Bytes
Binary file not shown.
Binary file not shown.

QuickLibrary/QlibTabControl.cs

+36-9
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public class QlibTabControl : TabControl
7171
/// Selected tab text color
7272
/// </summary>
7373
public Color selectedTextColor = Color.FromArgb(255, 255, 255);
74+
75+
/// <summary>
76+
/// Enable tab drag&drop
77+
/// </summary>
78+
public bool enableDragDrop = false;
79+
7480
/// <summary>
7581
/// Init
7682
/// </summary>
@@ -86,6 +92,20 @@ public QlibTabControl()
8692
AllowDrop = true;
8793
}
8894

95+
[Category("Options"), Browsable(true), Description("Enable tab drag&drop")]
96+
public bool EnableDragDrop
97+
{
98+
get
99+
{
100+
return this.enableDragDrop;
101+
}
102+
103+
set
104+
{
105+
this.enableDragDrop = value;
106+
}
107+
}
108+
89109
[Category("Colors"), Browsable(true), Description("The color of the selected page")]
90110
public Color ActiveColor
91111
{
@@ -240,16 +260,19 @@ protected override void CreateHandle()
240260
/// <param name="drgevent"></param>
241261
protected override void OnDragOver(DragEventArgs drgevent)
242262
{
243-
var draggedTab = (TabPage)drgevent.Data.GetData(typeof(TabPage));
244-
var pointedTab = getPointedTab();
245-
246-
if (ReferenceEquals(draggedTab, predraggedTab) && pointedTab != null)
263+
if (enableDragDrop)
247264
{
248-
drgevent.Effect = DragDropEffects.Move;
265+
var draggedTab = (TabPage)drgevent.Data.GetData(typeof(TabPage));
266+
var pointedTab = getPointedTab();
249267

250-
if (!ReferenceEquals(pointedTab, draggedTab))
268+
if (ReferenceEquals(draggedTab, predraggedTab) && pointedTab != null)
251269
{
252-
this.ReplaceTabPages(draggedTab, pointedTab);
270+
drgevent.Effect = DragDropEffects.Move;
271+
272+
if (!ReferenceEquals(pointedTab, draggedTab))
273+
{
274+
this.ReplaceTabPages(draggedTab, pointedTab);
275+
}
253276
}
254277
}
255278

@@ -262,7 +285,11 @@ protected override void OnDragOver(DragEventArgs drgevent)
262285
/// <param name="e"></param>
263286
protected override void OnMouseDown(MouseEventArgs e)
264287
{
265-
predraggedTab = getPointedTab();
288+
if (enableDragDrop)
289+
{
290+
predraggedTab = getPointedTab();
291+
}
292+
266293
var p = e.Location;
267294
if (!this.ShowClosingButton)
268295
{
@@ -378,7 +405,7 @@ protected override void OnPaint(PaintEventArgs e)
378405
// Draws the back of the color when it is selected
379406
Drawer.FillRectangle(
380407
new SolidBrush(this.activeColor),
381-
new Rectangle(Header.X - 5, Header.Y - 3, Header.Width, Header.Height + 5));
408+
new Rectangle(Header.X - 2, Header.Y - 3, Header.Width - 3, Header.Height + 5));
382409

383410
// Draws the title of the page
384411
Drawer.DrawString(
512 Bytes
Binary file not shown.
-2 KB
Binary file not shown.

QuickLibrary/obj/Release/QuickLibrary.csproj.FileListAbsolute.txt

+9
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ D:\Projects\DotNet\quick-library\QuickLibrary\obj\Release\QuickLibrary.csproj.Co
1717
D:\Projects\DotNet\quick-library\QuickLibrary\obj\Release\QuickLibrary.dll
1818
D:\Projects\DotNet\quick-library\QuickLibrary\obj\Release\QuickLibrary.pdb
1919
D:\Projects\DotNet\quick-library\QuickLibrary\obj\Release\QuickLibrary.csprojAssemblyReference.cache
20+
D:\Projects\quick-library\QuickLibrary\bin\Release\QuickLibrary.dll
21+
D:\Projects\quick-library\QuickLibrary\bin\Release\QuickLibrary.pdb
22+
D:\Projects\quick-library\QuickLibrary\bin\Release\Octokit.dll
23+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.DownloadForm.resources
24+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.Properties.Resources.resources
25+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.csproj.GenerateResource.cache
26+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.csproj.CopyComplete
27+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.dll
28+
D:\Projects\quick-library\QuickLibrary\obj\Release\QuickLibrary.pdb
Binary file not shown.
Binary file not shown.
512 Bytes
Binary file not shown.
-2 KB
Binary file not shown.

0 commit comments

Comments
 (0)