示例#1
0
 /// <summary>
 /// Closes all open <see cref="AutoHidePane"/>s except one.
 /// </summary>
 /// <param name="dockTabPane">
 /// The content of the <see cref="AutoHidePane"/> that should stay open.
 /// </param>
 internal void CloseAutoHidePanesExcept(IDockTabPane dockTabPane)
 {
     foreach (var autoHideBar in _autoHideBars)
     {
         autoHideBar.CloseAutoHidePanesExcept(dockTabPane);
     }
 }
示例#2
0
 private void ShowAutoHidePane(IDockTabPane dockTabPane, IDockTabItem dockTabItem)
 {
     CloseAutoHidePanesExcept(dockTabPane);
     foreach (var autoHideBar in _autoHideBars)
     {
         var autoHidePane = autoHideBar.ShowAutoHidePane(dockTabPane, dockTabItem, true);
         if (autoHidePane != null)
         {
             break;
         }
     }
 }
示例#3
0
 internal void CloseAutoHidePanesExcept(IDockTabPane dockTabPane)
 {
     for (int i = _autoHideOverlays.Count - 1; i >= 0; i--)
     {
         var autoHideOverlay = _autoHideOverlays[i];
         var autoHidePane    = (AutoHidePane)autoHideOverlay.Content;
         if (autoHidePane.Content != dockTabPane)
         {
             CloseAutoHidePane(autoHidePane);
         }
     }
 }
示例#4
0
        private AutoHidePane GetAutoHidePane(IDockTabPane dockTabPane)
        {
            foreach (var autoHideOverlay in _autoHideOverlays)
            {
                var autoHidePane = (AutoHidePane)autoHideOverlay.Content;
                if (autoHidePane.Content == dockTabPane)
                {
                    return(autoHidePane);
                }
            }

            return(null);
        }
            public SerializationContext(IDockControl dockControl)
            {
                Debug.Assert(dockControl != null);
                Debug.Assert(dockControl.DockStrategy != null);

                DockControl = dockControl;

                var dockStrategy = dockControl.DockStrategy;

                DefaultFloatWindow    = dockStrategy.CreateFloatWindow();
                DefaultDockAnchorPane = dockStrategy.CreateDockAnchorPane();
                DefaultDockSplitPane  = dockStrategy.CreateDockSplitPane();
                DefaultDockTabPane    = dockStrategy.CreateDockTabPane();
            }
        /// <summary>
        /// Replaces the items with invisible proxies.
        /// </summary>
        /// <param name="currentPane">
        /// The <see cref="IDockTabPane"/> where the items are currently visible. Item proxies will
        /// be added to this pane, but the original items will be kept.
        /// </param>
        private void ReplaceItemsWithProxies(IDockTabPane currentPane)
        {
            Debug.Assert(_dockStrategy != null);

            ReplaceItemsWithProxies(_dockStrategy.DockControl.RootPane, _draggedItems, currentPane);

            foreach (var floatWindow in _dockStrategy.DockControl.FloatWindows)
            {
                ReplaceItemsWithProxies(floatWindow.RootPane, _draggedItems, currentPane);
            }

            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideLeft, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideRight, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideTop, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideBottom, _draggedItems, currentPane);
        }
示例#7
0
        internal AutoHidePane ShowAutoHidePane(IDockTabPane dockTabPane, IDockTabItem dockTabItem, bool focus)
        {
            if (dockTabPane == null || !Items.Contains(dockTabPane))
            {
                return(null);
            }

            var dockControl = DockHelper.GetDockControl(this);

            // Ensure that correct item is selected.
            if (dockTabItem != null)
            {
                Debug.Assert(dockTabPane.Items.Contains(dockTabItem));
                dockTabPane.SelectedItem = dockTabItem;
            }

            // Get or create AutoHidePane that shows the DockTabItem.
            var autoHidePane = GetAutoHidePane(dockTabPane);

            if (autoHidePane == null)
            {
                // Create a new AutoHidePane if necessary.
                autoHidePane = new AutoHidePane
                {
                    Content = dockTabPane,
                    Dock    = Dock,
                };
                var autoHideOverlay = new AutoHideOverlay(dockControl, TargetArea)
                {
                    Content = autoHidePane
                };
                autoHideOverlay.Show();
                _autoHideOverlays.Add(autoHideOverlay);
            }

            // Slide-in AutoHidePane.
            autoHidePane.Show();

            if (focus)
            {
                dockControl?.DockStrategy?.Activate(dockTabPane);
            }

            return(autoHidePane);
        }
