Пример #1
0
        /// <summary>
        /// On mouse move over title bar
        /// </summary>
        /// <param name="sender">sender of the event</param>
        /// <param name="e">event arg</param>
        private void OnMouseMoveInTitleBar(object sender, MouseEventArgs e)
        {
            if (_sizeMode == zSizeMode.Move)
            {
                Point location = TitleBar.PointToScreen(e.Location);
                ContinueMovementByMouse(location);

                return;
            }

            int buttonIndex = _titleRenderer.TitleBarButtonIndexUnderMouse;

            _titleRenderer.UpdateTitleBarButtonIndexUnderMouse(e.Location);
            if (buttonIndex != _titleRenderer.TitleBarButtonIndexUnderMouse)
            {
                TitleBar.Invalidate();
            }

            Cursor cursor = Cursors.Default;

            if (buttonIndex >= 0)
            {
                cursor = Cursors.Hand;
            }
            else if (_positioner != null)
            {
                if (_positioner.CanMove && CanMoveByMouse)
                {
                    cursor = Cursors.SizeAll;
                }
            }

            TitleBar.Cursor = cursor;
        }
Пример #2
0
 private void TitleBar_MouseMove(object sender, MouseEventArgs e)
 {
     if (isTopPanelDragged)
     {
         Point newPoint = TitleBar.PointToScreen(new Point(e.X, e.Y));
         newPoint.Offset(offset);
         this.Location = newPoint;
     }
 }
Пример #3
0
        /// <summary>
        /// On mouse down in title bar
        /// </summary>
        /// <param name="sender">sender of the event</param>
        /// <param name="e">event arg</param>
        private void OnMouseDownInTitleBar(object sender, MouseEventArgs e)
        {
            _sizeMode = zSizeMode.None;

            if (e.Button == MouseButtons.Left)
            {
                if (_titleRenderer.TitleBarButtonIndexUnderMouse >= 0)
                {
                    EventHandler handler = null;

                    int index = -1;
                    if (_titleRenderer.ShowContextMenuButton)
                    {
                        index++;
                        if (index == _titleRenderer.TitleBarButtonIndexUnderMouse)
                        {
                            handler = ContextButtonClick;
                        }
                    }

                    if (_titleRenderer.ShowAutohideButton)
                    {
                        index++;
                        if (index == _titleRenderer.TitleBarButtonIndexUnderMouse)
                        {
                            handler = AutohideButtonClick;
                        }
                    }

                    if (_titleRenderer.ShowCloseButton)
                    {
                        index++;
                        if (index == _titleRenderer.TitleBarButtonIndexUnderMouse)
                        {
                            handler = CloseButtonClick;
                        }
                    }

                    if (handler != null)
                    {
                        handler(this, EventArgs.Empty);
                    }
                }
                else if (CanMoveByMouse)
                {
                    BeginMovementByMouse(TitleBar.PointToScreen(e.Location));
                }
            }
        }