コード例 #1
0
        private void UpdateTranslation(bool scrollNow)
        {
            SceneView      activeView = this.ActiveView;
            SceneViewModel viewModel  = activeView.ViewModel;
            Vector         delta      = this.dragCurrentPosition - this.dragStartPosition;

            if (this.isConstraining)
            {
                delta = this.ConstrainDeltaToAxis(delta);
            }
            if (delta == this.lastMove || this.IsAltDown)
            {
                return;
            }
            this.EnsureEditTransaction();
            Vector       vector1          = delta - this.lastMove;
            SceneElement primarySelection = viewModel.ElementSelectionSet.PrimarySelection;

            if (primarySelection == null)
            {
                return;
            }
            PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection);

            if (propertyReference == null)
            {
                return;
            }
            object computedValue = primarySelection.GetComputedValue(propertyReference);

            if (computedValue != null && !PlatformTypes.IsInstance(computedValue, PlatformTypes.SolidColorBrush, (ITypeResolver)primarySelection.ProjectContext))
            {
                Vector vector2 = vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true);
                if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool)
                {
                    ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.StartPointProperty);
                    ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(LinearGradientBrushNode.EndPointProperty);
                    Point         point1         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2);
                    Point         point2         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2);
                    this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point1);
                    this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point2);
                }
                else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext) && this.Tool is GradientBrushTool)
                {
                    ReferenceStep referenceStep1 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.CenterProperty);
                    ReferenceStep referenceStep2 = (ReferenceStep)viewModel.ProjectContext.ResolveProperty(RadialGradientBrushNode.GradientOriginProperty);
                    Point         point1         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep1.GetCurrentValue(computedValue)) + vector2);
                    Point         point2         = RoundingHelper.RoundPosition((Point)viewModel.DefaultView.ConvertToWpfValue(referenceStep2.GetCurrentValue(computedValue)) + vector2);
                    this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point1);
                    this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point2);
                }
                else
                {
                    this.TranslateBrushPosition(vector1 * activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, false), primarySelection);
                }
            }
            activeView.EnsureVisible(this.dragStartPosition + delta, scrollNow);
            this.lastMove = delta;
            this.UpdateEditTransaction();
        }
コード例 #2
0
        protected virtual void UpdateCenterPoint(Point centerPoint)
        {
            CanonicalTransform canonicalTransform = new CanonicalTransform((Transform)this.EditingElement.GetComputedValueAsWpf(Base2DElement.RenderTransformProperty));
            Point  elementCoordinates             = this.BaseEditingElement.RenderTransformOriginInElementCoordinates;
            Vector translation           = canonicalTransform.Translation;
            Rect   computedTightBounds   = ((Base2DElement)this.EditingElement).GetComputedTightBounds();
            Point  renderTransformOrigin = this.BaseEditingElement.RenderTransformOrigin;
            Point  point2 = new Point((centerPoint.X - computedTightBounds.Left) / (computedTightBounds.Width == 0.0 ? 1.0 : computedTightBounds.Width), (centerPoint.Y - computedTightBounds.Top) / (computedTightBounds.Height == 0.0 ? 1.0 : computedTightBounds.Height));

            point2 = RoundingHelper.RoundPosition(point2);
            Point newOrigin = new Point(computedTightBounds.Left + point2.X * computedTightBounds.Width, computedTightBounds.Top + point2.Y * computedTightBounds.Height);

            canonicalTransform.UpdateForNewOrigin(elementCoordinates, newOrigin);
            canonicalTransform.TranslationX = RoundingHelper.RoundLength(canonicalTransform.TranslationX);
            canonicalTransform.TranslationY = RoundingHelper.RoundLength(canonicalTransform.TranslationY);
            if (!Point.Equals(renderTransformOrigin, point2))
            {
                this.BaseEditingElement.RenderTransformOrigin = point2;
            }
            if (!object.Equals((object)translation.X, (object)canonicalTransform.TranslationX))
            {
                this.EditingElement.SetValue(this.EditingElement.Platform.Metadata.CommonProperties.RenderTransformTranslationX, (object)canonicalTransform.TranslationX);
            }
            if (object.Equals((object)translation.Y, (object)canonicalTransform.TranslationY))
            {
                return;
            }
            this.EditingElement.SetValue(this.EditingElement.Platform.Metadata.CommonProperties.RenderTransformTranslationY, (object)canonicalTransform.TranslationY);
        }
