Пример #1
0
        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();
            }
        }
Пример #2
0
        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);
        }