protected override void ApplyScale(Vector scale, Point center)
        {
            Rect   elementBounds = this.EditingElementSet.ElementBounds;
            Matrix m             = this.startSharedTransform;
            Matrix inverseMatrix = ElementUtilities.GetInverseMatrix(m);
            Matrix matrix1       = new Matrix();

            matrix1.Translate(-center.X, -center.Y);
            foreach (SceneElement element in this.EditingElementSet.Elements)
            {
                Matrix matrix2 = this.elementToElementsTransformDictionary[element] * matrix1;
                Point  point1  = this.startCentersDictionary[element];
                Matrix matrix3 = this.startTransformsDictionary[element];
                Rect   rect    = this.startBoundsDictionary[element];
                Point  point2  = new Point(rect.X + rect.Width * point1.X, rect.Y + rect.Height * point1.Y);
                Point  point3  = matrix2.Transform(point2);
                Vector vector  = new Point(scale.X * point3.X, scale.Y * point3.Y) - point3;
                Matrix matrix4 = matrix3 * inverseMatrix;
                matrix4.ScaleAt(scale.X, scale.Y, matrix4.OffsetX, matrix4.OffsetY);
                matrix4.Translate(vector.X, vector.Y);
                CanonicalDecomposition newTransform = new CanonicalDecomposition(matrix4 * m);
                newTransform.ScaleX        = RoundingHelper.RoundScale(newTransform.ScaleX);
                newTransform.ScaleY        = RoundingHelper.RoundScale(newTransform.ScaleY);
                newTransform.SkewX         = RoundingHelper.RoundAngle(newTransform.SkewX);
                newTransform.SkewY         = RoundingHelper.RoundAngle(newTransform.SkewY);
                newTransform.RotationAngle = RoundingHelper.RoundAngle(newTransform.RotationAngle);
                newTransform.TranslationX  = RoundingHelper.RoundLength(newTransform.TranslationX);
                newTransform.TranslationY  = RoundingHelper.RoundLength(newTransform.TranslationY);
                AdornedToolBehavior.UpdateElementTransform(element, newTransform, AdornedToolBehavior.TransformPropertyFlags.All);
            }
        }
Exemple #2
0
        protected virtual void ApplyScale(Vector scale, Point center)
        {
            CanonicalTransform newTransform = new CanonicalTransform(this.startTransform);

            newTransform.ApplyScale(scale, this.BaseEditingElement.RenderTransformOriginInElementCoordinates, center);
            newTransform.ScaleX       = RoundingHelper.RoundScale(newTransform.ScaleX);
            newTransform.ScaleY       = RoundingHelper.RoundScale(newTransform.ScaleY);
            newTransform.TranslationX = RoundingHelper.RoundLength(newTransform.TranslationX);
            newTransform.TranslationY = RoundingHelper.RoundLength(newTransform.TranslationY);
            AdornedToolBehavior.UpdateElementTransform(this.EditingElement, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale | AdornedToolBehavior.TransformPropertyFlags.Translation);
        }
        protected override void ApplyScale(Vector scale, Point center)
        {
            Dictionary <SceneElement, Size> dictionary = this.CalculateClampedSizes(ref scale);
            Vector          vector1 = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0);
            Matrix          startSharedTransform = this.StartSharedTransform;
            Matrix          inverseMatrix        = ElementUtilities.GetInverseMatrix(startSharedTransform);
            ILayoutDesigner designerForChild     = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElementSet.PrimaryElement, true);

            foreach (SceneElement index in this.EditingElementSet.Elements)
            {
                double width  = dictionary[index].Width;
                double height = dictionary[index].Height;
                Rect   rect1  = this.StartBoundsDictionary[index];
                Point  renderTransformOrigin = ((Base2DElement)index).RenderTransformOrigin;
                Point  point1  = new Point(rect1.X + rect1.Width * renderTransformOrigin.X, rect1.Y + rect1.Height * renderTransformOrigin.Y);
                Matrix matrix1 = this.ElementToElementsTransformDictionary[index];
                Matrix matrix2 = new Matrix();
                matrix2.Translate(-center.X, -center.Y);
                matrix1 *= matrix2;
                Point  point2  = matrix1.Transform(point1);
                Vector vector2 = new Point(point2.X * scale.X, point2.Y * scale.Y) - point2;
                Vector vector3 = new Vector((width - rect1.Width) * renderTransformOrigin.X, (height - rect1.Height) * renderTransformOrigin.Y);
                Vector vector4 = vector2 * startSharedTransform - vector3;
                Matrix matrix3 = this.StartTransformsDictionary[index];
                Matrix m       = new Matrix();
                m.Scale(scale.X, scale.Y);
                Matrix matrix4 = ElementUtilities.GetInverseMatrix(m) * matrix3 * inverseMatrix;
                Vector vector5 = new Vector(matrix3.OffsetX, matrix3.OffsetY) * inverseMatrix;
                matrix4.ScaleAt(scale.X, scale.Y, vector5.X, vector5.Y);
                CanonicalDecomposition newTransform = new CanonicalDecomposition(matrix4 * startSharedTransform);
                newTransform.ScaleX      *= vector1.X;
                newTransform.ScaleY      *= vector1.Y;
                newTransform.Translation += vector4;
                AdornedToolBehavior.UpdateElementTransform(index, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale | AdornedToolBehavior.TransformPropertyFlags.Skew | AdornedToolBehavior.TransformPropertyFlags.RotatationAngle);
                Rect rect2 = this.initialRects[index];
                rect2.Offset(newTransform.TranslationX - this.initialTransforms[index].TranslationX, newTransform.TranslationY - this.initialTransforms[index].TranslationY);
                rect2.Width  = width;
                rect2.Height = height;
                BaseFrameworkElement child             = (BaseFrameworkElement)index;
                LayoutOverrides      overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)width, (object)rect1.Width) ? 16 : 0) | (!object.Equals((object)height, (object)rect1.Height) ? 32 : 0));
                designerForChild.SetChildRect(child, rect2, this.initialOverrides[index], overridesToIgnore, LayoutOverrides.None);
                if (!object.Equals((object)width, (object)rect1.Width) || !object.Equals((object)height, (object)rect1.Height))
                {
                    PathElement.EnsureStretchIsFill((SceneNode)index);
                }
                PathElement.PathTransformHelper pathTransformHelper;
                if (this.pathTransformHelpers.TryGetValue(index, out pathTransformHelper))
                {
                    pathTransformHelper.Update(scale.X * vector1.X, scale.Y * vector1.Y);
                }
            }
        }
