Can now drag content in to empty regions.

This commit is contained in:
Robin 2016-01-05 10:59:44 +00:00
parent fe9d60dc0e
commit 7cd946b372
4 changed files with 83 additions and 108 deletions

View File

@ -22,16 +22,22 @@ namespace DarkUI.Docking
#region Constructor Region
internal DockDropArea(DarkDockRegion region, DockInsertType insertType)
internal DockDropArea(DarkDockPanel dockPanel, DarkDockRegion region)
{
DockPanel = dockPanel;
DockRegion = region;
InsertType = insertType;
InsertType = DockInsertType.None;
BuildAreas();
}
internal DockDropArea(DarkDockGroup group, DockInsertType insertType)
internal DockDropArea(DarkDockPanel dockPanel, DarkDockGroup group, DockInsertType insertType)
{
DockPanel = dockPanel;
DockGroup = group;
InsertType = insertType;
BuildAreas();
}
#endregion
@ -48,7 +54,67 @@ namespace DarkUI.Docking
private void BuildRegionAreas()
{
switch (DockRegion.DockArea)
{
case DarkDockArea.Left:
var leftRect = new Rectangle
{
X = DockPanel.PointToScreen(Point.Empty).X,
Y = DockPanel.PointToScreen(Point.Empty).Y,
Width = 50,
Height = DockPanel.Height
};
DropArea = leftRect;
HighlightArea = leftRect;
break;
case DarkDockArea.Right:
var rightRect = new Rectangle
{
X = DockPanel.PointToScreen(Point.Empty).X + DockPanel.Width - 50,
Y = DockPanel.PointToScreen(Point.Empty).Y,
Width = 50,
Height = DockPanel.Height
};
DropArea = rightRect;
HighlightArea = rightRect;
break;
case DarkDockArea.Bottom:
var x = DockPanel.PointToScreen(Point.Empty).X;
var width = DockPanel.Width;
if (DockPanel.Regions[DarkDockArea.Left].Visible)
{
x += DockPanel.Regions[DarkDockArea.Left].Width;
width -= DockPanel.Regions[DarkDockArea.Left].Width;
}
if (DockPanel.Regions[DarkDockArea.Right].Visible)
{
width -= DockPanel.Regions[DarkDockArea.Right].Width;
}
var bottomRect = new Rectangle
{
X = x,
Y = DockPanel.PointToScreen(Point.Empty).Y + DockPanel.Height - 50,
Width = width,
Height = 50
};
DropArea = bottomRect;
HighlightArea = bottomRect;
break;
}
}
private void BuildGroupAreas()

View File

@ -14,33 +14,11 @@
#region Constructor Region
internal DockDropCollection(DarkDockPanel dockPanel, DarkDockRegion region)
{
DropArea = new DockDropArea(region, DockInsertType.None);
InsertBeforeArea = new DockDropArea(region, DockInsertType.Before);
InsertAfterArea = new DockDropArea(region, DockInsertType.After);
BuildAreas();
}
internal DockDropCollection(DarkDockPanel dockPanel, DarkDockGroup group)
{
DropArea = new DockDropArea(group, DockInsertType.None);
InsertBeforeArea = new DockDropArea(group, DockInsertType.Before);
InsertAfterArea = new DockDropArea(group, DockInsertType.After);
BuildAreas();
}
#endregion
#region Method Region
private void BuildAreas()
{
DropArea.BuildAreas();
InsertBeforeArea.BuildAreas();
InsertAfterArea.BuildAreas();
DropArea = new DockDropArea(dockPanel, group, DockInsertType.None);
InsertBeforeArea = new DockDropArea(dockPanel, group, DockInsertType.Before);
InsertAfterArea = new DockDropArea(dockPanel, group, DockInsertType.After);
}
#endregion

View File

