/// <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="GorgonMouseEventArgs" /> instance containing the event data.</param> private void MouseInput(object sender, GorgonMouseEventArgs e) { if (_joystick != null) { return; } Color drawColor = Color.Black; // Drawing color. Point position = _useWinFormsInput ? e.Position : PointToClient(e.Position); if (e.Buttons == GorgonMouseButtons.None) { return; } // Draw to the back buffer. _graphics.SetRenderTarget(_backBuffer); _2D.Begin(_currentBlend); if ((e.Buttons & GorgonMouseButtons.Left) == GorgonMouseButtons.Left) { drawColor = Color.FromArgb(64, 0, 0, 192); } if ((e.Buttons & GorgonMouseButtons.Right) == GorgonMouseButtons.Right) { drawColor = Color.FromArgb(64, 192, 0, 0); } // Draw the pen. var penPosition = new DX.RectangleF(position.X - (_radius / 2.0f), position.Y - (_radius / 2.0f), _radius, _radius); if (_radius > 3.0f) { _2D.DrawFilledEllipse(penPosition, drawColor); } else { _2D.DrawFilledRectangle(penPosition, drawColor); } _2D.End(); _graphics.SetRenderTarget(_screen.RenderTargetView); }
/// <summary> /// Handles the PointingDeviceDown event of the _mouse control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="GorgonMouseEventArgs" /> instance containing the event data.</param> /// <exception cref="NotSupportedException"></exception> private void _mouse_ButtonDown(object sender, GorgonMouseEventArgs e) => UpdateMouse(e.RelativePosition, e.Buttons | e.ShiftButtons);
/// <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="GorgonMouseEventArgs" /> instance containing the event data.</param> /// <exception cref="NotSupportedException"></exception> private void _mouse_Move(object sender, GorgonMouseEventArgs e) => // Lock the cursor in place as well so that we can, again, fake an "exclusive" mode. UpdateMouse(e.RelativePosition, e.Buttons | e.ShiftButtons);
/// <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="GorgonMouseEventArgs" /> instance containing the event data.</param> /// <exception cref="NotSupportedException"></exception> private void _mouse_ButtonUp(object sender, GorgonMouseEventArgs e) => // Update the buttons so that only the buttons we have held down are showing. UpdateMouse(e.RelativePosition, e.ShiftButtons & ~e.Buttons);