Fixed docking groups

Groups were being kept on scope because they weren't being removed from
the region's control array.
This commit is contained in:
Robin 2015-09-19 13:16:44 +01:00
parent 5a57b1011c
commit 8d49f8ce77
8 changed files with 75 additions and 7 deletions

View File

@ -106,6 +106,7 @@
<Compile Include="Docking\DarkToolWindow.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Docking\Items\DarkDockSplitter.cs" />
<Compile Include="Extensions\BitmapExtensions.cs" />
<Compile Include="Forms\DarkDialog.cs">
<SubType>Form</SubType>

View File

@ -72,13 +72,10 @@ namespace DarkUI
// If that was the final content in the group then remove the group
if (group.ContentCount == 0)
{
_groups.Remove(group);
PositionGroups();
}
RemoveGroup(group);
// Check if we have any groups left. If not then hide the region
if (_groups.Count == 0)
// If we just removed the final group, and this isn't the document region, then hide
if (_groups.Count == 0 && DockArea != DarkDockArea.Document)
Visible = false;
}
@ -93,6 +90,14 @@ namespace DarkUI
return newGroup;
}
private void RemoveGroup(DarkDockGroup group)
{
_groups.Remove(group);
Controls.Remove(group);
PositionGroups();
}
private void PositionGroups()
{
DockStyle dockStyle;

View File

@ -0,0 +1,6 @@
namespace DarkUI
{
public class DarkDockSplitter
{
}
}

View File

@ -28,12 +28,24 @@
/// </summary>
private void InitializeComponent()
{
this.lstConsole = new DarkUI.DarkListView();
this.SuspendLayout();
//
// lstConsole
//
this.lstConsole.Dock = System.Windows.Forms.DockStyle.Fill;
this.lstConsole.Location = new System.Drawing.Point(0, 25);
this.lstConsole.MultiSelect = true;
this.lstConsole.Name = "lstConsole";
this.lstConsole.Size = new System.Drawing.Size(500, 175);
this.lstConsole.TabIndex = 0;
this.lstConsole.Text = "darkListView1";
//
// DockConsole
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lstConsole);
this.DockArea = DarkUI.DarkDockArea.Bottom;
this.DockText = "Console";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -45,5 +57,7 @@
}
#endregion
private DarkUI.DarkListView lstConsole;
}
}

View File

@ -9,6 +9,13 @@ namespace Example
public DockConsole()
{
InitializeComponent();
// Build dummy list data
for (var i = 0; i < 100; i++)
{
var item = new DarkListItem(string.Format("List item #{0}", i));
lstConsole.Items.Add(item);
}
}
#endregion

View File

@ -28,12 +28,26 @@
/// </summary>
private void InitializeComponent()
{
this.treeProject = new DarkUI.DarkTreeView();
this.SuspendLayout();
//
// treeProject
//
this.treeProject.AllowMoveNodes = true;
this.treeProject.Dock = System.Windows.Forms.DockStyle.Fill;
this.treeProject.Location = new System.Drawing.Point(0, 25);
this.treeProject.MultiSelect = true;
this.treeProject.Name = "treeProject";
this.treeProject.ShowIcons = true;
this.treeProject.Size = new System.Drawing.Size(280, 425);
this.treeProject.TabIndex = 0;
this.treeProject.Text = "darkTreeView1";
//
// DockProject
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.treeProject);
this.DockArea = DarkUI.DarkDockArea.Left;
this.DockText = "Project Explorer";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -45,5 +59,7 @@
}
#endregion
private DarkUI.DarkTreeView treeProject;
}
}

View File

@ -9,6 +9,25 @@ namespace Example
public DockProject()
{
InitializeComponent();
// Build dummy nodes
var childCount = 0;
for (var i = 0; i < 20; i++)
{
var node = new DarkTreeNode(string.Format("Root node #{0}", i));
node.ExpandedIcon = Icons.folder_open;
node.Icon = Icons.folder_closed;
for (var x = 0; x < 10; x++)
{
var childNode = new DarkTreeNode(string.Format("Child node #{0}", childCount));
childNode.Icon = Icons.files;
childCount++;
node.Nodes.Add(childNode);
}
treeProject.Nodes.Add(node);
}
}
#endregion

View File

@ -34,7 +34,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.DockArea = DarkUI.DarkDockArea.Right;
this.DockArea = DarkUI.DarkDockArea.Left;
this.DockText = "Properties";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Icon = global::Example.Icons.properties_16xLG;