Ejemplo 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;
        }
Ejemplo 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;
        }
 private static void SetAutoHideSize(DockItem dockItem, SplitterDistance value)
 {
     dockItem.AutoHideSize = value;
     if (DockPositionHelper.IsAutoHide(dockItem.DockPosition) && !dockItem.IsSelected)
     {
         dockItem.Show(DockItemShowMethod.Select);
     }
 }
Ejemplo n.º 4
0
        internal override DockPosition GetDockPosition()
        {
            DockTreePosition?dockTreePosition = DockTreePosition;

            if (ChildrenVisibility == SplitChildrenVisibility.None)
            {
                return(DockPosition.Hidden);
            }
            else
            {
                return(DockPositionHelper.GetDockPosition(dockTreePosition, false));
            }
        }
Ejemplo n.º 5
0
        private IEnumerable <DockItem> GetAutoHideItems()
        {
            foreach (DockPane pane in _autoHidePanes)
            {
                if (!DockPositionHelper.IsAutoHide(pane.DockPosition))
                {
                    continue;
                }

                foreach (DockItem item in pane.VisibleItems)
                {
                    yield return(item);
                }
            }
        }
Ejemplo n.º 6
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));
        }
Ejemplo n.º 7
0
        private DockItem GetActiveItem()
        {
            DockItem activeItem = _panes.Count > 0 ? _panes[_panes.Count - 1].SelectedItem : null;

            if (activeItem == null || !activeItem.IsSelected)
            {
                return(null);
            }
            else if (DockPositionHelper.IsAutoHide(activeItem.DockPosition) && !activeItem.IsKeyboardFocusWithin)
            {
                return(null);
            }
            else
            {
                return(activeItem);
            }
        }
Ejemplo n.º 8
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));
                }
            }
Ejemplo n.º 9
0
        private void RefreshChildrenVisibility()
        {
            bool showChild1, showChild2;

            showChild1 = showChild2 = true;
            if (Child1 == null || Child1.DockPosition == DockPosition.Hidden || DockPositionHelper.IsAutoHide(Child1.DockPosition))
            {
                showChild1 = false;
            }

            if (Child2 == null || Child2.DockPosition == DockPosition.Hidden || DockPositionHelper.IsAutoHide(Child2.DockPosition))
            {
                showChild2 = false;
            }

            SplitChildrenVisibility newChildrenVisibility;

            if (showChild1 && showChild2)
            {
                newChildrenVisibility = SplitChildrenVisibility.Both;
            }
            else if (showChild1)
            {
                newChildrenVisibility = SplitChildrenVisibility.Child1Only;
            }
            else if (showChild2)
            {
                newChildrenVisibility = SplitChildrenVisibility.Child2Only;
            }
            else
            {
                newChildrenVisibility = SplitChildrenVisibility.None;
            }

            SplitChildrenVisibility oldChildrenVisibility = ChildrenVisibility;

            if (oldChildrenVisibility != newChildrenVisibility)
            {
                ChildrenVisibility = newChildrenVisibility;
            }
        }
Ejemplo n.º 10
0
 internal DockPosition GetDockPosition(DockControl dockControl)
 {
     return(ShowMethod == DockItemShowMethod.Hide ? DockPosition.Hidden : DockPositionHelper.GetDockPosition(GetDockTreePosition(dockControl), GetIsAutoHide(dockControl)));
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
 internal override bool GetIsAutoHide(DockControl dockControl)
 {
     return(DockPositionHelper.IsAutoHide(_dockPosition));
 }
Ejemplo n.º 13
0
 internal override DockTreePosition?GetDockTreePosition(DockControl dockControl)
 {
     return(DockPositionHelper.GetDockTreePosition(_dockPosition));
 }