/// <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="MouseEventArgs"/> instance containing the event data.</param> private static void Mouse_Down(object sender, MouseEventArgs args) { if ((args.Button != MouseButtons.Right) || (_mouse != null)) { return; } GI.GorgonRawMouse.CursorVisible = false; // Capture the cursor so that we can't move it outside the client area. Cursor.Clip = _window.RectangleToScreen(new Rectangle(_window.ClientSize.Width / 2, _window.ClientSize.Height / 2, 1, 1)); _mouse = new GI.GorgonRawMouse(); _input.RegisterDevice(_mouse); _mouse.MouseButtonUp += Mouse_Up; _mouse.MouseMove += RawMouse_MouseMove; }
/// <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="GI.GorgonMouseEventArgs"/> instance containing the event data.</param> private static void Mouse_Up(object sender, GI.GorgonMouseEventArgs args) { if (((args.Buttons & GI.MouseButtons.Right) != GI.MouseButtons.Right) || (_mouse == null)) { return; } try { _mouse.MouseButtonUp -= Mouse_Up; _mouse.MouseMove -= RawMouse_MouseMove; _input.UnregisterDevice(_mouse); _mouse = null; Cursor.Clip = Rectangle.Empty; GI.GorgonRawMouse.CursorVisible = true; } catch (Exception ex) { GorgonDialogs.ErrorBox(_window, ex); } }