Table of Contents

Class ExDockManager

Namespace
ExControls
Assembly
ExControls.dll

Layout of a window into dockable panels like Visual Studio or Rider: the main content in Document and tool panels (ExDockPanel) docked to the left, right, top or bottom. A zone splits into nested rows and columns of groups, several panels in one group are tabs; splitters resize zones and groups. The user can hide a panel, collapse its group to the strip at the edge (auto-hide), drag it with the docking guides (a compass over a group or the document like in Visual Studio) to another place or to a floating window. SaveLayout() and LoadLayout(string?) keep the layout in a string for the application settings.

public class ExDockManager : Control, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable, IThemeable
Inheritance
ExDockManager
Implements
Inherited Members
Extension Methods

Remarks

The manager is created in code (place it with Fill, move the content of the form into Document), add all panels and then load the saved layout. It owns the panels: disposing the manager disposes all of them, including the hidden ones. Texts of the tool tips and the window menu are in Strings.

Constructors

ExDockManager()

Initializes a new instance of the ExDockManager class.

public ExDockManager()

Properties

ActivePanel

Gets the panel with the keyboard focus; null when the focus is in Document.

[Browsable(false)]
public ExDockPanel? ActivePanel { get; }

Property Value

ExDockPanel

AllowFloating

Gets or sets whether panels can be moved to floating windows (dragging out of the guides, the window menu, double-click on the caption).

[Browsable(false)]
public bool AllowFloating { get; set; }

Property Value

bool

DefaultSize

Gets the default size of the control.

protected override Size DefaultSize { get; }

Property Value

Size

The default Size of the control.

Document

Gets the container of the main content (the area between the docked zones).

[Browsable(false)]
public Panel Document { get; }

Property Value

Panel

Panels

Gets the panels added to the manager (shown and hidden) in the order of adding.

[Browsable(false)]
public IReadOnlyList<ExDockPanel> Panels { get; }

Property Value

IReadOnlyList<ExDockPanel>

Strings

Gets or sets the texts of the tool tips and the window menu.

[Browsable(false)]
public ExDockStrings Strings { get; set; }

Property Value

ExDockStrings

Methods

AddPanel(ExDockPanel, ExDockPanel)

Adds a panel as a tab to the group of another panel (the active tab of the group stays).

public void AddPanel(ExDockPanel panel, ExDockPanel tabWith)

Parameters

panel ExDockPanel

panel with a unique non-empty Key

tabWith ExDockPanel

panel of this manager whose group gets the new tab

Exceptions

ArgumentException

the panel is already in a manager, has no key or its key is used, or tabWith is not in this manager

AddPanel(ExDockPanel, ExDockPanel, ExDockSide)

Adds a panel to a new group next to the group of another panel: the target group is split and the new one is on the given side of it (nested rows and columns like dragging to an arrow of the compass).

public void AddPanel(ExDockPanel panel, ExDockPanel target, ExDockSide side)

Parameters

panel ExDockPanel

panel with a unique non-empty Key

target ExDockPanel

docked or collapsed panel of this manager

side ExDockSide

side of the target group where the new group goes

Exceptions

ArgumentException

the panel is already in a manager, has no key or its key is used, or target is not in this manager

InvalidOperationException

target is floating

AddPanel(ExDockPanel, ExDockSide)

Adds a panel to a new group at the end of the zone on a side and shows it.

public void AddPanel(ExDockPanel panel, ExDockSide side)

Parameters

panel ExDockPanel

panel with a unique non-empty Key

side ExDockSide

side of the zone

Exceptions

ArgumentException

the panel is already in a manager, has no key or its key is used

ApplyTheme(ExTheme)

Sets the colors and appearance of the control by the theme.

public void ApplyTheme(ExTheme theme)

Parameters

theme ExTheme

Dispose(bool)

Releases the unmanaged resources used by the Control and its child controls and optionally releases the managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

DockPanel(ExDockPanel, ExDockPanel)

Moves a panel (shown or hidden) as a tab into the group of another panel, makes it the active tab and shows it.

public void DockPanel(ExDockPanel panel, ExDockPanel tabWith)

Parameters

panel ExDockPanel

panel of this manager

tabWith ExDockPanel

panel of this manager whose group gets the tab

DockPanel(ExDockPanel, ExDockPanel, ExDockSide)

Docks a panel (shown or hidden) to a new group next to the group of another panel and shows it: the target group is split and the panel is on the given side of it.

public void DockPanel(ExDockPanel panel, ExDockPanel target, ExDockSide side)

Parameters

panel ExDockPanel

panel of this manager

target ExDockPanel

another docked or collapsed panel of this manager (a tab of the same group splits the group)

side ExDockSide

side of the target group where the panel goes

Exceptions

InvalidOperationException

target is floating or the panel itself

DockPanel(ExDockPanel, ExDockSide)

Docks a panel (shown or hidden) to a new group at the end of the zone on a side and shows it.

public void DockPanel(ExDockPanel panel, ExDockSide side)

Parameters

panel ExDockPanel

panel of this manager

side ExDockSide

side of the zone

FloatPanel(ExDockPanel)

Moves a panel (shown or hidden) to a floating window next to its current place and shows it; a panel that is alone in its group takes the whole group.

public void FloatPanel(ExDockPanel panel)

Parameters

panel ExDockPanel

panel of this manager

Exceptions

InvalidOperationException

