protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { if (!IsPickingRegion) { return; } Region = new Rect(e.GetPosition(this), new Size(0, 0)); _cropAdorner = new CroppingAdorner(_mainCanvas, Region) { Fill = new SolidColorBrush(Color.FromArgb(30, 255, 255, 255)) }; _adornerLayer.Add(_cropAdorner); CaptureMouse(); e.Handled = true; base.OnMouseLeftButtonDown(e); }
private void RemoveCropElements() { AdornerLayer aly = AdornerLayer.GetAdornerLayer(_currentElement); aly.Remove(_cropAdorner); _currentElement = null; _cropAdorner.CropChanged -= CropChanged; _cropAdorner = null; }
private void AddCropToElement(FrameworkElement fel) { if (_currentElement != null) { RemoveCropElements(); } var rcInterior = new Rect( fel.Width * 0.2, fel.Height * 0.2, fel.Width * 0.6, fel.Height * 0.6); var aly = AdornerLayer.GetAdornerLayer(fel); _cropAdorner = new CroppingAdorner(fel, rcInterior); aly.Add(_cropAdorner); _cropAdorner.CropChanged += CropChanged; _currentElement = fel; _cropAdorner.Fill = new SolidColorBrush(Color.FromArgb(110,0,0,0)); RefreshCropImage(); }