コード例 #3
0
        private void UpdateRotation()
        {
            this.actionString = StringTable.UndoUnitLinearGradientRotation;
            if (!this.HasMouseMovedAfterDown)
            {
                this.CopyPrimaryBrushToSelection();
            }
            Vector vector = this.dragCurrentPosition - this.centerInRootCoordinates;
            double num    = Math.Atan2(vector.Y, vector.X);

            if (this.IsShiftDown)
            {
                num = Math.Round(num * 57.2957795130823 / 15.0) * 15.0 * (Math.PI / 180.0);
            }
            vector = new Vector(this.radiusInRootCoordinates * Math.Cos(num), this.radiusInRootCoordinates * Math.Sin(num));
            Point point1 = this.centerInRootCoordinates + vector;
            Point point2 = this.centerInRootCoordinates - vector;
            Point point3 = RoundingHelper.RoundPosition(point1 * this.rootToBrushMatrix);
            Point point4 = RoundingHelper.RoundPosition(point2 * this.rootToBrushMatrix);

            if (this.ActiveAdorner.Kind == LinearGradientAdornerKind.EndRotation)
            {
                Point point5 = point3;
                point3 = point4;
                point4 = point5;
            }
            this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point3);
            this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point4);
            this.UpdateEditTransaction();
            this.Cursor = this.ActiveAdorner.AdornerSet.GetCursor((IAdorner)this.ActiveAdorner);
        }
コード例 #4
0
 private void UpdateModelFromMouse(Vector mousePositionDelta)
 {
     if (this.cameraElement == null || !(this.cameraElement is ProjectionCameraElement))
     {
         return;
     }
     if (this.mouseMovementMode == CameraOrbitToolBehavior.MovementMode.Rotate)
     {
         this.totalAzimuthDelta   += -mousePositionDelta.X / 2.0;
         this.totalElevationDelta += -mousePositionDelta.Y / 2.0;
         double angle1 = this.totalAzimuthDelta;
         if (this.IsShiftDown)
         {
             angle1 = CameraOrbitToolBehavior.shiftSnapAngle * Math.Round(angle1 / CameraOrbitToolBehavior.shiftSnapAngle);
         }
         RotateTransform3D rotateTransform3D1 = new RotateTransform3D(Vector3D.DotProduct((Vector3D)this.cameraElement.GetComputedValue(ProjectionCameraElement.UpDirectionProperty), this.cameraInitialUp) >= 0.0 ? (Rotation3D) new AxisAngleRotation3D(this.cameraInitialUp, angle1) : (Rotation3D) new AxisAngleRotation3D(-this.cameraInitialUp, angle1), this.cameraInitialLookAt);
         Point3D           point     = rotateTransform3D1.Transform(this.cameraInitialPosition);
         Vector3D          vector3D1 = rotateTransform3D1.Transform(this.cameraInitialUp);
         Vector3D          axis      = Vector3D.CrossProduct(this.cameraInitialLookAt - point, vector3D1);
         double            angle2    = this.totalElevationDelta;
         if (this.IsShiftDown)
         {
             angle2 = CameraOrbitToolBehavior.shiftSnapAngle * Math.Round(angle2 / CameraOrbitToolBehavior.shiftSnapAngle);
         }
         if (axis.LengthSquared == 0.0)
         {
             return;
         }
         RotateTransform3D rotateTransform3D2 = new RotateTransform3D((Rotation3D) new AxisAngleRotation3D(axis, angle2), this.cameraInitialLookAt);
         Point3D           point3D1           = rotateTransform3D2.Transform(point);
         Vector3D          vector3D2          = rotateTransform3D2.Transform(vector3D1);
         Point3D           point3D2           = RoundingHelper.RoundPosition(point3D1);
         Vector3D          vector3D3          = RoundingHelper.RoundDirection(vector3D2);
         Vector3D          vector3D4          = RoundingHelper.RoundDirection(this.cameraInitialLookAt - point3D2);
         this.cameraElement.SetValue(ProjectionCameraElement.PositionProperty, (object)point3D2);
         this.cameraElement.SetValue(ProjectionCameraElement.UpDirectionProperty, (object)vector3D3);
         this.cameraElement.SetValue(ProjectionCameraElement.LookDirectionProperty, (object)vector3D4);
     }
     else
     {
         Matrix3D matrix3D = Helper3D.CameraRotationMatrix((Camera)this.cameraElement.ViewObject.PlatformSpecificObject);
         if (this.mouseMovementMode == CameraOrbitToolBehavior.MovementMode.TranslateXY)
         {
             Vector3D vector3D1 = new Vector3D(matrix3D.M11, matrix3D.M21, matrix3D.M31);
             Vector3D vector3D2 = new Vector3D(matrix3D.M12, matrix3D.M22, matrix3D.M32);
             this.cameraInitialPosition += this.scale * (-mousePositionDelta.X * vector3D1 + mousePositionDelta.Y * vector3D2);
         }
         else
         {
             Vector3D vector3D1 = new Vector3D(matrix3D.M13, matrix3D.M23, matrix3D.M33);
             this.cameraInitialPosition += this.scale * mousePositionDelta.Y * vector3D1;
             Vector3D vector3D2 = RoundingHelper.RoundDirection(this.cameraInitialLookAt - this.cameraInitialPosition);
             this.cameraElement.SetValue(ProjectionCameraElement.LookDirectionProperty, (object)vector3D2);
         }
         this.cameraInitialPosition = RoundingHelper.RoundPosition(this.cameraInitialPosition);
         this.cameraElement.SetValue(ProjectionCameraElement.PositionProperty, (object)this.cameraInitialPosition);
     }
 }
