private void BuildCorner(ref CropThumb crt, Cursor crs) { if (crt != null) { return; } crt = new CropThumb(_cpxThumbWidth); // Set some arbitrary visual characteristics. crt.Cursor = crs; _cnvThumbs.Children.Add(crt); }
private void BuildCorner(ref CropThumb thumb, Cursor cursor) { if (thumb != null) { return; } thumb = new CropThumb(_thumbWidth); // Set some arbitrary visual characteristics. thumb.Cursor = cursor; _thumbsCanvas.Children.Add(thumb); }
public CroppingAdorner(UIElement adornedElement, Rect rcInit) : base(adornedElement) { _vc = new VisualCollection(this); _prCropMask = new PuncturedRect(); _prCropMask.IsHitTestVisible = false; _prCropMask.RectInterior = rcInit; _prCropMask.Fill = Fill; _vc.Add(_prCropMask); _cnvThumbs = new Canvas(); _cnvThumbs.HorizontalAlignment = HorizontalAlignment.Stretch; _cnvThumbs.VerticalAlignment = VerticalAlignment.Stretch; _vc.Add(_cnvThumbs); BuildCorner(ref _crtTop, Cursors.SizeNS); BuildCorner(ref _crtBottom, Cursors.SizeNS); BuildCorner(ref _crtLeft, Cursors.SizeWE); BuildCorner(ref _crtRight, Cursors.SizeWE); BuildCorner(ref _crtTopLeft, Cursors.SizeNWSE); BuildCorner(ref _crtTopRight, Cursors.SizeNESW); BuildCorner(ref _crtBottomLeft, Cursors.SizeNESW); BuildCorner(ref _crtBottomRight, Cursors.SizeNWSE); // Add handlers for Cropping. _crtBottomLeft.DragDelta += new DragDeltaEventHandler(HandleBottomLeft); _crtBottomRight.DragDelta += new DragDeltaEventHandler(HandleBottomRight); _crtTopLeft.DragDelta += new DragDeltaEventHandler(HandleTopLeft); _crtTopRight.DragDelta += new DragDeltaEventHandler(HandleTopRight); _crtTop.DragDelta += new DragDeltaEventHandler(HandleTop); _crtBottom.DragDelta += new DragDeltaEventHandler(HandleBottom); _crtRight.DragDelta += new DragDeltaEventHandler(HandleRight); _crtLeft.DragDelta += new DragDeltaEventHandler(HandleLeft); // Aggiungo maniglia per spostamento _moveHandle = new CropThumb(15); _moveHandle.Cursor = Cursors.SizeAll; _cnvThumbs.Children.Add(_moveHandle); _moveHandle.ToolTip = "Sposta"; // _moveHandle.Background = Brushes.Orange; // TODO non funziona il colore. Perché ?? _moveHandle.Background = new SolidColorBrush(Colors.Orange); _moveHandle.DragDelta += new DragDeltaEventHandler(moveHandle_DragDelta); // Aggiungo una checkbox per gestire il rispetto delle proporzioni della carta. _checkBoxKeepAspect = new CheckBox(); Binding bind = new Binding(); // bind.Mode = BindingMode.TwoWay; bind.Source = this; bind.Path = new PropertyPath("MantainAspectRatio"); _checkBoxKeepAspect.DataContext = this; _checkBoxKeepAspect.SetBinding(CheckBox.IsCheckedProperty, bind); _checkBoxKeepAspect.IsChecked = true; // non so perché ma il binding non funziona alla prima battuta. Io imposto la property ma non si illumina la checkbox. Allora lo forzo io. _checkBoxKeepAspect.ToolTip = "Mantieni proporzioni"; _cnvThumbs.Children.Add(_checkBoxKeepAspect); // // Linee _lineVert = new Line(); _lineVert.StrokeThickness = 1; _lineVert.Stroke = System.Windows.Media.Brushes.Red; _lineVert.StrokeDashArray = new DoubleCollection() { 4, 5 }; _cnvThumbs.Children.Add(_lineVert); // _lineHoriz = new Line(); _lineHoriz.Stroke = _lineVert.Stroke; _lineHoriz.StrokeThickness = _lineVert.StrokeThickness; _lineHoriz.StrokeDashArray = _lineVert.StrokeDashArray; _cnvThumbs.Children.Add(_lineHoriz); // // We have to keep the clipping interior withing the bounds of the adorned element // so we have to track it's size to guarantee that... FrameworkElement fel = adornedElement as FrameworkElement; if (fel != null) { fel.SizeChanged += new SizeChangedEventHandler(AdornedElement_SizeChanged); } }
private void BuildCorner(ref CropThumb crt, Cursor crs) { if (crt != null) return; crt = new CropThumb(_cpxThumbWidth); // Set some arbitrary visual characteristics. crt.Cursor = crs; _cnvThumbs.Children.Add(crt); }
private void BuildCorner(ref CropThumb crt, Cursor cur) { if (crt != null) return; crt = new CropThumb(THUMB_SIZE); // Set some arbitrary visual characteristics. crt.Cursor = cur; _cnvThumbs.Children.Add(crt); }