示例#8
0
        private static void ReplaceItemsWithProxies(IDockPane dockPane, List<IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(items != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                    ReplaceItemsWithProxies(dockAnchorPane.ChildPane, items, currentPane);
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                ReplaceItemsWithProxies(dockSplitPane.ChildPanes, items, currentPane);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                if (dockTabPane == currentPane)
                {
                    // Special: If the IDockTabPane is the current pane, add the item proxies but
                    // keep the original items.
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items.Insert(i + 1, new DockTabItemProxy(dockTabPane.Items[i]));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                            dockTabPane.Items[i] = new DockTabItemProxy(dockTabPane.Items[i]);
                    }
                }
            }
        }
        private static void ReplaceItemsWithProxies(IDockPane dockPane, List <IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPane != null);
            Debug.Assert(items != null);

            if (dockPane is IDockAnchorPane)
            {
                var dockAnchorPane = (IDockAnchorPane)dockPane;
                if (dockAnchorPane.ChildPane != null)
                {
                    ReplaceItemsWithProxies(dockAnchorPane.ChildPane, items, currentPane);
                }
            }
            else if (dockPane is IDockSplitPane)
            {
                var dockSplitPane = (IDockSplitPane)dockPane;
                ReplaceItemsWithProxies(dockSplitPane.ChildPanes, items, currentPane);
            }
            else if (dockPane is IDockTabPane)
            {
                var dockTabPane = (IDockTabPane)dockPane;
                if (dockTabPane == currentPane)
                {
                    // Special: If the IDockTabPane is the current pane, add the item proxies but
                    // keep the original items.
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items.Insert(i + 1, new DockTabItemProxy(dockTabPane.Items[i]));
                            i++;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < dockTabPane.Items.Count; i++)
                    {
                        if (items.IndexOf(dockTabPane.Items[i]) >= 0)
                        {
                            dockTabPane.Items[i] = new DockTabItemProxy(dockTabPane.Items[i]);
                        }
                    }
                }
            }
        }
示例#10
0
 internal void CloseAutoHidePanesExcept(IDockTabPane dockTabPane)
 {
     for (int i = _autoHideOverlays.Count - 1; i >= 0; i--)
     {
         var autoHideOverlay = _autoHideOverlays[i];
         var autoHidePane = (AutoHidePane)autoHideOverlay.Content;
         if (autoHidePane.Content != dockTabPane)
             CloseAutoHidePane(autoHidePane);
     }
 }
示例#11
0
        internal AutoHidePane ShowAutoHidePane(IDockTabPane dockTabPane, IDockTabItem dockTabItem, bool focus)
        {
            if (dockTabPane == null || !Items.Contains(dockTabPane))
                return null;

            var dockControl = DockHelper.GetDockControl(this);

            // Ensure that correct item is selected.
            if (dockTabItem != null)
            {
                Debug.Assert(dockTabPane.Items.Contains(dockTabItem));
                dockTabPane.SelectedItem = dockTabItem;
            }

            // Get or create AutoHidePane that shows the DockTabItem.
            var autoHidePane = GetAutoHidePane(dockTabPane);
            if (autoHidePane == null)
            {
                // Create a new AutoHidePane if necessary.
                autoHidePane = new AutoHidePane
                {
                    Content = dockTabPane,
                    Dock = Dock,
                };
                var autoHideOverlay = new AutoHideOverlay(dockControl, TargetArea)
                {
                    Content = autoHidePane
                };
                autoHideOverlay.Show();
                _autoHideOverlays.Add(autoHideOverlay);
            }

            // Slide-in AutoHidePane.
            autoHidePane.Show();

            if (focus)
                dockControl?.DockStrategy?.Activate(dockTabPane);

            return autoHidePane;
        }
