コード例 #1
0
        /// <summary>
        /// Handle the mouse click events.
        /// </summary>
        public virtual void Handle()
        {
            MouseButtons button = MouseButtons.None;

            if (MouseUtils.AnyButtonPressed(out button))
            {
                if (MouseDown != null)
                {
                    MouseDown(this, new MouseButtonEventArgs(button, MouseUtils.Position));
                }
                else
                {
                    OnMouseDown();
                }

                if (Click == null || !Click(this, new MouseButtonEventArgs(button, MouseUtils.Position)))
                {
                    Focus();

                    switch (button)
                    {
                    case MouseButtons.Left:
                        OnLeftClick();
                        break;

                    case MouseButtons.Middle:
                        OnMiddleClick();
                        break;

                    case MouseButtons.Right:
                        OnRightClick();
                        break;

                    case MouseButtons.XButton1:
                        OnXButton1Click();
                        break;

                    case MouseButtons.XButton2:
                        OnXButton2Click();
                        break;
                    }
                }
            }

            if (MouseUtils.AnyButtonReleased(out button))
            {
                if (MouseUp != null)
                {
                    MouseUp(this, new MouseButtonEventArgs(button, MouseUtils.Position));
                }
                else
                {
                    OnMouseUp();
                }
            }
        }