예제 #1
0
 private void Cropping_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         SelectedAreaChanged?.Invoke(this, e);
     }
 }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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));
            }
        }
예제 #4
0
        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);
            }
        }