コード例 #1
0
        /// <inheritdoc />
        public override void OnMouseMove(Vector2 location)
        {
            // Cache mouse
            MousePosition = location;

            // Check if mouse is down
            if (IsMouseDown)
            {
                // Check if mouse is outside the header
                if (!HeaderRectangle.Contains(location))
                {
                    // Clear flag
                    IsMouseDown = false;

                    // Check tab under the mouse
                    if (!IsMouseDownOverCross && MouseDownWindow != null)
                    {
                        startDrag(MouseDownWindow);
                    }
                    MouseDownWindow = null;
                }
                // Check if has more than one tab to change order
                else if (MouseDownWindow != null && _panel.TabsCount > 1)
                {
                    // Check if mouse left current tab rect
                    Rectangle currWinRect;
                    getTabRect(MouseDownWindow, out currWinRect);
                    if (!currWinRect.Contains(location))
                    {
                        int index = _panel.GetTabIndex(MouseDownWindow);

                        // Check if move right or left
                        if (location.X < currWinRect.X)
                        {
                            // Move left
                            _panel.MoveTabLeft(index);
                        }
                        else if (_panel.LastTab != MouseDownWindow)
                        {
                            // Move right
                            _panel.MoveTabRight(index);
                        }

                        // Update
                        _panel.PerformLayout();
                    }
                }
            }

            base.OnMouseMove(location);
        }
コード例 #2
0
        internal void unlinkWindow(DockWindow window)
        {
            // Call event to the window
            window.OnUnlinkInternal();

            // Prevent this action during disposing (we don't want to modify Windows list)
            if (IsDisposing)
            {
                return;
            }

            // Remove from the windows list
            Windows.Remove(window);
        }
コード例 #3
0
        /// <inheritdoc />
        public override bool OnMouseDown(Vector2 location, MouseButton buttons)
        {
            // Check buttons
            if (buttons == MouseButton.Left)
            {
                // Cache data
                IsMouseDown     = true;
                MouseDownWindow = getTabAtPos(location, out IsMouseDownOverCross);
                if (!IsMouseDownOverCross && MouseDownWindow != null)
                {
                    _panel.SelectTab(MouseDownWindow);
                }
            }

            return(base.OnMouseDown(location, buttons));
        }
コード例 #4
0
        /// <inheritdoc />
        public override void OnMouseLeave()
        {
            // Check if mouse is down
            if (IsMouseDown)
            {
                // Clear flag
                IsMouseDown = false;

                // Check tabs under mouse position
                if (!IsMouseDownOverCross && MouseDownWindow != null)
                {
                    startDrag(MouseDownWindow);
                }
                MouseDownWindow = null;
            }

            base.OnMouseLeave();
        }
コード例 #5
0
        /// <summary>
        /// Docks the window.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="window">The window.</param>
        protected virtual void DockWindow(DockState state, DockWindow window)
        {
            createTabsProxy();

            // Check if dock like a tab or not
            if (state == DockState.DockFill)
            {
                // Add tab
                addTab(window);
            }
            else
            {
                // Create child panel
                var dockPanel = CreateChildPanel(state, DefaultSplitterValue);

                // Dock window as a tab in a child panel
                dockPanel.DockWindow(DockState.DockFill, window);
            }
        }
コード例 #6
0
        /// <summary>
        /// Creates the new dragging hit window.
        /// </summary>
        /// <param name="toMove">Dock window to move.</param>
        /// <returns>The dock hint window object.</returns>
        public static DockHintWindow Create(DockWindow toMove)
        {
            if (toMove == null)
            {
                throw new ArgumentNullException();
            }

            // Show floating
            toMove.ShowFloating();

            // Move window to the mouse position (with some offset for caption bar)
            var     window = toMove.ParentWindow;
            Vector2 mouse  = Application.MousePosition;

            window.NativeWindow.Position = mouse - new Vector2(8, 8);

            // Get floating panel
            var floatingPanelToMove = window.GetChild(0) as FloatWindowDockPanel;

            return(new DockHintWindow(floatingPanelToMove));
        }
