예제 #1
0
        protected internal override void OnMouseDown(Input.Mouse.MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Control2D ctl = HitTest(e.X, e.Y);

            if (ctl != null)
            {
                MouseEventArgs args = new MouseEventArgs(e.Buttons, (int)(e.X - ctl.Position.X), (int)(e.Y - ctl.Position.Y));
                ctl.OnMouseDown(args);
                pressedctl = ctl;
                return;
            }

            if (e.Buttons == Input.Mouse.MouseButton.Primary && e.Y <= 20)
            {
                mvarMoving = true;
                cx         = base.Position.X;
                cy         = base.Position.Y;
                dx         = e.X;
                dy         = e.Y;
            }
        }
예제 #2
0
        private static void _OnMouse(int button, int state, int x, int y)
        {
            Window w = null;

            if (mvarLastFullscreenWindow != null)
            {
                w = mvarLastFullscreenWindow;
            }
            else
            {
                int handle = Internal.FreeGLUT.Methods.glutGetWindow();
                w = handleWindows[handle];
            }

            MouseButton buttons = MouseButton.None;

            switch (button)
            {
            case 0:
            {
                buttons = MouseButton.Primary;
                break;
            }

            case 1:
            {
                buttons = MouseButton.Wheel;
                break;
            }

            case 2:
            {
                buttons = MouseButton.Secondary;
                break;
            }

            case 3:
            {
                // Wheel up
                if (state == 0)
                {
                    state = 2;
                }
                else if (state == 1)
                {
                    return;
                }
                break;
            }

            case 4:
            {
                //  Wheel down
                if (state == 0)
                {
                    state = 2;
                }
                else if (state == 1)
                {
                    return;
                }
                break;
            }

            case 7:
            {
                buttons = MouseButton.XButton1;
                break;
            }

            case 8:
            {
                buttons = MouseButton.XButton2;
                break;
            }
            }
            MouseEventArgs args = new MouseEventArgs(buttons, x, y);

            /*
             * if (w.FullScreen)
             * {
             *  y += 25;
             *  x -= 5;
             * }
             */
            switch (state)
            {
            case 0:
            {
                Control2D c2d = w.HitTest(x, y);
                if (c2d != null)
                {
                    args         = new MouseEventArgs(buttons, (int)(x - c2d.Position.X), (int)(y - c2d.Position.Y));
                    w._motionCtl = c2d;

                    if (mvarFocusedControl != c2d)
                    {
                        if (mvarFocusedControl != null)
                        {
                            mvarFocusedControl.HasFocus = false;
                            mvarFocusedControl.OnLostFocus(EventArgs.Empty);
                        }
                        mvarFocusedControl = c2d;
                        c2d.HasFocus       = true;
                        c2d.OnGotFocus(EventArgs.Empty);
                    }

                    c2d.OnMouseDown(args);
                    return;
                }
                else if (mvarFocusedControl != null)
                {
                    mvarFocusedControl.HasFocus = false;
                    mvarFocusedControl.OnLostFocus(EventArgs.Empty);
                    mvarFocusedControl = null;
                }
                w.OnMouseDown(args);
                break;
            }

            case 1:
            {
                Control2D c2d = (w._motionCtl as Control2D);
                if (c2d != null)
                {
                    args = new MouseEventArgs(buttons, (int)(x - c2d.Position.X), (int)(y - c2d.Position.Y));
                    w._motionCtl.OnMouseUp(args);
                    w._motionCtl = null;
                    return;
                }
                w.OnMouseUp(args);
                break;
            }

            case 2:
            {
                Control2D c2d = w.HitTest(x, y);
                if (c2d != null)
                {
                    args = new MouseEventArgs(buttons, (int)(x - 4 - c2d.Position.X), (int)(y + 12 - c2d.Position.Y));
                    c2d.OnMouseWheel(args);
                    return;
                }
                w.OnMouseWheel(args);
                break;
            }
            }
        }