Exemple #4
0
        protected override void ApplyScale(Vector scale, Point center)
        {
            Vector             scale1             = new Vector(Math.Abs(scale.X), Math.Abs(scale.Y));
            Vector             scale2             = new Vector(scale.X < 0.0 ? -1.0 : 1.0, scale.Y < 0.0 ? -1.0 : 1.0);
            Vector             vector1            = new Vector(this.StartCenter.X, this.StartCenter.Y);
            Size               newSize            = this.ComputeNewSize(scale1);
            Point              topLeft            = this.StartBounds.TopLeft;
            CanonicalTransform canonicalTransform = new CanonicalTransform(this.StartTransform);

            canonicalTransform.ApplyScale(scale, this.StartCenter, center);
            Point point1 = (topLeft - vector1) * canonicalTransform.TransformGroup.Value + vector1;
            Point renderTransformOrigin = this.BaseEditingElement.RenderTransformOrigin;

            renderTransformOrigin.X *= newSize.Width;
            renderTransformOrigin.Y *= newSize.Height;
            CanonicalTransform newTransform = new CanonicalTransform(this.StartTransform);

            newTransform.ApplyScale(scale2, renderTransformOrigin, center);
            Vector vector2 = (Vector)renderTransformOrigin;
            Point  point2  = (topLeft - vector2) * newTransform.TransformGroup.Value + vector2;

            newTransform.Translation += point1 - point2;
            AdornedToolBehavior.UpdateElementTransform(this.EditingElement, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale);
            ILayoutDesigner designerForChild = this.ActiveSceneViewModel.GetLayoutDesignerForChild(this.EditingElement, true);
            Rect            rect             = this.initialRect;

            rect.Offset(newTransform.TranslationX - this.StartTransform.TranslationX, newTransform.TranslationY - this.StartTransform.TranslationY);
            rect.Width  = newSize.Width;
            rect.Height = newSize.Height;
            LayoutOverrides overridesToIgnore = (LayoutOverrides)(0 | (!object.Equals((object)rect.Width, (object)this.StartSize.Width) ? 16 : 0) | (!object.Equals((object)rect.Height, (object)this.StartSize.Height) ? 32 : 0));

            designerForChild.SetChildRect(this.BaseEditingElement, rect, this.initialOverrides, overridesToIgnore, LayoutOverrides.None);
            if (!object.Equals((object)rect.Width, (object)this.StartSize.Width) || !object.Equals((object)rect.Height, (object)this.StartSize.Height))
            {
                PathElement.EnsureStretchIsFill((SceneNode)this.EditingElement);
            }
            if (this.transformHelper == null)
            {
                return;
            }
            this.transformHelper.Update(scale1.X, scale1.Y);
        }
