예제 #1
0
        private void dragX_Changed(DragListener drag)
        {
            Point  currentPoint = Mouse.GetPosition(this.parent);
            Vector deltaVector  = Point.Subtract(currentPoint, this.startPoint);

            var destAngle = (-0.5 * deltaVector.X) + skewX;

            if (destAngle == 0 && skewY == 0)
            {
                this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
                rtTransform   = null;
                skewTransform = null;
            }
            else
            {
                if ((rtTransform == null) || !(rtTransform.Component is SkewTransform))
                {
                    if (!this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet)
                    {
                        this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
                    }

                    if (this.skewTransform == null)
                    {
                        this.skewTransform = new SkewTransform(0, 0);
                    }
                    this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(skewTransform);
                    rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value;
                }
                rtTransform.Properties["AngleX"].SetValue(destAngle);
            }

            _adornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
        }
예제 #2
0
        private void drag_Rotate_Changed(DragListener drag)
        {
            Point  currentPoint = Mouse.GetPosition(this.parent);
            Vector deltaVector  = Point.Subtract(currentPoint, this.centerPoint);

            double angle = Vector.AngleBetween(this.startVector, deltaVector);

            var destAngle = this.initialAngle + Math.Round(angle, 0);

            if (!Keyboard.IsKeyDown(Key.LeftCtrl))
            {
                destAngle = ((int)destAngle / 15) * 15;
            }

            if (destAngle == 0)
            {
                this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).Reset();
                rtTransform     = null;
                rotateTransform = null;
            }
            else
            {
                if ((rtTransform == null) || !(rtTransform.Component is RotateTransform))
                {
                    if (!this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).IsSet)
                    {
                        this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformOriginProperty).SetValue(new Point(0.5, 0.5));
                    }

                    if (this.rotateTransform == null)
                    {
                        this.rotateTransform = new RotateTransform(0);
                    }
                    this.ExtendedItem.Properties.GetProperty(FrameworkElement.RenderTransformProperty).SetValue(rotateTransform);
                    rtTransform = this.ExtendedItem.Properties[FrameworkElement.RenderTransformProperty].Value;
                }
                rtTransform.Properties["Angle"].SetValue(destAngle);

                _adornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
            }
        }