public void AddContent(DarkDockContent dockContent, DarkDockGroup dockGroup) { if (_contents.Contains(dockContent)) { RemoveContent(dockContent); } dockContent.DockPanel = this; _contents.Add(dockContent); if (dockGroup != null) { dockContent.DockArea = dockGroup.DockArea; } if (dockContent.DockArea == DarkDockArea.None) { dockContent.DockArea = dockContent.DefaultDockArea; } DarkDockRegion region = _regions[dockContent.DockArea]; region.AddContent(dockContent, dockGroup); ContentAdded?.Invoke(this, new DockContentEventArgs(dockContent)); if (_contents.Count == 1) { dockContent.Select(); } }
public void RestoreDockPanelState(DockPanelState state, Func <string, DarkDockContent> getContentBySerializationKey) { foreach (var region in state.Regions) { switch (region.Area) { case DarkDockArea.Left: _regions[DarkDockArea.Left].Size = region.Size; break; case DarkDockArea.Right: _regions[DarkDockArea.Right].Size = region.Size; break; case DarkDockArea.Bottom: _regions[DarkDockArea.Bottom].Size = region.Size; break; } foreach (var group in region.Groups) { DarkDockContent previousContent = null; DarkDockContent visibleContent = null; foreach (var contentKey in group.Contents) { var content = getContentBySerializationKey(contentKey); if (content == null) { continue; } content.DockArea = region.Area; if (previousContent == null) { AddContent(content); } else { AddContent(content, previousContent.DockGroup); } previousContent = content; if (group.VisibleContent == contentKey) { visibleContent = content; } } if (visibleContent != null) { visibleContent.Select(); } } } }
public void InsertContent(DarkDockContent dockContent, DarkDockGroup dockGroup, DockInsertType insertType) { if (_contents.Contains(dockContent)) { RemoveContent(dockContent); } dockContent.DockPanel = this; _contents.Add(dockContent); dockContent.DockArea = dockGroup.DockArea; var region = _regions[dockGroup.DockArea]; region.InsertContent(dockContent, dockGroup, insertType); ContentAdded?.Invoke(this, new DockContentEventArgs(dockContent)); if (_contents.Count == 1) { dockContent.Select(); } }