@ -22,7 +22,7 @@ namespace DarkUI.Win32
private DarkDockGroup _targetGroup;
private DockInsertType _insertType = DockInsertType.None;
private Dictionary<DarkDockRegion, DockDropCollection> _regionDropAreas = new Dictionary<DarkDockRegion, DockDropCollection>();
private Dictionary<DarkDockRegion, DockDropArea> _regionDropAreas = new Dictionary<DarkDockRegion, DockDropArea>();
private Dictionary<DarkDockGroup, DockDropCollection> _groupDropAreas = new Dictionary<DarkDockGroup, DockDropCollection>();
#endregion
@ -98,7 +98,7 @@ namespace DarkUI.Win32
public void StartDrag(DarkDockContent content)
{
_regionDropAreas = new Dictionary<DarkDockRegion, DockDropCollection>();
_regionDropAreas = new Dictionary<DarkDockRegion, DockDropArea>();
_groupDropAreas = new Dictionary<DarkDockGroup, DockDropCollection>();
// Add all regions and groups to the drop collections
@ -116,65 +116,11 @@ namespace DarkUI.Win32
_groupDropAreas.Add(group, collection);
}
}
// If the region is NOT visible then build a drop area for the region itself.
// If the region is NOT visible then build drop areas for the region itself.
else
{
/*var rect = new Rectangle();
switch (region.DockArea)
{
case DarkDockArea.Left:
rect = new Rectangle
{
X = _dockPanel.PointToScreen(Point.Empty).X,
Y = _dockPanel.PointToScreen(Point.Empty).Y,
Width = 15,
Height = _dockPanel.Height
};
break;
case DarkDockArea.Right:
rect = new Rectangle
{
X = _dockPanel.PointToScreen(Point.Empty).X + _dockPanel.Width - 15,
Y = _dockPanel.PointToScreen(Point.Empty).Y,
Width = 15,
Height = _dockPanel.Height
};
break;
case DarkDockArea.Bottom:
var x = _dockPanel.PointToScreen(Point.Empty).X;
var width = _dockPanel.Width;
if (_dockPanel.Regions[DarkDockArea.Left].Visible)
{
x += _dockPanel.Regions[DarkDockArea.Left].Width;
width -= _dockPanel.Regions[DarkDockArea.Left].Width;
}
if (_dockPanel.Regions[DarkDockArea.Right].Visible)
{
width -= _dockPanel.Regions[DarkDockArea.Right].Width;
}
rect = new Rectangle
{
X = x,
Y = _dockPanel.PointToScreen(Point.Empty).Y + _dockPanel.Height - 15,
Width = width,
Height = 15
};
break;
}
_regionDropAreas.Add(region, rect);*/
var area = new DockDropArea(_dockPanel, region);
_regionDropAreas.Add(region, area);
}
}
@ -219,29 +165,13 @@ namespace DarkUI.Win32
_targetGroup = null;
// Check all region drop areas
foreach (var collection in _regionDropAreas.Values)
foreach (var area in _regionDropAreas.Values)
{
if (collection.InsertBeforeArea.DropArea.Contains(location))
{
_insertType = DockInsertType.Before;
_targetRegion = collection.InsertBeforeArea.DockRegion;
UpdateHighlightForm(collection.InsertBeforeArea.HighlightArea);
return;
}
if (collection.InsertAfterArea.DropArea.Contains(location))
{
_insertType = DockInsertType.After;
_targetRegion = collection.InsertAfterArea.DockRegion;
UpdateHighlightForm(collection.InsertAfterArea.HighlightArea);
return;
}
if (collection.DropArea.DropArea.Contains(location))
if (area.DropArea.Contains(location))
{
_insertType = DockInsertType.None;
_targetRegion = collection.DropArea.DockRegion;
UpdateHighlightForm(collection.DropArea.HighlightArea);
_targetRegion = area.DockRegion;
UpdateHighlightForm(area.HighlightArea);
return;
}
}

View File

@ -16,11 +16,12 @@ DarkUI
-- ScrollView not taking in to account size WITHOUT scrollbars causing you to have to overshoot when re-sizing to get rid of them
-- if the final node in a treeview has been previous expanded, pressing 'down' will cause it to re-open
-- create click-through panel
-- dragging treeview nodes doesn't rebuild prev/next references
Dock panel
-- make it so highlight form doesn't steal focus
-- add splitters between region groups
-- fix max position of splitters
-- fix max position of splitters - can currently resize a tool window offscreen
-- serialise the visible content for groups and the active content
-- right click tab menu. close all, close all but this etc. etc.
-- stop dragging tabs instantly going to the end of the row