コード例 #5
0
 protected override bool OnClickEnd(Point pointerPosition, int clickCount)
 {
     if (clickCount > 1)
     {
         this.actionString = StringTable.UndoUnitResetRadialGradient;
         Point  point = new Point(0.5, 0.5);
         double num1  = 1.0;
         double num2  = 1.0;
         if (this.ActiveAdorner.IsStretchedToFitBoundingBox)
         {
             point = new Point(0.5, 0.5);
             num1  = num2 = 0.5;
         }
         else
         {
             BaseFrameworkElement frameworkElement = this.EditingElement as BaseFrameworkElement;
             if (frameworkElement == null)
             {
                 StyleNode styleNode = this.EditingElement as StyleNode;
                 if (styleNode != null)
                 {
                     frameworkElement = styleNode.TargetElement;
                 }
             }
             if (frameworkElement != null)
             {
                 Rect computedTightBounds = frameworkElement.GetComputedTightBounds();
                 num1  = RoundingHelper.RoundLength(computedTightBounds.Width / 2.0);
                 num2  = RoundingHelper.RoundLength(computedTightBounds.Height / 2.0);
                 point = RoundingHelper.RoundPosition(new Point(computedTightBounds.X + num1, computedTightBounds.Y + num2));
             }
         }
         this.CopyPrimaryBrushToSelection();
         this.ClearBrushTransform();
         if ((Point)this.GetBrushValue(RadialGradientBrushNode.GradientOriginProperty) != point)
         {
             this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point);
         }
         if ((Point)this.GetBrushValue(RadialGradientBrushNode.CenterProperty) != point)
         {
             this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point);
         }
         if ((double)this.GetBrushValue(RadialGradientBrushNode.RadiusXProperty) != num1)
         {
             this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)num1);
         }
         if ((double)this.GetBrushValue(RadialGradientBrushNode.RadiusYProperty) != num2)
         {
             this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)num2);
         }
     }
     this.CommitEditTransaction();
     return(base.OnClickEnd(pointerPosition, clickCount));
 }
