private void Cropping_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { SelectedAreaChanged?.Invoke(this, e); } }
private void AddCrop() { if (croppedElement != null) { RemoveCrop(); } if (AreaSelection) { Rect rcInterior = new Rect( uiImage.ActualWidth * 0.2, uiImage.ActualHeight * 0.2, uiImage.ActualWidth * 0.6, uiImage.ActualHeight * 0.6); AdornerLayer layer = AdornerLayer.GetAdornerLayer(uiImage); cropping = new CroppingAdorner(uiImage, rcInterior); cropping.Fill = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); layer.Add(cropping); croppedElement = uiImage; cropping.MouseMove += Cropping_MouseMove; SelectedAreaChanged?.Invoke(this, EventArgs.Empty); } }
private void UpdateSelectedAreaView() { if (ImageViewer != null && ImageViewer.ActiveItem != null && ImageViewer.ActiveItem.Element != null) { SelectAreaView view = ImageViewer.ActiveItem.Element as SelectAreaView; view.SelectAreaRectangle = GetSelectedAreaRectangle(false); view.ControlPoints = _controlPoints; SelectedAreaChanged?.Invoke(this, new SelectedAreaChangedEventArgs(view.SelectAreaRectangle)); } }
private void RemoveCrop() { if (croppedElement != null) { AdornerLayer layer = AdornerLayer.GetAdornerLayer(croppedElement); layer.Remove(cropping); croppedElement = null; cropping.MouseMove -= Cropping_MouseMove; SelectedAreaChanged?.Invoke(this, EventArgs.Empty); } }