private void DropPatch(Point location) { if (GetColorPatchAt(location) == null) { _grabbedPatch.GridLocation = new PointI((int)(location.X / _patchSize), (int)(location.Y / _patchSize)); RaiseColorsModifiedEvent(); } _grabbedPatch = null; InvalidateVisual(); }
private void CancelDrag() { if (_grabbedPatch == null) { return; } _isDragging = false; _grabbedPatch = null; InvalidateVisual(); }
protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); if (e.ChangedButton != MouseButton.Left) { return; } _dragLocation = e.GetPosition(this); _mouseDownLocation = _dragLocation; var patch = GetColorPatchAt(_dragLocation); if (patch != null) { _isDragging = false; // we are not yet dragging until mouse has moved a small distance with the grabbed patch _grabbedPatch = patch; InvalidateVisual(); } }
public ColorPatchRoutedEventArgs(RoutedEvent routedEvent, ColorPatch colorPatch) : base(routedEvent) { ColorPatch = colorPatch; }