protected override void OnMouseMove(MouseEventArgs e)
 {
     if (IsSplitterFixed)
     {
         if (e.Button == MouseButtons.Left)
         {
             if (Orientation == Orientation.Vertical)
             {
                 if (e.X > 0 && e.X < Width)
                 {
                     SplitterDistance = e.X + _delta < 0 ? 0 : e.X + _delta;
                 }
             }
             else
             {
                 if (e.Y > 0 && e.Y < Height)
                 {
                     SplitterDistance = e.Y + _delta < 0 ? 0 : e.Y + _delta;
                 }
             }
         }
         else
         {
             IsSplitterFixed = false;
         }
         Invalidate();
     }
     else
     {
         if (SplitterRectangle.Contains(e.Location))
         {
             Cursor = Orientation == Orientation.Vertical ? Cursors.VSplit : Cursors.HSplit;
         }
     }
 }
Exemple #2
0
        protected override void OnDoubleClick(EventArgs e)
        {
            if (SplitterRectangle.Contains(PointToClient(Control.MousePosition)))
            {
                Collapsed = !Collapsed;

                return;
            }

            base.OnDoubleClick(e);
        }
Exemple #3
0
        private bool HoveringButtons(int x, int y)
        {
            if (!SplitterRectangle.Contains(x, y))
            {
                return(false);
            }

            return(_collapse1Rectangle.Contains(x, y) ||
                   _collapse2Rectangle.Contains(x, y) ||
                   _directionRectangle.Contains(x, y));
        }
Exemple #4
0
        private void UpdateCursor(int x, int y)
        {
            if (!SplitterRectangle.Contains(x, y) ||
                HoveringButtons(x, y))
            {
                Cursor = Cursors.Default;
                return;
            }

            Cursor = (Orientation == Orientation.Vertical ? Cursors.VSplit : Cursors.HSplit);

            return;
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            //鼠标在控制按钮区域
            if (SplitterRectangle.Contains(e.Location))
            {
                if (ControlRect.Contains(e.Location))
                {
                    //如果拆分器可移动,则鼠标在控制按钮范围内时临时关闭拆分器
                    if (!IsSplitterFixed)
                    {
                        IsSplitterFixed = true;

                        _isSplitterFixed = false;
                    }

                    Cursor      = Cursors.Hand;
                    _mouseState = MouseState.Hover;
                    Invalidate(ControlRect);
                }
                else
                {
                    //如果拆分器为临时关闭,则开启拆分器
                    if (!_isSplitterFixed)
                    {
                        IsSplitterFixed = false;
                        Cursor          = Orientation == Orientation.Horizontal ? Cursors.HSplit : Cursors.VSplit;
                    }
                    else
                    {
                        Cursor = Cursors.Default;
                    }
                    _mouseState = MouseState.Normal;
                    Invalidate(ControlRect);
                }
            }
            base.OnMouseMove(e);
        }