Overview

Namespace: TheTechIdea.Beep.Winform.Controls.Docking.Models

DockLayoutDefinition is the root serializable object for persisting docking layouts. It contains three collections that capture the complete state:

Serialization Classes

DockLayoutDefinition (root)

PropertyTypeDescription
SchemaVersionintLayout format version. Default 1
GroupsList<DockGroupDefinition>Top-level docked groups (content-serialized)
FloatingList<FloatingPanelInfo>Floating panel positions
AutoHiddenList<AutoHiddenPanelInfo>Auto-hidden panel edges
IsEmptyboolTrue when all collections are null/empty

DockGroupDefinition

PropertyTypeDescription
PositionDockPositionDocked edge. Default Left
SplitOrientationSplitOrientationHorizontal or Vertical. Default Horizontal
SplitRatiofloatProportional split. Default 0.5
PanelKeysList<string>Panel keys in this group (content-serialized)
ActivePanelKeystringKey of active panel. Default null
ChildrenList<DockGroupDefinition>Nested split children (content-serialized)

FloatingPanelInfo

PropertyTypeDescription
KeystringPanel identifier
BoundsRectangleScreen position and size
LastDockPositionDockPositionPosition before floating. Default Left

AutoHiddenPanelInfo

PropertyTypeDescription
KeystringPanel identifier
EdgeDockPositionAuto-hide edge. Default Left

JSON Format

{
  "SchemaVersion": 1,
  "Groups": [
    {
      "Position": "Left",
      "SplitOrientation": "Horizontal",
      "SplitRatio": 0.3,
      "PanelKeys": ["explorer", "toolbox"],
      "ActivePanelKey": "explorer",
      "Children": []
    },
    {
      "Position": "Fill",
      "SplitOrientation": "Vertical",
      "SplitRatio": 0.6,
      "PanelKeys": [],
      "ActivePanelKey": null,
      "Children": [
        {
          "PanelKeys": ["editor1"],
          "ActivePanelKey": "editor1"
        },
        {
          "PanelKeys": ["editor2"],
          "ActivePanelKey": "editor2"
        }
      ]
    }
  ],
  "Floating": [
    {
      "Key": "output",
      "Bounds": "100,100,600,400",
      "LastDockPosition": "Bottom"
    }
  ],
  "AutoHidden": [
    {
      "Key": "properties",
      "Edge": "Right"
    }
  ]
}

Examples

// Save to file
var def = manager.LayoutTree.ToDefinition();
string json = JsonConvert.SerializeObject(def, Formatting.Indented);
File.WriteAllText("layout.json", json);

// Restore from file
string json = File.ReadAllText("layout.json");
var def = JsonConvert.DeserializeObject<DockLayoutDefinition>(json);
manager.MaterializeFromDefinition(def);

// Check if layout is empty
if (def.IsEmpty)
    Console.WriteLine("No layout to restore");