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"> <Compile Include="Docking\DarkToolWindow.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Docking\Items\DarkDockSplitter.cs" />
<Compile Include="Extensions\BitmapExtensions.cs" /> <Compile Include="Extensions\BitmapExtensions.cs" />
<Compile Include="Forms\DarkDialog.cs"> <Compile Include="Forms\DarkDialog.cs">
<SubType>Form</SubType> <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 that was the final content in the group then remove the group
if (group.ContentCount == 0) if (group.ContentCount == 0)
{ RemoveGroup(group);
_groups.Remove(group);
PositionGroups();
}
// Check if we have any groups left. If not then hide the region // If we just removed the final group, and this isn't the document region, then hide
if (_groups.Count == 0) if (_groups.Count == 0 && DockArea != DarkDockArea.Document)
Visible = false; Visible = false;
} }
@ -93,6 +90,14 @@ namespace DarkUI
return newGroup; return newGroup;
} }
private void RemoveGroup(DarkDockGroup group)
{
_groups.Remove(group);
Controls.Remove(group);
PositionGroups();
}
private void PositionGroups() private void PositionGroups()
{ {
DockStyle dockStyle; DockStyle dockStyle;

View File

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

View File

@ -28,12 +28,24 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.lstConsole = new DarkUI.DarkListView();
this.SuspendLayout(); 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 // DockConsole
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lstConsole);
this.DockArea = DarkUI.DarkDockArea.Bottom; this.DockArea = DarkUI.DarkDockArea.Bottom;
this.DockText = "Console"; this.DockText = "Console";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -45,5 +57,7 @@
} }
#endregion #endregion
private DarkUI.DarkListView lstConsole;
} }
} }

View File

@ -9,6 +9,13 @@ namespace Example
public DockConsole() public DockConsole()
{ {
InitializeComponent(); 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 #endregion

View File

@ -28,12 +28,26 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.treeProject = new DarkUI.DarkTreeView();
this.SuspendLayout(); 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 // DockProject
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.treeProject);
this.DockArea = DarkUI.DarkDockArea.Left; this.DockArea = DarkUI.DarkDockArea.Left;
this.DockText = "Project Explorer"; this.DockText = "Project Explorer";
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -45,5 +59,7 @@
} }
#endregion #endregion
private DarkUI.DarkTreeView treeProject;
} }
} }

View File

@ -9,6 +9,25 @@ namespace Example
public DockProject() public DockProject()
{ {
InitializeComponent(); 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 #endregion

View File

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