Ejemplo n.º 1
0
        private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            designerItem = DataContext as ContentControl;

            if (designerItem != null)
            {
                canvas = designerItem.FindParentControl<Canvas>();

                if (canvas != null)
                {
                    this.transformOrigin = this.designerItem.RenderTransformOrigin;

                    rotateTransform = this.designerItem.RenderTransform as RotateTransform;
                    if (rotateTransform != null)
                    {
                        angle = this.rotateTransform.Angle * Math.PI / 180.0;
                    }
                    else
                    {
                        angle = 0.0d;
                    }

                    AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas);
                    if (adornerLayer != null)
                    {
                        adorner = new SizeAdorner(this.designerItem);
                        adornerLayer.Add(this.adorner);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void RotateThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            _designerItem = DataContext as ContentControl;

            if (_designerItem != null)
            {
                _canvas = _designerItem.FindParentControl<Canvas>();

                var annoyingRectangle = _designerItem.DataContext as AnnoyingRectangle;
                if (_canvas != null)
                {
                    _centerPoint = _designerItem.TranslatePoint(
                        new Point((double)annoyingRectangle.Width * _designerItem.RenderTransformOrigin.X,
                                  (double)annoyingRectangle.Height * _designerItem.RenderTransformOrigin.Y),
                                  _canvas);

                    Point startPoint = Mouse.GetPosition(_canvas);
                    _startVector = Point.Subtract(startPoint, _centerPoint);

                    _offset = annoyingRectangle.Angle;

                    AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this._canvas);
                    if (adornerLayer != null)
                    {
                        adorner = new RotateAdorner(this._designerItem);
                        adornerLayer.Add(this.adorner);
                    }
                }
            }
        }