AllowFloating or CanFloat is false

GetZoneSize(ExDockSide)

Gets the size of the zone on a side in logical pixels (96 DPI): the width of the left and right zones, the height of the top and bottom ones.

public int GetZoneSize(ExDockSide side)

Parameters

side ExDockSide

Returns

int

HidePanel(ExDockPanel)

Hides a panel; it keeps its place and ShowPanel(ExDockPanel, bool) returns it there. It does not raise PanelClosing.

public void HidePanel(ExDockPanel panel)

Parameters

panel ExDockPanel

panel of this manager

LoadLayout(string?)

Restores a layout saved by SaveLayout(). Call it after adding all panels: panels missing in the layout stay where they are, keys of panels not added are ignored. An empty string keeps the current layout.

public void LoadLayout(string? layout)

Parameters

layout string

saved layout; null or empty = no change

Exceptions

FormatException

the text is not a dock layout of a supported version (the layout does not change)

OnActivePanelChanged(EventArgs)

protected virtual void OnActivePanelChanged(EventArgs e)

Parameters

e EventArgs

OnDpiChangedAfterParent(EventArgs)

Raises the DpiChangedAfterParent event.

protected override void OnDpiChangedAfterParent(EventArgs e)

Parameters

e EventArgs

An DpiChangedEventArgs that contains the event data.

OnFontChanged(EventArgs)

Raises the FontChanged event.

protected override void OnFontChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnLayout(LayoutEventArgs)

Raises the Layout event.

protected override void OnLayout(LayoutEventArgs levent)

Parameters

levent LayoutEventArgs

A LayoutEventArgs that contains the event data.

OnMouseCaptureChanged(EventArgs)

Raises the MouseCaptureChanged event.

protected override void OnMouseCaptureChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnMouseDown(MouseEventArgs)

Raises the MouseDown event.

protected override void OnMouseDown(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseLeave(EventArgs)

Raises the MouseLeave event.

protected override void OnMouseLeave(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

OnMouseMove(MouseEventArgs)

Raises the MouseMove event.

protected override void OnMouseMove(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnMouseUp(MouseEventArgs)

Raises the MouseUp event.

protected override void OnMouseUp(MouseEventArgs e)

Parameters

e MouseEventArgs

A MouseEventArgs that contains the event data.

OnPaint(PaintEventArgs)

Raises the Paint event.

protected override void OnPaint(PaintEventArgs e)

Parameters

e PaintEventArgs

A PaintEventArgs that contains the event data.

OnPanelClosing(ExDockPanelClosingEventArgs)

Raises PanelClosing.

protected virtual void OnPanelClosing(ExDockPanelClosingEventArgs e)

Parameters

e ExDockPanelClosingEventArgs

OnPanelStateChanged(ExDockPanelEventArgs)

protected virtual void OnPanelStateChanged(ExDockPanelEventArgs e)

Parameters

e ExDockPanelEventArgs

OnVisibleChanged(EventArgs)

Raises the VisibleChanged event.

protected override void OnVisibleChanged(EventArgs e)

Parameters

e EventArgs

An EventArgs that contains the event data.

RemovePanel(ExDockPanel)

Removes a panel from the manager (the panel is not disposed).

public void RemovePanel(ExDockPanel panel)

Parameters

panel ExDockPanel

panel of this manager

SaveLayout()

Saves the layout (zones and their sizes, nested rows and columns of groups, tabs, collapsed and hidden panels, floating windows) to a single-line XML string for the application settings. Panels are identified by Key; sizes are in logical pixels, so the layout survives a DPI change.

public string SaveLayout()

Returns

string

the layout for LoadLayout(string?)

SetAutoHide(ExDockPanel, bool)

Collapses the group of a panel to the strip at the edge or docks it again; a floating group is docked first.

public void SetAutoHide(ExDockPanel panel, bool autoHide)

Parameters

panel ExDockPanel

panel of this manager

autoHide bool

collapse (true) or dock (false)

SetZoneSize(ExDockSide, int)

Sets the size of the zone on a side in logical pixels (96 DPI); the layout shrinks it when the document would not fit.

public void SetZoneSize(ExDockSide side, int size)

Parameters

side ExDockSide

side of the zone

size int

width of the left and right zones, height of the top and bottom ones

ShowPanel(ExDockPanel, bool)

Shows a hidden panel at its last place and selects its tab; with activate it also moves the focus into the panel (a collapsed panel slides out, a floating window comes to the front).

public void ShowPanel(ExDockPanel panel, bool activate = true)

Parameters

panel ExDockPanel

panel of this manager

activate bool

move the focus into the panel

WndProc(ref Message)

Processes Windows messages.

protected override void WndProc(ref Message m)

Parameters

m Message

The Windows Message to process.

Events

ActivePanelChanged

Occurs when ActivePanel changes.

public event EventHandler? ActivePanelChanged

Event Type

EventHandler

PanelClosing

Occurs before the user hides a panel; the application can keep it open.

public event EventHandler<ExDockPanelClosingEventArgs>? PanelClosing

Event Type

EventHandler<ExDockPanelClosingEventArgs>

PanelStateChanged

Occurs when a panel changes its state or side (shown, hidden, docked elsewhere, collapsed, floated, removed).

public event EventHandler<ExDockPanelEventArgs>? PanelStateChanged

Event Type

EventHandler<ExDockPanelEventArgs>