示例#12
0
        /// <summary>
        /// Starts a drag operation.
        /// </summary>
        /// <param name="floatWindow">The <see cref="FloatWindow"/> to be dragged.</param>
        /// <param name="dockTabPane">The <see cref="DockTabPane"/> to be dragged.</param>
        /// <param name="dockTabItem">The <see cref="DockTabItem"/> to be dragged.</param>
        /// <returns>
        /// <see langword="true" /> if the drag operation has been started; otherwise,
        /// <see langword="false" /> if the drag operation could not be started (e.g. because the
        /// mouse could not be captured).
        /// </returns>
        private bool BeginDrag(FloatWindow floatWindow, DockTabPane dockTabPane, DockTabItem dockTabItem)
        {
            _dockStrategy = _dockControl.GetViewModel()?.DockStrategy;
            if (_dockStrategy == null || _dockStrategy.DockControl.IsLocked)
            {
                Reset();
                return(false);
            }

            FrameworkElement element     = null;
            IDockTabPane     draggedPane = null;
            IDockTabItem     draggedItem = null;

            if (floatWindow != null)
            {
                // User is dragging a FloatWindow.
                // (Note: Dragging of FloatWindows with nested layouts is not supported.)
                draggedPane  = floatWindow.GetViewModel()?.RootPane as IDockTabPane;
                element      = floatWindow;
                _floatWindow = floatWindow;
                _initialSize = floatWindow.RenderSize;

                // Start dragging immediately.
                _dragDeltaExceeded = true;
            }
            else if (dockTabItem != null)
            {
                // User is dragging a DockTabItem in a DockTabPanel.
                draggedItem        = dockTabItem.GetViewModel();
                element            = dockTabItem;
                _targetDockTabPane = dockTabPane;
                _initialSize       = dockTabPane.RenderSize;

                // Start dragging when threshold is exceeded.
                _initialMousePosition = WindowsHelper.GetMousePosition(_dockControl);
                _dragDeltaExceeded    = false;
            }
            else if (dockTabPane != null)
            {
                // User is dragging a DockTabPane.
                draggedPane           = dockTabPane.GetViewModel();
                element               = dockTabPane;
                _initialSize          = dockTabPane.RenderSize;
                _initialMousePosition = WindowsHelper.GetMousePosition(_dockControl);

                // Start dragging when threshold is exceeded.
                _initialMousePosition = WindowsHelper.GetMousePosition(_dockControl);
                _dragDeltaExceeded    = false;
            }

            if (draggedPane == null && draggedItem == null)
            {
                Reset();
                return(false);
            }

            // When the user is dragging the FloatWindow, the mouse is captured by Win32 move window
            // loop. When dragging a DockTabPane or DockTabItem, the mouse needs to be
            // captured to receive mouse events.
            if (_floatWindow == null)
            {
                if (!_dockControl.CaptureMouse())
                {
                    // Failed to capture the mouse.
                    Reset();
                    return(false);
                }

                _dockControl.LostMouseCapture  += OnLostMouseCapture;
                _dockControl.MouseLeftButtonUp += OnMouseLeftButtonUp;
                _dockControl.MouseMove         += OnMouseMove;
                _dockControl.PreviewKeyDown    += OnPreviewKeyDown;
                if (_targetDockTabPane != null)
                {
                    _targetDockTabPane.PreviewKeyDown += OnPreviewKeyDown;
                }
            }

            _dockStrategy.Begin();

            if (draggedPane != null)
            {
                _dockStrategy.Activate(draggedPane);
                _activeItem = draggedPane.SelectedItem;
                foreach (var item in draggedPane.Items)
                {
                    if (item.DockState == draggedPane.DockState)
                    {
                        _draggedItems.Add(item);
                    }
                }
            }
            else
            {
                Debug.Assert(draggedItem != null);

                _dockStrategy.Activate(draggedItem);
                _activeItem = draggedItem;
                _draggedItems.Add(draggedItem);
            }

            Debug.Assert(_draggedItems.Count > 0);

            // Determine whether dragged items may end in a FloatWindow.
            _canFloat = CanFloat();

            // Store the mouse offset relative to the dragged element.
            _mouseOffset = (Vector)WindowsHelper.GetMousePosition(element);

            // Remember information needed for a rollback.
            ReplaceItemsWithProxies(draggedPane ?? _targetDockTabPane.GetViewModel());
            _originalDockState = _draggedItems[0].DockState;
            BackupFloatWindowPosition();

            // Override mouse cursors. (Mouse cursor should not change to caret over text editor.)
            Mouse.OverrideCursor = Cursors.Arrow;

            return(true);
        }
