mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-04 16:19:25 +03:00
Can now drag document tabs.
This commit is contained in:
parent
b1eef2985c
commit
f8625669a8
@ -19,6 +19,8 @@ namespace DarkUI.Docking
|
|||||||
|
|
||||||
private DarkDockTabArea _tabArea;
|
private DarkDockTabArea _tabArea;
|
||||||
|
|
||||||
|
private DarkDockTab _dragTab = null;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Property Region
|
#region Property Region
|
||||||
@ -414,6 +416,61 @@ namespace DarkUI.Docking
|
|||||||
{
|
{
|
||||||
base.OnMouseMove(e);
|
base.OnMouseMove(e);
|
||||||
|
|
||||||
|
if (_dragTab != null)
|
||||||
|
{
|
||||||
|
var offsetX = e.Location.X + _tabArea.Offset;
|
||||||
|
if (offsetX < _dragTab.ClientRectangle.Left)
|
||||||
|
{
|
||||||
|
if (_dragTab.DockContent.Order > 0)
|
||||||
|
{
|
||||||
|
var otherTabs = _tabs.Values.Where(t => t.DockContent.Order == _dragTab.DockContent.Order - 1).ToList();
|
||||||
|
if (otherTabs.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var otherTab = otherTabs.First();
|
||||||
|
|
||||||
|
if (otherTab == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var oldIndex = _dragTab.DockContent.Order;
|
||||||
|
_dragTab.DockContent.Order = oldIndex - 1;
|
||||||
|
otherTab.DockContent.Order = oldIndex;
|
||||||
|
|
||||||
|
BuildTabs();
|
||||||
|
EnsureVisible();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (offsetX > _dragTab.ClientRectangle.Right)
|
||||||
|
{
|
||||||
|
var maxOrder = _contents.Count;
|
||||||
|
|
||||||
|
if (_dragTab.DockContent.Order < maxOrder)
|
||||||
|
{
|
||||||
|
var otherTabs = _tabs.Values.Where(t => t.DockContent.Order == _dragTab.DockContent.Order + 1).ToList();
|
||||||
|
if(otherTabs.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var otherTab = otherTabs.First();
|
||||||
|
|
||||||
|
if (otherTab == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var oldIndex = _dragTab.DockContent.Order;
|
||||||
|
_dragTab.DockContent.Order = oldIndex + 1;
|
||||||
|
otherTab.DockContent.Order = oldIndex;
|
||||||
|
|
||||||
|
BuildTabs();
|
||||||
|
EnsureVisible();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
||||||
{
|
{
|
||||||
_tabArea.DropdownHot = true;
|
_tabArea.DropdownHot = true;
|
||||||
@ -480,6 +537,7 @@ namespace DarkUI.Docking
|
|||||||
{
|
{
|
||||||
DockPanel.ActiveContent = tab.DockContent;
|
DockPanel.ActiveContent = tab.DockContent;
|
||||||
EnsureVisible();
|
EnsureVisible();
|
||||||
|
_dragTab = tab;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,6 +551,8 @@ namespace DarkUI.Docking
|
|||||||
{
|
{
|
||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
|
|
||||||
|
_dragTab = null;
|
||||||
|
|
||||||
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
if (_tabArea.DropdownRectangle.Contains(e.Location))
|
||||||
{
|
{
|
||||||
if (_tabArea.DropdownHot)
|
if (_tabArea.DropdownHot)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user