コード例 #6
0
        private void UpdatePosition()
        {
            Point positionInBrush = this.dragCurrentPosition * this.rootToBrushMatrix;

            if (this.IsShiftDown)
            {
                Vector vector1 = this.initialEndPoint - this.initialStartPoint;
                double length  = vector1.Length;
                if (length == 0.0)
                {
                    positionInBrush = this.initialStartPoint;
                }
                else
                {
                    Vector vector2 = vector1 / length;
                    positionInBrush = this.initialStartPoint + vector2 * (positionInBrush - this.initialStartPoint) * vector2;
                }
            }
            Point point = RoundingHelper.RoundPosition(new Point(this.initialStartPoint.X + this.initialEndPoint.X - positionInBrush.X, this.initialStartPoint.Y + this.initialEndPoint.Y - positionInBrush.Y));

            if (this.ActiveAdorner.Kind == LinearGradientAdornerKind.StartPoint)
            {
                positionInBrush *= this.brushToRootMatrix;
                BrushTransformBehavior.OffsetDragPoint(ref positionInBrush, this.initialEndPoint * this.brushToRootMatrix, this.dragOffset, 0.001 / this.ActiveView.Zoom);
                positionInBrush   = RoundingHelper.RoundPosition(positionInBrush * this.rootToBrushMatrix);
                this.actionString = StringTable.UndoUnitLinearGradientStart;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                }
                this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)positionInBrush);
                if (this.IsAltDown)
                {
                    this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point);
                }
            }
            else
            {
                positionInBrush *= this.brushToRootMatrix;
                BrushTransformBehavior.OffsetDragPoint(ref positionInBrush, this.initialStartPoint * this.brushToRootMatrix, this.dragOffset, 0.001 / this.ActiveView.Zoom);
                positionInBrush   = RoundingHelper.RoundPosition(positionInBrush * this.rootToBrushMatrix);
                this.actionString = StringTable.UndoUnitLinearGradientEnd;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                }
                this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)positionInBrush);
                if (this.IsAltDown)
                {
                    this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point);
                }
            }
            this.UpdateEditTransaction();
        }
コード例 #7
0
        protected override bool OnDrag(Point dragStartPosition, Point dragCurrentPosition, bool scrollNow)
        {
            switch (this.ActiveAdorner.Kind)
            {
            case RadialGradientAdornerKind.GradientOriginPoint:
                this.actionString = StringTable.UndoUnitRadialGradientOrigin;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                }
                Point point = this.initialCenterInBrush;
                if (Tolerances.HaveMoved(dragCurrentPosition, this.initialCenterInDocument, this.ActiveView.Zoom))
                {
                    Point positionInBrush = this.ActiveAdorner.InverseTransformPoint(dragCurrentPosition * this.initialContextToElementMatrix, true) * this.brushToRootMatrix;
                    BrushTransformBehavior.OffsetDragPoint(ref positionInBrush, this.initialCenterInBrush * this.brushToRootMatrix, this.dragOffset, 0.0);
                    point = RoundingHelper.RoundPosition(positionInBrush * this.rootToBrushMatrix);
                }
                if (this.ActiveAdorner.GradientOriginPoint != point)
                {
                    this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point);
                    this.UpdateEditTransaction();
                    break;
                }
                break;

            case RadialGradientAdornerKind.RadiusPoint:
                this.actionString = StringTable.UndoUnitScaleRadialGradient;
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                    this.radiusX = (double)this.GetBrushValue(RadialGradientBrushNode.RadiusXProperty);
                    this.radiusY = (double)this.GetBrushValue(RadialGradientBrushNode.RadiusYProperty);
                    if (Math.Abs(this.radiusX) < 0.01)
                    {
                        this.radiusX = 0.01;
                    }
                    if (Math.Abs(this.radiusY) < 0.01)
                    {
                        this.radiusY = 0.01;
                    }
                }
                Vector perpendicular;
                double num1 = GradientStopBehavior.VectorProjection(this.ActiveAdorner.BrushCenter * this.brushToRootMatrix, this.initialPointerPosition, dragCurrentPosition, 0.0, out perpendicular);
                double num2 = RoundingHelper.RoundLength(this.radiusX * num1);
                double num3 = RoundingHelper.RoundLength(this.radiusY * num1);
                this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)num2);
                this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)num3);
                this.UpdateEditTransaction();
                break;
            }
            this.ActiveView.EnsureVisible((IAdorner)this.ActiveAdorner, scrollNow);
            return(true);
        }