示例#13
0
        /// <summary>
        /// Replaces the items with invisible proxies.
        /// </summary>
        /// <param name="currentPane">
        /// The <see cref="IDockTabPane"/> where the items are currently visible. Item proxies will
        /// be added to this pane, but the original items will be kept.
        /// </param>
        private void ReplaceItemsWithProxies(IDockTabPane currentPane)
        {
            Debug.Assert(_dockStrategy != null);

            ReplaceItemsWithProxies(_dockStrategy.DockControl.RootPane, _draggedItems, currentPane);

            foreach (var floatWindow in _dockStrategy.DockControl.FloatWindows)
                ReplaceItemsWithProxies(floatWindow.RootPane, _draggedItems, currentPane);

            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideLeft, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideRight, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideTop, _draggedItems, currentPane);
            ReplaceItemsWithProxies(_dockStrategy.DockControl.AutoHideBottom, _draggedItems, currentPane);
        }
示例#14
0
 private void ShowAutoHidePane(IDockTabPane dockTabPane, IDockTabItem dockTabItem)
 {
     CloseAutoHidePanesExcept(dockTabPane);
     foreach (var autoHideBar in _autoHideBars)
     {
         var autoHidePane = autoHideBar.ShowAutoHidePane(dockTabPane, dockTabItem, true);
         if (autoHidePane != null)
             break;
     }
 }
        private static void ReplaceItemsWithProxies(IReadOnlyList <IDockPane> dockPanes, List <IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPanes != null);
            Debug.Assert(items != null);

            for (int i = 0; i < dockPanes.Count; i++)
            {
                ReplaceItemsWithProxies(dockPanes[i], items, currentPane);
            }
        }
示例#16
0
        private AutoHidePane GetAutoHidePane(IDockTabPane dockTabPane)
        {
            foreach (var autoHideOverlay in _autoHideOverlays)
            {
                var autoHidePane = (AutoHidePane)autoHideOverlay.Content;
                if (autoHidePane.Content == dockTabPane)
                    return autoHidePane;
            }

            return null;
        }
示例#17
0
            public SerializationContext(IDockControl dockControl)
            {
                Debug.Assert(dockControl != null);
                Debug.Assert(dockControl.DockStrategy != null);

                DockControl = dockControl;

                var dockStrategy = dockControl.DockStrategy;
                DefaultFloatWindow = dockStrategy.CreateFloatWindow();
                DefaultDockAnchorPane = dockStrategy.CreateDockAnchorPane();
                DefaultDockSplitPane = dockStrategy.CreateDockSplitPane();
                DefaultDockTabPane = dockStrategy.CreateDockTabPane();
            }
示例#18
0
        private static void ReplaceItemsWithProxies(IReadOnlyList<IDockPane> dockPanes, List<IDockTabItem> items, IDockTabPane currentPane)
        {
            Debug.Assert(dockPanes != null);
            Debug.Assert(items != null);

            for (int i = 0; i < dockPanes.Count; i++)
                ReplaceItemsWithProxies(dockPanes[i], items, currentPane);
        }
示例#19
0
 /// <summary>
 /// Closes all open <see cref="AutoHidePane"/>s except one.
 /// </summary>
 /// <param name="dockTabPane">
 /// The content of the <see cref="AutoHidePane"/> that should stay open.
 /// </param>
 internal void CloseAutoHidePanesExcept(IDockTabPane dockTabPane)
 {
     foreach (var autoHideBar in _autoHideBars)
         autoHideBar.CloseAutoHidePanesExcept(dockTabPane);
 }