상속: System.Windows.Documents.Adorner
예제 #1
0
        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);
        }
예제 #2
0
        private void RemoveCropElements()
        {
            AdornerLayer aly = AdornerLayer.GetAdornerLayer(_currentElement);
            aly.Remove(_cropAdorner);

            _currentElement = null;
            _cropAdorner.CropChanged -= CropChanged;
            _cropAdorner = null;
        }
예제 #3
0
        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();
        }