/// <summary> /// Handles the MouseMove event of the renderControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> private void renderControl_MouseMove(object sender, [NotNull] MouseEventArgs e) { Controller controller = ActiveController; if (controller == null) { return; } lock (_lock) { controller = ActiveController; if (controller == null) { return; } controller.CurrentTool?.UpdateLocation(new Vector2(e.X, e.Y)); DragAction dragAction = _dragAction; if (dragAction != null) { dragAction.Update(new Vector2(e.X, e.Y)); if (dragAction.ChangesData) { IsDirty = true; } } } }
/// <summary> /// Handles the MouseDown event of the renderControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> private void renderControl_MouseDown(object sender, [NotNull] MouseEventArgs e) { Controller controller = ActiveController; if (controller == null) { return; } if (e.Button != MouseButtons.Left) { return; } Vector2 loc = new Vector2(e.X, e.Y); lock (_lock) { controller = ActiveController; if (controller == null) { return; } Action action = controller.CurrentTool?.StartAction(loc); _dragAction = action as DragAction; if (action != null && action.ChangesData) { IsDirty = true; } } }
/// <summary> /// Handles the MouseLeave event of the renderControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void renderControl_MouseLeave(object sender, EventArgs e) { lock (_lock) { DragAction dragAction = Interlocked.Exchange(ref _dragAction, null); if (dragAction != null) { dragAction.Apply(); if (dragAction.ChangesData) { IsDirty = true; } } } }
/// <summary> /// Handles the MouseDown event of the renderControl control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> private void renderControl_MouseDown(object sender, [NotNull] MouseEventArgs e) { Controller controller = ActiveController; if (controller == null) return; if (e.Button != MouseButtons.Left) return; Vector2 loc = new Vector2(e.X, e.Y); lock (_lock) { controller = ActiveController; if (controller == null) return; Action action = controller.CurrentTool?.StartAction(loc); _dragAction = action as DragAction; if (action != null && action.ChangesData) IsDirty = true; } }