Exemple #5
0
        private void UpdateSkew()
        {
            if (!this.behaviorEnabled)
            {
                return;
            }
            Vector vector1 = this.MouseDevice.GetPosition((IInputElement)this.ActiveView.ViewRootContainer) - this.startPointerPosition;
            double num1    = vector1.X * this.transformedDisplacementVector.X + vector1.Y * this.transformedDisplacementVector.Y;

            vector1.X = this.transformedDisplacementVector.X * num1;
            vector1.Y = this.transformedDisplacementVector.Y * num1;
            Vector             vector2      = vector1 * this.documentToObjectTransform;
            double             num2         = vector2.X * this.displacementVector.X + vector2.Y * this.displacementVector.Y;
            CanonicalTransform newTransform = new CanonicalTransform(this.canonicalTransform);
            Point  fixedPoint = !this.skewAroundCenter ? this.oppositeAdornerPosition : this.BaseEditingElement.RenderTransformOriginInElementCoordinates;
            Vector vector3    = fixedPoint - this.adornerPosition;

            if (vector3.LengthSquared < FloatingPointArithmetic.DistanceTolerance)
            {
                return;
            }
            Vector vector4 = vector3 / vector3.Length;
            double num3    = vector4.X * this.displacementVector.X + vector4.Y * this.displacementVector.Y;

            if ((this.displacementVector - vector4 * num3).LengthSquared < FloatingPointArithmetic.DistanceTolerance)
            {
                return;
            }
            newTransform.ApplySkewScale(this.displacementVector, this.adornerPosition - fixedPoint, this.BaseEditingElement.RenderTransformOriginInElementCoordinates, fixedPoint, this.displacementVector, this.adornerPosition - fixedPoint + this.displacementVector * num2);
            newTransform.ScaleX       = RoundingHelper.RoundScale(newTransform.ScaleX);
            newTransform.ScaleY       = RoundingHelper.RoundScale(newTransform.ScaleY);
            newTransform.SkewX        = RoundingHelper.RoundAngle(newTransform.SkewX);
            newTransform.SkewY        = RoundingHelper.RoundAngle(newTransform.SkewY);
            newTransform.TranslationX = RoundingHelper.RoundLength(newTransform.TranslationX);
            newTransform.TranslationY = RoundingHelper.RoundLength(newTransform.TranslationY);
            if ((Math.Abs(newTransform.Skew.X) - 90.0) * (Math.Abs(newTransform.Skew.X) - 90.0) < FloatingPointArithmetic.DistanceTolerance || (Math.Abs(newTransform.Skew.Y) - 90.0) * (Math.Abs(newTransform.Skew.Y) - 90.0) < FloatingPointArithmetic.DistanceTolerance)
            {
                return;
            }
            AdornedToolBehavior.UpdateElementTransform(this.EditingElement, newTransform, AdornedToolBehavior.TransformPropertyFlags.Scale | AdornedToolBehavior.TransformPropertyFlags.Skew | AdornedToolBehavior.TransformPropertyFlags.Translation);
        }
Exemple #6
0
        protected override void ApplyRotation(double angle)
        {
            Point point1 = this.initialElementSetCenter;

            angle -= this.initialSharedTransform.RotationAngle;
            this.ActiveView.AdornerLayer.FirePropertyChanged("RotateBoundingBoxAdornerRotationAngle", (object)angle);
            foreach (SceneElement element in this.EditingElementSet.Elements)
            {
                if (!(element.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty) is Transform))
                {
                    Transform identity = Transform.Identity;
                }
                Matrix matrix             = this.elementsToElement[element];
                Point  elementCoordinates = ((Base2DElement)element).RenderTransformOriginInElementCoordinates;
                Point  point2             = point1 * matrix;
                point2 = new Point(point2.X - elementCoordinates.X, point2.Y - elementCoordinates.Y);
                Point fixedPoint = RoundingHelper.RoundPosition(point2);
                CanonicalTransform newTransform = (CanonicalTransform)this.initialTransforms[element].Clone();
                newTransform.ApplyRotation(angle, fixedPoint);
                AdornedToolBehavior.UpdateElementTransform(element, newTransform, AdornedToolBehavior.TransformPropertyFlags.Translation | AdornedToolBehavior.TransformPropertyFlags.RotatationAngle);
            }
            if (this.EditingElementSet.HasHomogeneousRotation)
            {
                return;
            }
            this.EditingElementSet.Update();
            this.UpdateEditTransaction();
            this.EditingElement.ViewModel.DefaultView.UpdateLayout();
            Vector vector1 = this.initialArtboardOrigin - this.EditingElement.DesignerContext.ActiveView.Artboard.ArtboardBounds.TopLeft;
            Rect   bounds  = this.EditingElementSet.Bounds;
            Rect   rect    = this.initialBounds;
            Point  point3  = new Point(0.0, 0.0);
            Vector vector2 = this.initialBounds.TopLeft + new Point(this.intialRenderTransformOrigin.X * rect.Width, this.intialRenderTransformOrigin.Y * rect.Height) - point3 - bounds.TopLeft + vector1;

            vector2.X /= bounds.Width;
            vector2.Y /= bounds.Height;
            this.EditingElementSet.RenderTransformOrigin = RoundingHelper.RoundPosition(point3 + vector2);
        }