DockPanel System
DockPanel, DockGroup, and DockLayoutTree — the core data model powering the Beep docking system
Table of Contents
Overview
The docking data model consists of three core types that work together to represent the full docking state:
- DockPanel — The atomic unit: a single dockable content window
- DockGroup — A tree node organizing panels and nested groups
- DockLayoutTree — The root container owning the full hierarchy
DockPanel
Namespace: TheTechIdea.Beep.Winform.Controls.Docking.Models
Inheritance: System.Windows.Forms.Panel
Key Properties
| Property | Type | Description |
|---|---|---|
| Key | string | Unique identifier (required) |
| Title | string | Display title in caption/tab. Default "Tool Window" |
| Content | Control | Hosted user control. Set to fill panel |
| State | DockPanelState | Current display state (Docked/Float/AutoHidden/Hidden/Closed) |
| DockPosition | DockPosition | Docked edge (Left/Right/Top/Bottom/Fill) |
| Group | DockGroup | Owning group. Set internally by manager |
| CanClose / CanFloat / CanAutoHide | bool | Capability flags controlling allowed operations |
| AllowedAreas | DockAreas | Bitmask of allowed dock positions |
| IsDirty | bool | Unsaved changes indicator (asterisk in tab) |
| ShowCaption | bool | Draw own caption bar. True when floating |
| PreferredWidth / MinWidth | int | Sizing constraints |
Key Events
Activated / Deactivated— Panel selection changedClosed— Panel moved to closed storePropertyChanged— Panel property changed
DockGroup
Inheritance: object (not a control — pure data model)
Key Properties
| Property | Type | Description |
|---|---|---|
| Id | string | Unique GUID identifier (default: Guid.NewGuid()) |
| Position | DockPosition | Docked edge |
| SplitOrientation | SplitOrientation | Horizontal or Vertical split direction for child groups |
| SplitRatio | float | Proportional split (0.1-0.9, default 0.5) |
| Parent | DockGroup | Parent group (null for root) |
| Children | IReadOnlyList<DockGroup> | Child groups (for split layouts) |
| Panels | IReadOnlyList<DockPanel> | Panels in this group |
| ActivePanel | DockPanel | Currently active panel. Setter fires events |
| Bounds | Rectangle | Cached client rectangle (set internally) |
Key Methods
GetAllPanelsRecursive()— Flat list of all descendant panelsFindPanelRecursive(string key)— Deep search by panel keyGetPanelIndex(DockPanel)— Position within Panels listToString()— Diagnostic string showing structure
DockLayoutTree
Inheritance: object
Key Properties
| Property | Type | Description |
|---|---|---|
| Root | DockGroup | Root group (auto-creates on first get). Id="root", Position=Fill |
| SchemaVersion | int | Layout format version. Default 1 |
| Name | string | Layout name. Default "Default" |
| CreatedUtc / ModifiedUtc | DateTime | Timestamps |
Key Methods
RegisterPanel / UnregisterPanel— Panel registry managementRegisterGroup / UnregisterGroup— Group registry managementGetRootGroupsByPosition()— Root-level groups per DockPositionGetDiagnostics()— Summary string of entire layoutClear()— Resets all registries and root
Relationships
DockLayoutTree
└── DockGroup (Root, Id="root", Position=Fill)
├── DockGroup (Position=Left)
│ ├── DockPanel (Key="explorer", Title="Explorer")
│ └── DockPanel (Key="toolbox", Title="Toolbox")
├── DockGroup (Position=Fill, SplitOrientation=Horizontal)
│ ├── DockGroup (child, no position)
│ │ └── DockPanel (Key="editor1")
│ └── DockGroup (child, no position)
│ └── DockPanel (Key="editor2")
└── DockGroup (Position=Bottom)
└── DockPanel (Key="output")Examples
// Navigate the tree
var root = manager.LayoutTree.Root;
foreach (var posGroup in root.Children)
{
Console.WriteLine($"Group {posGroup.Id}: {posGroup.Position}");
foreach (var panel in posGroup.GetAllPanelsRecursive())
Console.WriteLine($" Panel: {panel.Key} = {panel.Title}");
}
// Find specific panel
var explorer = manager.LayoutTree.FindPanel("explorer");
var ownerGroup = explorer.Group; // owning DockGroup
var siblings = ownerGroup.Panels; // panels in same group