コード例 #8
0
        internal AnnotationSceneNode CreateAnnotation(IEnumerable <SceneElement> targets)
        {
            Artboard            artboard             = this.sceneViewModel.DefaultView.Artboard;
            SceneElement        sceneElement         = Enumerable.First <SceneElement>(targets);
            int                 num                  = Enumerable.Count <SceneElement>(targets);
            bool                treatTopLeftAsCenter = num > 1 || sceneElement.Equals((object)sceneElement.ViewModel.RootNode);
            AnnotationSceneNode annotation;

            using (SceneEditTransaction editTransaction = sceneElement.ViewModel.CreateEditTransaction(StringTable.AddAnnotationUndoUnit))
            {
                annotation = AnnotationManagerSceneNode.CreateAnnotation((SceneNode)sceneElement);
                foreach (SceneElement element in Enumerable.Skip <SceneElement>(targets, 1))
                {
                    AnnotationUtils.AddAnnotationReference(element, annotation);
                }
                Point point1;
                if (treatTopLeftAsCenter)
                {
                    Rect rect = Rect.Empty;
                    if (num > 1 || !sceneElement.Equals((object)annotation.ViewModel.RootNode))
                    {
                        rect = artboard.GetElementListBounds(targets);
                    }
                    if (rect.IsEmpty)
                    {
                        rect = artboard.ArtboardBounds;
                    }
                    point1 = new Point(rect.Left + rect.Width / 2.0, rect.Top + rect.Height / 2.0);
                }
                else
                {
                    point1 = artboard.GetElementBounds(sceneElement).TopRight;
                }
                Point point2 = RoundingHelper.RoundPosition(point1);
                annotation.Left = point2.X;
                annotation.Top  = point2.Y;
                string authorName = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorName;
                if (!string.IsNullOrEmpty(authorName))
                {
                    annotation.Author = authorName;
                }
                string authorInitials = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorInitials;
                if (!string.IsNullOrEmpty(authorInitials))
                {
                    annotation.AuthorInitials = authorInitials;
                }
                AnnotationUtils.SetSerialNumber(annotation);
                editTransaction.Commit();
            }
            this.CreateAnnotationVisual(annotation).Initialize(treatTopLeftAsCenter);
            return(annotation);
        }
コード例 #9
0
        protected override void UpdateCenterPoint(Point centerPoint)
        {
            Rect  elementBounds         = this.EditingElementSet.ElementBounds;
            Point renderTransformOrigin = this.EditingElementSet.RenderTransformOrigin;
            Point point2 = new Point((centerPoint.X - elementBounds.Left) / (elementBounds.Width == 0.0 ? 1.0 : elementBounds.Width), (centerPoint.Y - elementBounds.Top) / (elementBounds.Height == 0.0 ? 1.0 : elementBounds.Height));

            point2 = RoundingHelper.RoundPosition(point2);
            if (Point.Equals(renderTransformOrigin, point2))
            {
                return;
            }
            this.EditingElementSet.RenderTransformOrigin = point2;
        }
コード例 #10
0
        private void OnDragWithin(Vector delta)
        {
            Matrix matrix = (((UIElement)this.Parent).RenderTransform ?? Transform.Identity).Clone().Value;

            matrix.Invert();
            Vector       offset       = matrix.Transform(delta);
            Size         size         = this.TransformFromRenderToLayout(this.RenderSize);
            SceneElement sceneElement = this.Annotation.ViewModel.ActiveSceneInsertionPoint.SceneElement;
            Rect         rectSnap     = Rect.Transform(new Rect(this.drag.OriginalAnnotationPos, size), sceneElement.TransformFromRoot);
            Point        point        = RoundingHelper.RoundPosition(this.drag.OriginalAnnotationPos + offset + this.SnapRect(rectSnap, sceneElement, offset, EdgeFlags.All));

            this.Annotation.Left = point.X;
            this.Annotation.Top  = point.Y;
            this.drag.Undo.Update();
        }
