Ejemplo n.º 1
0
 private void joystickMouseMoveHandler(MouseEventArgs e, Point location, PictureBox box, Action <int, int> stickObserver)
 {
     if (MathLibrary.isPointInCircle(e.X, e.Y, joystickR, joystickR, joystickR))
     {
         location = e.Location;
         box.Invalidate();
         if (enabledStick)
         {
             stickObserver((int)Math.Floor((e.X - joystickR) / ((double)joystickR / 100)), (int)Math.Floor((e.Y - joystickR) / ((double)joystickR / 100)));
         }
     }
     else
     {
         Cursor.Position = box.PointToScreen(MathLibrary.convertPointToCircle(e.X, e.Y, joystickR, joystickR, joystickR - 2));
     }
 }
Ejemplo n.º 2
0
 private void panelForJoystick_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (MathLibrary.isPointInCircle(e.X, e.Y, joystickR, joystickR, joystickR))
         {
             Cursor.Hide();
             if (sender.Equals(panelForDirectMoveJoystick))
             {
                 joystickMouseDownHandler(e, stickDirectMoveLocation, panelForDirectMoveJoystick, stickDirectMoveObserver);
             }
             else
             {
                 joystickMouseDownHandler(e, stickMoveLocation, panelForMoveJoystick, stickMoveObserver);
             }
         }
     }
 }