Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        internal override DockPosition GetDockPosition()
        {
            DockTreePosition?dockTreePosition = DockTreePosition;

            if (ChildrenVisibility == SplitChildrenVisibility.None)
            {
                return(DockPosition.Hidden);
            }
            else
            {
                return(DockPositionHelper.GetDockPosition(dockTreePosition, false));
            }
        }
Exemplo n.º 4
0
        internal override DockPosition GetDockPosition()
        {
            DockTreePosition?dockTreePosition = DockTreePosition;

            if (Items.Count == 0)
            {
                return(DockPosition.Unknown);
            }
            else if (VisibleItems.Count == 0)
            {
                return(DockPosition.Hidden);
            }

            return(DockPositionHelper.GetDockPosition(dockTreePosition, IsAutoHide));
        }
Exemplo n.º 5
0
            private static ShowAction GetShowAsDockTreeRootAction(DockItem item, DockPane pane)
            {
                DockControl        dockControl = item.DockControl;
                int                source      = dockControl.DockItems.IndexOf(item);
                DockItemShowMethod showMethod  = GetShowMethod(item, pane);

                DockTree dockTree = pane.DockTree;

                if (dockTree.IsFloating)
                {
                    FloatingWindow floatingWindow = dockTree.FloatingWindow;
                    Rect           bounds         = new Rect(floatingWindow.Left, floatingWindow.Top, floatingWindow.Width, floatingWindow.Height);
                    return(new ShowAsFloatingAction(source, bounds, showMethod));
                }
                else
                {
                    DockPosition dockPosition = DockPositionHelper.GetDockPosition(pane.DockTreePosition, pane.IsAutoHide);
                    return(new ShowAsDockPositionAction(source, dockPosition, showMethod));
                }
            }
Exemplo n.º 6
0
 internal DockPosition GetDockPosition(DockControl dockControl)
 {
     return(ShowMethod == DockItemShowMethod.Hide ? DockPosition.Hidden : DockPositionHelper.GetDockPosition(GetDockTreePosition(dockControl), GetIsAutoHide(dockControl)));
 }
Exemplo n.º 7
0
        private ShowAction GetShowAction(DockItem item, DockPane pane)
        {
            Debug.Assert(item != null);
            Debug.Assert(pane != null && pane.Items.Contains(item));
            Debug.Assert(item.FirstPane == pane || item.SecondPane == pane);

            int source = GetIndex(item);
            DockItemShowMethod showMethod = item.SecondPane == pane || item.IsHidden ? DockItemShowMethod.Hide : DockItemShowMethod.Activate;

            Collection <DockItem> items;
            ShowAction            action;

            if (_panes.Contains(pane))
            {
                items = GetItems(pane);
                DockItem targetItem   = items[0];
                int      targetIndex  = GetIndex(targetItem);
                DockItem itemToInsert = FindItemToInsert(item, pane);
                int      index        = itemToInsert == null ? -1 : items.IndexOf(itemToInsert);
                action = new ShowAsTabbedAction(source, targetIndex, pane.IsFloating, index, showMethod);
            }
            else
            {
                if (IsDockTreeEmpty(pane))
                {
                    DockTree dockTree = pane.DockTree;

                    if (dockTree.IsFloating)
                    {
                        showMethod = DockItemShowMethod.Activate;
                        FloatingWindow floatingWindow = dockTree.FloatingWindow;
                        Rect           bounds         = new Rect(floatingWindow.Left, floatingWindow.Top, floatingWindow.Width, floatingWindow.Height);
                        action = new ShowAsFloatingAction(source, bounds, showMethod);
                    }
                    else
                    {
                        DockPosition dockPosition = DockPositionHelper.GetDockPosition(pane.DockTreePosition, pane.IsAutoHide);
                        action = new ShowAsDockPositionAction(source, dockPosition, showMethod);
                    }
                }
                else
                {
                    DockPane      targetPane = null;
                    DockPaneSplit split;
                    for (split = pane.Parent; split != null; split = split.Parent)
                    {
                        foreach (DockPane pane1 in _panes)
                        {
                            if (split.IsParentOf(pane1))
                            {
                                targetPane = pane1;
                                break;
                            }
                        }
                        if (targetPane != null)
                        {
                            break;
                        }
                    }
                    Debug.Assert(targetPane != null);
                    Debug.Assert(split != null);

                    int ancestorSplitLevel = 0;
                    foreach (DockPaneSplit split1 in _splits)
                    {
                        if (split.IsParentOf(split1) && split1.IsParentOf(targetPane))
                        {
                            ancestorSplitLevel++;
                        }
                    }
                    action = GetShowAsSidePaneAction(item, pane, targetPane, ancestorSplitLevel, split, showMethod);
                    _splits.Add(split);
                }
                _panes.Add(pane);
                items = new Collection <DockItem>();
                _itemsCollections.Add(items);
            }
            items.Add(item);
            return(action);
        }