Ejemplo n.º 1
0
        protected internal override void OnMouseUp(Input.Mouse.MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (pressedctl != null)
            {
                Control2D c2d = (pressedctl as Control2D);
                if (c2d == null)
                {
                    return;
                }

                MouseEventArgs args = new MouseEventArgs(e.Buttons, (int)(e.X - c2d.Position.X), (int)(e.Y - c2d.Position.Y));
                pressedctl.OnMouseUp(args);
                pressedctl = null;
                return;
            }

            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.OnMouseUp(args);
                return;
            }

            if (e.Buttons == Input.Mouse.MouseButton.Primary)
            {
                mvarMoving = false;
            }
        }
Ejemplo n.º 2
0
 protected internal override void OnMouseMove(Input.Mouse.MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (mvarMoving)
     {
         base.Position = new PositionVector2((e.X - dx), (e.Y - dy));
         base.Parent.Refresh();
     }
     else
     {
         Control2D ctl = HitTest(e.X, e.Y);
         if (ctl != null)
         {
             MouseEventArgs args = new MouseEventArgs(e.Buttons, (int)(e.X - ctl.Position.X + mvarOffsetX), (int)(e.Y - ctl.Position.Y + mvarOffsetY));
             // args = new MouseEventArgs(e.Buttons, (int)(e.X), (int)(e.Y));
             ctl.OnMouseMove(args);
         }
     }
 }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
0
        protected internal override void OnMouseUp(Input.Mouse.MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (pressedctl != null)
            {
                Control2D c2d = (pressedctl as Control2D);
                if (c2d == null) return;

                MouseEventArgs args = new MouseEventArgs(e.Buttons, (int)(e.X - c2d.Position.X), (int)(e.Y - c2d.Position.Y));
                pressedctl.OnMouseUp(args);
                pressedctl = null;
                return;
            }

            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.OnMouseUp(args);
                return;
            }

            if (e.Buttons == Input.Mouse.MouseButton.Primary)
            {
                mvarMoving = false;
            }
        }
Ejemplo n.º 5
0
 protected internal override void OnMouseMove(Input.Mouse.MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (mvarMoving)
     {
         base.Position = new PositionVector2((e.X - dx), (e.Y - dy));
         base.Parent.Refresh();
     }
     else
     {
         Control2D ctl = HitTest(e.X, e.Y);
         if (ctl != null)
         {
             MouseEventArgs args = new MouseEventArgs(e.Buttons, (int)(e.X - ctl.Position.X + mvarOffsetX), (int)(e.Y - ctl.Position.Y + mvarOffsetY));
             // args = new MouseEventArgs(e.Buttons, (int)(e.X), (int)(e.Y));
             ctl.OnMouseMove(args);
         }
     }
 }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
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;
                }
            }
        }
Ejemplo n.º 8
0
 private static void _OnMotion(int x, int y)
 {
     Window w = null;
     if (mvarLastFullscreenWindow != null)
     {
         w = mvarLastFullscreenWindow;
     }
     else
     {
         int handle = Internal.FreeGLUT.Methods.glutGetWindow();
         w = handleWindows[handle];
     }
     MouseEventArgs args = new MouseEventArgs(MouseButton.None, x, y);
     if (w._motionCtl != null)
     {
         w._motionCtl.OnMouseMove(args);
     }
     else
     {
         Control2D ctl = w.HitTest(x, y);
         if (ctl != null)
         {
             args = new MouseEventArgs(MouseButton.None, (int)(x - ctl.Position.X), (int)(y - ctl.Position.Y));
             ctl.OnMouseMove(args);
         }
         else
         {
             w.OnMouseMove(args);
         }
     }
 }
Ejemplo n.º 9
0
 protected virtual void OnMouseWheel(MouseEventArgs e)
 {
     if (MouseWheel != null) MouseWheel(this, e);
 }
Ejemplo n.º 10
0
 protected virtual void OnMouseUp(MouseEventArgs e)
 {
     if (MouseUp != null) MouseUp(this, e);
 }
Ejemplo n.º 11
0
 protected virtual void OnMouseMove(MouseEventArgs e)
 {
     if (MouseMove != null) MouseMove(this, e);
 }
Ejemplo n.º 12
0
 protected virtual void OnMouseDown(MouseEventArgs e)
 {
     if (MouseDown != null) MouseDown(this, e);
 }