private void CommitChanges(bool force) { if (!_isDirty && !force) { return; } foreach (DockPaneNode node in _dirtyNodes) { node.RefreshState(); } _dirtyNodes.Clear(); DockPaneNode rootNode = RootNode; IsVisible = (rootNode != null && rootNode.DockPosition == DockPositionHelper.GetDockPosition(Position, false)); UpdateVisiblePanes(); UpdateAutoHidePanes(); UpdateAutoHideItems(); if (_floatingWindow != null) { _floatingWindow.CountOfVisiblePanes = _visiblePanes.Count; _floatingWindow.FirstVisiblePane = _visiblePanes.Count == 0 ? null : _visiblePanes[0]; _floatingWindow.IsVisible = IsVisible; if (_panes.Count == 0) // Fix bug #1 https://github.com/DevZest/WpfDocking/issues/1 { _floatingWindow.DockControl.RemoveFloatingWindow(_floatingWindow); } } _isDirty = false; }
internal void RemovePane(DockPane pane) { Debug.Assert(pane.DockTree == this); Debug.Assert(pane.Items.Count == 0); RemovePaneFromCollection(pane); DockPaneSplit splitToRemove = pane.Parent; if (splitToRemove == null) { SetRootNode(null); } else { AddDirtyNode(splitToRemove); DockPaneNode siblingNode = splitToRemove.GetSibling(pane); Debug.Assert(siblingNode != null); AddDirtyNode(siblingNode); DockPaneSplit grandParent = splitToRemove.Parent; splitToRemove.ClearChildren(); if (grandParent == null) { SetRootNode(siblingNode); } else { AddDirtyNode(grandParent); grandParent.SetSibling(grandParent.GetSibling(splitToRemove), siblingNode); } splitToRemove.ClearParent(); } }
private static DockPane FindPane(DockPaneNode node, bool isAutoHide) { DockPane pane = node as DockPane; if (pane != null && pane.IsAutoHide == isAutoHide) { return(pane); } DockPaneSplit split = node as DockPaneSplit; if (split != null) { pane = FindPane(split.Child1, isAutoHide); if (pane != null) { return(pane); } pane = FindPane(split.Child2, isAutoHide); if (pane != null) { return(pane); } } return(null); }
private void CommitChanges(bool force) { if (!_isDirty && !force) { return; } foreach (DockPaneNode node in _dirtyNodes) { node.RefreshState(); } _dirtyNodes.Clear(); DockPaneNode rootNode = RootNode; IsVisible = (rootNode != null && rootNode.DockPosition == DockPositionHelper.GetDockPosition(Position, false)); UpdateVisiblePanes(); UpdateAutoHidePanes(); UpdateAutoHideItems(); if (_floatingWindow != null) { _floatingWindow.CountOfVisiblePanes = _visiblePanes.Count; _floatingWindow.FirstVisiblePane = _visiblePanes.Count == 0 ? null : _visiblePanes[0]; _floatingWindow.IsVisible = IsVisible; } _isDirty = false; }
internal DockPaneSplit(DockPaneNode child1, DockPaneNode child2, Orientation orientation, bool isSplitterTopLeft, SplitterDistance splitterDistance) { Child1 = child1; Child2 = child2; Orientation = orientation; IsSplitterTopLeft = isSplitterTopLeft; SplitterDistance = splitterDistance; }
private ShowAsSidePaneCommand(DockItem dockItem, DockPaneNode paneNode, bool isAutoHide, Dock side, SplitterDistance size, bool isSizeForTarget, DockItemShowMethod showMethod) : base(dockItem, showMethod) { TargetPaneNode = paneNode; _isAutoHide = isAutoHide; _side = side; _size = size; _isSizeForTarget = isSizeForTarget; }
internal sealed override void Run(DockItem dockItem, DockPane targetPane) { DockPaneNode targetPaneNode = targetPane; for (int i = 0; i < AncestorLevel; i++) { targetPaneNode = targetPaneNode.Parent; } dockItem.Show(targetPaneNode, IsAutoHide, Side, Size, IsSizeForTarget, ShowMethod); }
public DockPaneNode ToDockPaneNode(DockControl dockControl) { DockItem item = dockControl.DockItems[ItemIndex]; DockPaneNode paneNode = item.FirstPane.IsFloating == IsFloating ? item.FirstPane : item.SecondPane; for (int i = 0; i < AncestorLevel; i++) { paneNode = paneNode.Parent; } return(paneNode); }
internal bool IsParentOf(DockPaneNode paneNode) { for (DockPaneSplit split = paneNode.Parent; split != null; split = split.Parent) { if (split == this) { return(true); } } return(false); }
internal void AddDirtyNode(DockPaneNode node) { if (_dirtyNodes.Contains(node)) { return; } node.LockState(); _dirtyNodes.Add(node); _isDirty = true; }
internal DockPaneNode GetSibling(DockPaneNode node) { Debug.Assert(Child1 == node || Child2 == node); if (Child1 == node) { return(Child2); } else { return(Child1); } }
public static void Execute(DockItem dockItem, DockPaneNode paneNode, bool isAutoHide, Dock side, SplitterDistance size, bool isSizeForTarget, DockItemShowMethod showMethod) { DockControl dockControl = paneNode.DockControl; Debug.Assert(dockControl != null); if (TestUndo(dockItem, dockControl)) { dockControl.ExecuteCommand(new ShowAsSidePaneCommand(dockItem, paneNode, isAutoHide, side, size, isSizeForTarget, showMethod)); } else // if (dockItem.DockControl == dockControl) Fix for 1.1.3730: this condition will prevent unattached DockItem from showing { dockItem.DoShowAsSidePane(paneNode, isAutoHide, side, size, isSizeForTarget, showMethod); } }
public ShowAsSidePaneEventArgs(DockItem dockItem, DockPaneNode paneNode, bool isAutoHide, Dock side, SplitterDistance size, bool isSizeForTarget, DockItemShowMethod showMethod) : base(dockItem, paneNode.DockControl, showMethod) { ShowAsSidePaneAction showAction = StrongTypeShowAction; DockPaneNodeStruct paneNodeStruct = DockPaneNodeStruct.FromDockPaneNode(paneNode); showAction.Target = paneNodeStruct.ItemIndex; showAction.IsFloating = paneNodeStruct.IsFloating; showAction.AncestorLevel = paneNodeStruct.AncestorLevel; showAction.IsAutoHide = isAutoHide; showAction.Side = side; showAction.Size = size; showAction.IsSizeForTarget = isSizeForTarget; }
internal void SetSibling(DockPaneNode node, DockPaneNode newValue) { Debug.Assert(Child1 == node || Child2 == node); Debug.Assert(newValue != null); Debug.Assert(newValue.Parent == null); if (Child1 == node) { SetValue(Child2PropertyKey, newValue); } else { SetValue(Child1PropertyKey, newValue); } newValue.SetParent(this); }
private static ShowAction GetShowAsSidePaneAction(DockItem item, DockPane pane) { DockPaneSplit split = pane.Parent; Debug.Assert(split != null); DockPaneNode targetPaneNode = split.Child1 == pane ? split.Child2 : split.Child1; Debug.Assert(targetPaneNode != null); DockPaneNodeStruct targetPaneNodeStruct = DockPaneNodeStruct.FromDockPaneNode(targetPaneNode); bool swapChildren = split.Child1 == targetPaneNode; Dock side; if (split.Orientation == Orientation.Horizontal) { if (split.IsSplitterTopLeft) { side = Dock.Left; } else { side = Dock.Right; } } else { if (split.IsSplitterTopLeft) { side = Dock.Top; } else { side = Dock.Bottom; } } SplitterDistance splitterDistance = split.SplitterDistance; int source = pane.DockControl.DockItems.IndexOf(item); int targetIndex = targetPaneNodeStruct.ItemIndex; bool isFloating = targetPaneNodeStruct.IsFloating; int ancestorLevel = targetPaneNodeStruct.AncestorLevel; bool isAutoHide = pane.IsAutoHide; DockItemShowMethod showMethod = GetShowMethod(item, pane); return(new ShowAsSidePaneAction(source, targetIndex, isFloating, ancestorLevel, isAutoHide, side, splitterDistance, swapChildren, showMethod)); }
private void SetRootNode(DockPaneNode newValue, bool clearOldValueParent) { DockPaneNode oldValue = RootNode; if (oldValue == newValue) { return; } SetValue(RootNodePropertyKey, newValue); if (oldValue != null && clearOldValueParent) { oldValue.ClearParent(); } if (newValue != null) { newValue.SetParent(this); } }
public static DockPaneNodeStruct FromDockPaneNode(DockPaneNode paneNode) { DockControl dockControl = paneNode.DockControl; Debug.Assert(dockControl != null); int ancestorSplitLevel = 0; DockPaneNode node; for (node = paneNode; node is DockPaneSplit; node = (node as DockPaneSplit).Child1) { ancestorSplitLevel++; } DockPane pane = node as DockPane; Debug.Assert(pane != null); DockItem item = pane.Items[0]; int itemIndex = dockControl.DockItems.IndexOf(item); bool isFloating = paneNode.IsFloating; return(new DockPaneNodeStruct(itemIndex, isFloating, ancestorSplitLevel)); }
internal DockPane AddItem(DockItem item, DockPaneNode targetPaneNode, bool isAutoHide, Dock side, SplitterDistance size, bool isSizeForTarget) { Debug.Assert(targetPaneNode.DockTree == this); DockPane pane = DockControl.PaneManager.CreatePane(item, isAutoHide); AddDirtyNode(pane); AddDirtyNode(targetPaneNode); DockPaneSplit parent = targetPaneNode.Parent; DockPaneNode child1 = side == Dock.Left || side == Dock.Top ? pane : targetPaneNode; DockPaneNode child2 = side == Dock.Left || side == Dock.Top ? targetPaneNode : pane; Orientation orientation = side == Dock.Left || side == Dock.Right ? Orientation.Horizontal : Orientation.Vertical; bool isSplitterTopLeft = isSizeForTarget ? child1 == targetPaneNode : child2 == targetPaneNode; targetPaneNode.ClearParent(); DockPaneSplit newSplit; newSplit = new DockPaneSplit(child1, child2, orientation, isSplitterTopLeft, size); AddDirtyNode(newSplit); if (parent != null) { AddDirtyNode(parent); parent.SetSibling(parent.GetSibling(targetPaneNode), newSplit); } else { SetRootNode(newSplit, false); } AddPaneToCollection(pane); Debug.Assert(newSplit.Child1 != null); Debug.Assert(newSplit.Child1.Parent == newSplit); Debug.Assert(newSplit.Child2 != null); Debug.Assert(newSplit.Child2.Parent == newSplit); return(pane); }
private void SetRootNode(DockPaneNode newValue) { SetRootNode(newValue, true); }