コード例 #11
0
 protected override bool OnClickEnd(Point pointerPosition, int clickCount)
 {
     if (clickCount > 1)
     {
         this.CancelEditTransaction();
         this.actionString = StringTable.UndoUnitResetLinearGradient;
         Point point1 = new Point();
         Point point2 = new Point();
         if (this.ActiveAdorner.IsStretchedToFitBoundingBox)
         {
             point1 = new Point(0.5, 0.0);
             point2 = new Point(0.5, 1.0);
         }
         else
         {
             BaseFrameworkElement frameworkElement = this.EditingElement as BaseFrameworkElement;
             if (frameworkElement == null)
             {
                 StyleNode styleNode = this.EditingElement as StyleNode;
                 if (styleNode != null)
                 {
                     frameworkElement = styleNode.TargetElement;
                 }
             }
             if (frameworkElement != null)
             {
                 Rect computedTightBounds = frameworkElement.GetComputedTightBounds();
                 point1 = RoundingHelper.RoundPosition(new Point((computedTightBounds.Left + computedTightBounds.Right) / 2.0, computedTightBounds.Top));
                 point2 = RoundingHelper.RoundPosition(new Point((computedTightBounds.Left + computedTightBounds.Right) / 2.0, computedTightBounds.Bottom));
             }
         }
         this.CopyPrimaryBrushToSelection();
         this.ClearBrushTransform();
         if ((Point)this.GetBrushValue(LinearGradientBrushNode.StartPointProperty) != point1)
         {
             this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point1);
         }
         if ((Point)this.GetBrushValue(LinearGradientBrushNode.EndPointProperty) != point2)
         {
             this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point2);
         }
         this.UpdateEditTransaction();
     }
     this.CommitEditTransaction();
     return(base.OnClickEnd(pointerPosition, clickCount));
 }
コード例 #12
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);
        }
コード例 #13
0
        private void UpdateBrushForMappingModeChange(PropertyReference brushPropertyReference, BrushMappingMode mappingMode)
        {
            GradientBrush gradientBrush = this.GetComputedValueAsWpf(brushPropertyReference) as GradientBrush;

            if (gradientBrush == null || gradientBrush.MappingMode == mappingMode)
            {
                return;
            }
            Rect computedTightBounds = this.GetComputedTightBounds();

            if (computedTightBounds.IsEmpty)
            {
                return;
            }
            Matrix identity = Matrix.Identity;
            Matrix matrix   = Matrix.Identity;

            if (BrushAdorner.IsAdorningFillProperty((SceneElement)this))
            {
                matrix = BrushAdorner.GetStrokeTransform((SceneElement)this);
            }
            if (mappingMode == BrushMappingMode.Absolute)
            {
                identity *= matrix;
                identity.Scale(computedTightBounds.Width, computedTightBounds.Height);
                identity.Translate(computedTightBounds.X, computedTightBounds.Y);
            }
            else if (mappingMode == BrushMappingMode.RelativeToBoundingBox)
            {
                identity.Translate(-computedTightBounds.X, -computedTightBounds.Y);
                identity.Scale(computedTightBounds.Width == 0.0 ? 1.0 : 1.0 / computedTightBounds.Width, computedTightBounds.Height == 0.0 ? 1.0 : 1.0 / computedTightBounds.Height);
                matrix.Invert();
                identity *= matrix;
            }
            if (identity.IsIdentity)
            {
                return;
            }
            LinearGradientBrush linearGradientBrush;

            if ((linearGradientBrush = gradientBrush as LinearGradientBrush) != null)
            {
                Point point1 = RoundingHelper.RoundPosition(linearGradientBrush.StartPoint * identity);
                Point point2 = RoundingHelper.RoundPosition(linearGradientBrush.EndPoint * identity);
                this.SetValueAsWpf(brushPropertyReference.Append(LinearGradientBrushNode.StartPointProperty), (object)point1);
                this.SetValueAsWpf(brushPropertyReference.Append(LinearGradientBrushNode.EndPointProperty), (object)point2);
            }
            else
            {
                RadialGradientBrush radialGradientBrush;
                if ((radialGradientBrush = gradientBrush as RadialGradientBrush) == null)
                {
                    return;
                }
                Point  point1 = RoundingHelper.RoundPosition(radialGradientBrush.Center * identity);
                Point  point2 = RoundingHelper.RoundPosition(radialGradientBrush.GradientOrigin * identity);
                double num1   = RoundingHelper.RoundLength(radialGradientBrush.RadiusX * identity.M11);
                double num2   = RoundingHelper.RoundLength(radialGradientBrush.RadiusY * identity.M22);
                this.SetValueAsWpf(brushPropertyReference.Append(RadialGradientBrushNode.CenterProperty), (object)point1);
                this.SetValueAsWpf(brushPropertyReference.Append(RadialGradientBrushNode.GradientOriginProperty), (object)point2);
                this.SetValue(brushPropertyReference.Append(RadialGradientBrushNode.RadiusXProperty), (object)num1);
                this.SetValue(brushPropertyReference.Append(RadialGradientBrushNode.RadiusYProperty), (object)num2);
            }
        }
