Esempio n. 1
0
        // Arrange the Adorners.
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            var bbb = CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules);

            if (LastOperation != null)
            {
                bbb = LastOperation.TransformBounds(bbb);
            }

            //put a box right around the entire shebang
            BigThumb.Arrange(bbb);
            Canvas.SetLeft(BigThumb, bbb.Left);
            Canvas.SetTop(BigThumb, bbb.Top);
            BigThumb.Height = bbb.Height;
            BigThumb.Width  = bbb.Width;

            // Return the final size.
            return(finalSize);
        }
Esempio n. 2
0
        // Arrange the Adorners.
        protected override Size ArrangeOverride(Size finalSize)
        {
            // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
            // These will be used to place the ResizingAdorner at the corners of the adorned element.
            var bbb = CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules);

            if (LastOperation != null)
            {
                bbb = LastOperation.TransformBounds(bbb);
            }

            TopLeftHandle.Arrange(new Rect(bbb.Left - _halfThumbWidth, bbb.Top - _halfThumbWidth, _thumbWidth.Value,
                                           _thumbWidth.Value));
            TopRightHandle.Arrange(new Rect(bbb.Left + bbb.Width - _halfThumbWidth, bbb.Top - _halfThumbWidth,
                                            _thumbWidth.Value,
                                            _thumbWidth.Value));
            BottomLeftHandle.Arrange(new Rect(bbb.Left - _halfThumbWidth, bbb.Top + bbb.Height - _halfThumbWidth,
                                              _thumbWidth.Value, _thumbWidth.Value));
            BottomRightHandle.Arrange(new Rect(bbb.Left + bbb.Width - _halfThumbWidth,
                                               bbb.Height + bbb.Top - _halfThumbWidth, _thumbWidth.Value,
                                               _thumbWidth.Value));

            //add the rotator
            _xPlacement     = (bbb.Left + bbb.Right) / 2;
            _yPlacement     = bbb.Top - RotateHandle.Height * 3;
            _rotateThumbPos = new Point(_xPlacement, _yPlacement);

            if (BigThumb.IsDragging ||
                TopLeftHandle.IsDragging ||
                TopRightHandle.IsDragging ||
                BottomLeftHandle.IsDragging ||
                BottomRightHandle.IsDragging)
            {
                RotateHandle.Visibility = Visibility.Hidden;
            }
            else
            {
                RotateHandle.Visibility = Visibility.Visible;
                SetCentroid();
            }

            if (Rotating && LastOperation != null)
            {
                _rotateThumbPos = LastOperation.Transform(_rotateThumbPos);
            }

            Vector rotateThumbTweak = new Vector(-RotateHandle.Width / 2, -RotateHandle.Height / 2);
            Point  newLoc           = _rotateThumbPos + rotateThumbTweak;

            if (Rotating && LastOperation != null)
            {
                TopLeftHandle.Visibility     = Visibility.Collapsed;
                TopRightHandle.Visibility    = Visibility.Collapsed;
                BottomLeftHandle.Visibility  = Visibility.Collapsed;
                BottomRightHandle.Visibility = Visibility.Collapsed;
                BigThumb.Visibility          = Visibility.Collapsed;
            }
            else
            {
                TopLeftHandle.Visibility     = Visibility.Visible;
                TopRightHandle.Visibility    = Visibility.Visible;
                BottomLeftHandle.Visibility  = Visibility.Visible;
                BottomRightHandle.Visibility = Visibility.Visible;
                BigThumb.Visibility          = Visibility.Visible;
            }

            RotateHandle.Arrange(new Rect(newLoc.X, newLoc.Y, RotateHandle.Width, RotateHandle.Height));

            base.ArrangeOverride(finalSize);
            return(finalSize);
        }
Esempio n. 3
0
 private void SetCentroid()
 {
     _centroid      = GetCentroid(CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules));
     _rotateSnapper = new Snapper(_centroid, CurrentEditor.Chemistry as EditViewModel);
 }
Esempio n. 4
0
 private void SetBoundingBox()
 {
     BoundingBox = CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules);
     //and work out the aspect ratio for later resizing
     AspectRatio = BoundingBox.Width / BoundingBox.Height;
 }
Esempio n. 5
0
 private void SetCentroid()
 {
     _centroid      = BasicGeometry.GetCentroid(CurrentEditor.GetMoleculeBoundingBox(AdornedMolecules));
     _rotateSnapper = new Snapper(_centroid, CurrentEditor.ViewModel as EditViewModel);
 }