private void UpdateScale() { Vector scale = new Vector(1.0, 1.0); if (this.constrainAspectRatio) scale.X = scale.Y = 0.0; if (this.ActiveAdorner.TestFlags(EdgeFlags.LeftOrRight)) { double num = this.initialPointerPosition.X - this.currentCenter.X; scale.X = Math.Abs(num) >= 1E-06 ? (this.currentPointerPosition.X - this.currentCenter.X) / num : 1.0; } if (this.ActiveAdorner.TestFlags(EdgeFlags.TopOrBottom)) { double num = this.initialPointerPosition.Y - this.currentCenter.Y; scale.Y = Math.Abs(num) >= 1E-06 ? (this.currentPointerPosition.Y - this.currentCenter.Y) / num : 1.0; } if (this.constrainAspectRatio) { double num = Math.Max(Math.Abs(scale.X), Math.Abs(scale.Y)); scale.X = scale.X < 0.0 ? -num : num; scale.Y = scale.Y < 0.0 ? -num : num; } CanonicalTransform transform = new CanonicalTransform(this.initialBrushTransform); transform.UpdateCenter(this.ActiveAdorner.RelativeBrushCenter); transform.ApplyScale(scale, transform.Center, this.currentCenter); this.SetBrushTransform(transform); }
public object ApplyRelativeTransform(object transform) { if (transform != null) { Transform transform1 = transform as Transform; if (transform1 != null) { CanonicalTransform canonicalTransform = new CanonicalTransform(transform1); Point center = canonicalTransform.Center; canonicalTransform.ApplyScale(new Vector(1.0, 1.0) - this.ComponentVector * 2.0, canonicalTransform.Center, center); canonicalTransform.RotationAngle = -canonicalTransform.RotationAngle; Vector skew = canonicalTransform.Skew; canonicalTransform.Skew = new Vector(-skew.X, -skew.Y); return((object)canonicalTransform); } Transform3D transform2 = transform as Transform3D; if (transform2 != null) { CanonicalTransform3D canonicalTransform3D = new CanonicalTransform3D(transform2); Point3D center = canonicalTransform3D.Center; Vector3D scale = new Vector3D(1.0, 1.0, 1.0) - this.ComponentVector3D * 2.0; canonicalTransform3D.ApplyScale(scale, center); canonicalTransform3D.RotationAngles = -canonicalTransform3D.RotationAngles; return((object)canonicalTransform3D); } } return((object)Transform.Identity); }
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) { 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); }