Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Up event of the Mouse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="PointingDeviceEventArgs"/> instance containing the event data.</param>
        private static void Mouse_Up(object sender, PointingDeviceEventArgs args)
        {
            if (((args.Buttons & PointingDeviceButtons.Right) != PointingDeviceButtons.Right) &&
                (_mouse.Exclusive))
            {
                return;
            }

            _mouse.Exclusive = false;
            _mouse.ShowCursor();
        }
Ejemplo n.º 2
0
        //private PointingDeviceEventArgs _eventData;
        //private PointF _mousePosition;
        //private int _wheelDelta;

        //public PointingDeviceEventArgs EventData { get { return _eventData; } }
        //public Point Position { get { return Position }
        //public Point RelativePosition { get { return new Point((int)base.RelativePosition.X, (int)base.RelativePosition.Y); } }

        public MouseEventArgs(PointingDeviceEventArgs args)
        {
            ClickCount       = args.ClickCount;
            DoubleClick      = args.DoubleClick;
            Position         = Point2D.FromPointF(args.Position);
            RelativePosition = Point2D.FromPointF(args.RelativePosition);

            ShiftButtons  = args.ShiftButtons;
            WheelDelta    = args.WheelDelta;
            WheelPosition = args.WheelPosition;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the Down event of the Mouse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="PointingDeviceEventArgs"/> instance containing the event data.</param>
        private static void Mouse_Down(object sender, PointingDeviceEventArgs args)
        {
            if (((args.Buttons & PointingDeviceButtons.Right) != PointingDeviceButtons.Right) &&
                (!_mouse.Exclusive))
            {
                return;
            }

            _mouseStart      = args.Position;
            _mouse.Exclusive = true;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the PointingDeviceWheelMove event of the _mouse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="PointingDeviceEventArgs" /> instance containing the event data.</param>
        private void _mouse_PointingDeviceWheelMove(object sender, PointingDeviceEventArgs e)
        {
            if (e.WheelDelta > 0)
            {
                _radius += 1.0f;
            }
            if (e.WheelDelta < 0)
            {
                _radius -= 1.0f;
            }

            if (_radius < 2.0f)
            {
                _radius = 2.0f;
            }
            if (_radius > 10.0f)
            {
                _radius = 10.0f;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Function to convert raw input pointing device args to win forms event args.
        /// </summary>
        /// <param name="args">Raw input device args.</param>
        /// <returns>Winforms event args.</returns>
        private static MouseEventArgs Convert(PointingDeviceEventArgs args)
        {
            var buttons = MouseButtons.None;

            if (args.Buttons.HasFlag(PointingDeviceButtons.Button1))
            {
                buttons |= MouseButtons.Left;
            }

            if (args.Buttons.HasFlag(PointingDeviceButtons.Button2))
            {
                buttons |= MouseButtons.Right;
            }

            if (args.Buttons.HasFlag(PointingDeviceButtons.Button3))
            {
                buttons |= MouseButtons.Middle;
            }

            return(new MouseEventArgs(buttons, args.ClickCount, (int)args.Position.X, (int)args.Position.Y, args.WheelDelta));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the button and movement events of the _mouse control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="PointingDeviceEventArgs" /> instance containing the event data.</param>
        private void MouseInput(object sender, PointingDeviceEventArgs e)
        {
            Color drawColor = Color.Black;                      // Drawing color.

            if (e.Buttons == PointingDeviceButtons.None)
            {
                return;
            }

            // Draw to the back buffer.
            _2D.Target = _backBuffer;
            _2D.Drawing.Blending.DestinationAlphaBlend = BlendType.One;
            _2D.Drawing.BlendingMode = _blendMode;

            if ((e.Buttons & PointingDeviceButtons.Left) == PointingDeviceButtons.Left)
            {
                drawColor = Color.FromArgb(64, 0, 0, 192);
            }

            if ((e.Buttons & PointingDeviceButtons.Right) == PointingDeviceButtons.Right)
            {
                drawColor = Color.FromArgb(64, 192, 0, 0);
            }

            // Draw the pen.
            var penPositon = new RectangleF(e.Position.X - (_radius / 2.0f), e.Position.Y - (_radius / 2.0f), _radius, _radius);

            if (_radius > 3.0f)
            {
                _2D.Drawing.FilledEllipse(penPositon, drawColor);
            }
            else
            {
                _2D.Drawing.FilledRectangle(penPositon, drawColor);
            }

            _2D.Drawing.Blending.DestinationAlphaBlend = BlendType.Zero;
            _2D.Target = null;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Function to call in the mouse move event of the control being rendered into.
 /// </summary>
 /// <param name="e">Event parameters.</param>
 /// <returns>TRUE if handled, FALSE if not.</returns>
 public bool OnMouseMove(PointingDeviceEventArgs e)
 {
     return(OnMouseMove(Convert(e)));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Handles the PointingDeviceMove event of the _mouse control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="PointingDeviceEventArgs" /> instance containing the event data.</param>
 /// <exception cref="System.NotSupportedException"></exception>
 private void _mouse_PointingDeviceMove(object sender, PointingDeviceEventArgs e)
 {
     UpdateMouseLabel(e.Position, e.Buttons | e.ShiftButtons);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Handles the PointingDeviceUp event of the _mouse control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="PointingDeviceEventArgs" /> instance containing the event data.</param>
 /// <exception cref="System.NotSupportedException"></exception>
 private void _mouse_PointingDeviceUp(object sender, PointingDeviceEventArgs e)
 {
     // Update the buttons so that only the buttons we have held down are showing.
     UpdateMouseLabel(e.Position, e.ShiftButtons & ~e.Buttons);
 }