コード例 #7
0
        private DockWindow getTabAtPos(Vector2 position, out bool closeButton)
        {
            DockWindow result = null;

            closeButton = false;

            var tabsCount = _panel.TabsCount;

            if (tabsCount == 1)
            {
                var crossRect = new Rectangle(Width - DockPanel.DefaultButtonsSize - DockPanel.DefaultButtonsMargin, (DockPanel.DefaultHeaderHeight - DockPanel.DefaultButtonsSize) / 2, DockPanel.DefaultButtonsSize, DockPanel.DefaultButtonsSize);
                if (HeaderRectangle.Contains(position))
                {
                    closeButton = crossRect.Contains(position);
                    result      = _panel.GetTab(0);
                }
            }
            else
            {
                float x = 0;
                for (int i = 0; i < tabsCount; i++)
                {
                    var   tab         = _panel.GetTab(i);
                    var   titleSize   = tab.TitleSize;
                    float width       = titleSize.X + DockPanel.DefaultButtonsSize + 2 * DockPanel.DefaultButtonsMargin + DockPanel.DefaultLeftTextMargin + DockPanel.DefaultRightTextMargin;
                    var   tabRect     = new Rectangle(x, 0, width, DockPanel.DefaultHeaderHeight);
                    bool  isMouseOver = tabRect.Contains(position);
                    if (isMouseOver)
                    {
                        var crossRect = new Rectangle(x + width - DockPanel.DefaultButtonsSize - DockPanel.DefaultButtonsMargin, (DockPanel.DefaultHeaderHeight - DockPanel.DefaultButtonsSize) / 2, DockPanel.DefaultButtonsSize, DockPanel.DefaultButtonsSize);
                        closeButton = crossRect.Contains(position);
                        result      = tab;
                        break;
                    }
                    x += width;
                }
            }

            return(result);
        }
コード例 #8
0
        /// <inheritdoc />
        public override bool OnMouseUp(Vector2 location, MouseButton buttons)
        {
            // Check buttons
            if (buttons == MouseButton.Left && IsMouseDown)
            {
                // Clear flag
                IsMouseDown = false;

                // Check tabs under mouse position at the begining and at the end
                bool overCross;
                var  tab = getTabAtPos(location, out overCross);

                // Check if tabs are the same and cross was pressed
                if (tab != null && tab == MouseDownWindow && IsMouseDownOverCross && overCross)
                {
                    tab.Close(ClosingReason.User);
                }
                MouseDownWindow = null;
            }

            return(base.OnMouseUp(location, buttons));
        }
コード例 #9
0
        /// <summary>
        /// Undocks the window.
        /// </summary>
        /// <param name="window">The window.</param>
        protected virtual void UndockWindow(DockWindow window)
        {
            var index = GetTabIndex(window);

            if (index == -1)
            {
                throw new IndexOutOfRangeException();
            }

            // Check if tab was selected
            if (window == SelectedTab)
            {
                // Change selection
                if (index == 0 && TabsCount > 1)
                {
                    SelectTab(1);
                }
                else
                {
                    SelectTab(index - 1);
                }
            }

            // Undock
            _tabs.RemoveAt(index);
            window.ParentDockPanel = null;

            // Check if has no more tabs
            if (_tabs.Count == 0)
            {
                OnLastTabRemoved();
            }
            else
            {
                // Update
                PerformLayout();
            }
        }
コード例 #10
0
 internal void linkWindow(DockWindow window)
 {
     // Add to the windows list
     Windows.Add(window);
 }
コード例 #11
0
 internal void UndockWindowInternal(DockWindow window)
 {
     UndockWindow(window);
 }
コード例 #12
0
 internal virtual void DockWindowInternal(DockState state, DockWindow window)
 {
     DockWindow(state, window);
 }
コード例 #13
0
 /// <summary>
 /// Determines whether panel contains the specifiedtab.
 /// </summary>
 /// <param name="tab">The tab.</param>
 /// <returns>
 ///   <c>true</c> if panel contains the specified tab; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsTab(DockWindow tab)
 {
     return(_tabs.Contains(tab));
 }
コード例 #14
0
 /// <summary>
 /// Gets tab at the given index.
 /// </summary>
 /// <param name="tab">The tab page.</param>
 /// <returns>The index of the given tab.</returns>
 public int GetTabIndex(DockWindow tab)
 {
     return(_tabs.IndexOf(tab));
 }