コード例 #14
0
        private void UpdateTranslation(bool scrollNow)
        {
            SceneView      activeView = this.ActiveView;
            SceneViewModel viewModel  = activeView.ViewModel;

            if (!this.HasMouseMovedAfterDown)
            {
                this.hasInitializedBrush = false;
            }
            SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection;

            if (primarySelection == null)
            {
                return;
            }
            PropertyReference propertyReference = this.GetBrushPropertyReference((SceneNode)primarySelection);

            if (propertyReference == null || Adorner.NonAffineTransformInParentStack(primarySelection))
            {
                return;
            }
            this.EnsureEditTransaction();
            if (!this.hasInitializedBrush)
            {
                if (!PlatformTypes.IsInstance(this.ActiveView.ElementSelectionSet.PrimarySelection.GetComputedValue(propertyReference), PlatformTypes.GradientBrush, (ITypeResolver)primarySelection.ProjectContext))
                {
                    object lastUsed = BrushCategory.GetLastUsed(this.ActiveView.DesignerContext, this.ActiveView.Document.DocumentContext, BrushCategory.Gradient);
                    this.ActiveView.ElementSelectionSet.PrimarySelection.SetValueAsWpf(propertyReference, lastUsed);
                    this.UpdateEditTransaction();
                }
                this.CopyPrimaryBrushToSelection();
                this.hasInitializedBrush = true;
            }
            object computedValue = primarySelection.GetComputedValue(propertyReference);
            Matrix matrix        = activeView.GetComputedTransformFromRoot(primarySelection) * BrushAdorner.GetCompleteInverseBrushTransformMatrix((Base2DElement)primarySelection, computedValue, true);
            Point  point1        = this.dragStartPosition * matrix;
            Point  point2        = this.dragCurrentPosition * matrix;
            Point  point3        = RoundingHelper.RoundPosition(point1);
            Point  point4        = RoundingHelper.RoundPosition(point2);

            if (PlatformTypes.IsInstance(computedValue, PlatformTypes.LinearGradientBrush, (ITypeResolver)primarySelection.ProjectContext))
            {
                this.SetBrushValue(LinearGradientBrushNode.StartPointProperty, (object)point3);
                this.SetBrushValue(LinearGradientBrushNode.EndPointProperty, (object)point4);
            }
            else if (PlatformTypes.IsInstance(computedValue, PlatformTypes.RadialGradientBrush, (ITypeResolver)primarySelection.ProjectContext))
            {
                this.SetBrushValue(RadialGradientBrushNode.CenterProperty, (object)point3);
                this.SetBrushValue(RadialGradientBrushNode.GradientOriginProperty, (object)point3);
                if (this.IsShiftDown)
                {
                    Vector vector = point4 - point3;
                    this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)vector.Length);
                    this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)vector.Length);
                }
                else
                {
                    Point point5 = RoundingHelper.RoundPosition(new Point(Math.Abs(point3.X - point4.X), Math.Abs(point3.Y - point4.Y)));
                    this.SetBrushValue(RadialGradientBrushNode.RadiusXProperty, (object)point5.X);
                    this.SetBrushValue(RadialGradientBrushNode.RadiusYProperty, (object)point5.Y);
                }
            }
            activeView.EnsureVisible(this.dragStartPosition + this.dragCurrentPosition - this.dragStartPosition, scrollNow);
            this.UpdateEditTransaction();
        }