Exemple #1
0
 public DiffuseMaterialEditor(SceneNodeObjectSet objectSet, PropertyReference materialReference)
     : base(objectSet, materialReference)
 {
     this.ColorProperty        = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.DiffusColorProperty), (AttributeCollection)null);
     this.BrushProperty        = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.DiffusBrushProperty), (AttributeCollection)null);
     this.ambientColorProperty = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.DiffusAmbientColorProperty), (AttributeCollection)null);
 }
Exemple #2
0
 public SpecularMaterialEditor(SceneNodeObjectSet objectSet, PropertyReference materialReference)
     : base(objectSet, materialReference)
 {
     this.ColorProperty         = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.SpecularColorProperty), (AttributeCollection)null);
     this.BrushProperty         = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.SpecularBrushProperty), (AttributeCollection)null);
     this.specularPowerProperty = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.SpecularPowerProperty), (AttributeCollection)null);
     this.specularPowerProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnSpecularPowerChanged);
 }
Exemple #3
0
        private PropertyReference CreatePropertyReference(int figureIndex, int segmentIndex)
        {
            PropertyReference propertyReference = new PropertyReference((ReferenceStep)this.platformMetadata.ResolveProperty((IPropertyId)this.pathProperty)).Append(PathElement.FiguresProperty).Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, figureIndex));

            if (segmentIndex == PathStructureChange.StartPointIndex)
            {
                return(propertyReference.Append(PathElement.PathFigureStartPointProperty));
            }
            return(propertyReference.Append(PathElement.PathFigureSegmentsProperty).Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, segmentIndex)));
        }
Exemple #4
0
        private static void TransferPathFigureAnimations(PathElement oldElement, PathElement newElement, PropertyReference pathProperty, int oldFigureIndex, int newFigureIndex, Transform transform, PathAnimationMovePackage animationMove)
        {
            IProjectContext   projectContext             = newElement.ProjectContext;
            IType             type                       = projectContext.ResolveType(PlatformTypes.PathFigureCollection);
            PropertyReference propertyReference          = pathProperty.Append(PathElement.FiguresProperty);
            ReferenceStep     step1                      = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((ITypeResolver)projectContext, type.RuntimeType, oldFigureIndex);
            PropertyReference sourceReferencePrefix      = propertyReference.Append(step1);
            ReferenceStep     step2                      = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((ITypeResolver)projectContext, type.RuntimeType, newFigureIndex);
            PropertyReference destinationReferencePrefix = propertyReference.Append(step2);

            PathCommandHelper.MoveVertexAnimations((SceneElement)oldElement, sourceReferencePrefix, (SceneElement)newElement, destinationReferencePrefix, transform, animationMove);
        }
Exemple #5
0
 private void SetFigureUsingMinimalDiff(PathFigure pathFigure, PathFigure currentFigure, PropertyReference figureReference)
 {
     if (!VectorUtilities.ArePathPointsVeryClose(currentFigure.StartPoint, pathFigure.StartPoint))
     {
         this.targetElement.SetValueAsWpf(figureReference.Append(PathElement.PathFigureStartPointProperty), (object)pathFigure.StartPoint);
     }
     for (int index = 0; index < pathFigure.Segments.Count; ++index)
     {
         PathSegment       currentSegment    = currentFigure.Segments[index];
         PathSegment       pathSegment       = pathFigure.Segments[index];
         PropertyReference segmentsReference = figureReference.Append(PathElement.PathFigureSegmentsProperty).Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, index));
         this.SetSegmentUsingMinimalDiff(pathSegment, currentSegment, segmentsReference);
     }
 }
Exemple #6
0
        private void SetQuadraticBezierSegmentUsingMinimalDiff(QuadraticBezierSegment currentSegment, QuadraticBezierSegment pathSegment, PropertyReference segmentReference)
        {
            PropertyReference propertyReference1 = segmentReference.Append(PathElement.QuadraticBezierSegmentPoint1Property);
            PropertyReference propertyReference2 = segmentReference.Append(PathElement.QuadraticBezierSegmentPoint2Property);

            if (!VectorUtilities.ArePathPointsVeryClose(currentSegment.Point1, pathSegment.Point1))
            {
                this.targetElement.SetValueAsWpf(propertyReference1, (object)pathSegment.Point1);
            }
            if (VectorUtilities.ArePathPointsVeryClose(currentSegment.Point2, pathSegment.Point2))
            {
                return;
            }
            this.targetElement.SetValueAsWpf(propertyReference2, (object)pathSegment.Point2);
        }
Exemple #7
0
 public static void MoveVertexAnimations(SceneElement source, PropertyReference sourceReferencePrefix, SceneElement destination, PropertyReference destinationReferencePrefix, Transform transform, PathAnimationMovePackage animationMove)
 {
     foreach (StoryboardTimelineSceneNode parent in source.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(source.StoryboardContainer))
     {
         foreach (TimelineSceneNode timeline1 in (IEnumerable <TimelineSceneNode>)parent.Children)
         {
             if (timeline1.TargetElement == source && timeline1.TargetProperty != null && sourceReferencePrefix.IsPrefixOf(timeline1.TargetProperty))
             {
                 PropertyReference propertyReference = destinationReferencePrefix;
                 for (int count = sourceReferencePrefix.Count; count < timeline1.TargetProperty.Count; ++count)
                 {
                     propertyReference = propertyReference.Append(timeline1.TargetProperty[count]);
                 }
                 TimelineSceneNode timeline2 = (TimelineSceneNode)source.ViewModel.GetSceneNode(timeline1.DocumentNode.Clone(timeline1.DocumentContext));
                 if (transform != null)
                 {
                     PathCommandHelper.ApplyTransformToAnimation(timeline2, transform);
                 }
                 timeline2.TargetProperty = propertyReference;
                 timeline2.TargetElement  = (SceneNode)destination;
                 animationMove.Add(parent, timeline2);
                 animationMove.Remove(parent, timeline1);
             }
         }
     }
 }
Exemple #8
0
        public void UpdatePropertyContainers(TransformPropertyLookup propertyLookup)
        {
            AttributeCollection attributes = new AttributeCollection(new Attribute[2]
            {
                (Attribute) new NumberRangesAttribute(new double?(double.NegativeInfinity), new double?(0.0), new double?(1.0), new double?(double.PositiveInfinity), new bool?()),
                (Attribute) new NumberIncrementsAttribute(new double?(0.01), new double?(0.05), new double?(0.1))
            });
            ITypeResolver     typeResolver      = (ITypeResolver)propertyLookup.TransformProperty.SceneNodeObjectSet.ProjectContext;
            PropertyReference propertyReference = new PropertyReference(typeResolver.ResolveProperty(Base2DElement.RenderTransformOriginProperty) as ReferenceStep);
            ReferenceStep     property1         = PlatformTypeHelper.GetProperty(typeResolver, PlatformTypes.Point, MemberType.LocalProperty, "X");
            ReferenceStep     property2         = PlatformTypeHelper.GetProperty(typeResolver, PlatformTypes.Point, MemberType.LocalProperty, "Y");

            this.renderTransformOriginXProperty = propertyReference.Append(property1);
            this.renderTransformOriginYProperty = propertyReference.Append(property2);
            PropertyReference reference = propertyLookup.TransformProperty.Reference;

            if (reference.Count == 1 && reference.FirstStep.Equals((object)Base2DElement.RenderTransformProperty))
            {
                if (propertyLookup.Relative)
                {
                    this.CenterPointXEditor.PropertyEntry = (PropertyEntry)null;
                    this.CenterPointYEditor.PropertyEntry = (PropertyEntry)null;
                }
                else
                {
                    this.CenterPointXEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateNormalProperty(this.renderTransformOriginXProperty, attributes);
                    this.CenterPointYEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateNormalProperty(this.renderTransformOriginYProperty, attributes);
                }
            }
            else
            {
                this.CenterPointXEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterX", attributes);
                this.CenterPointYEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterY", attributes);
            }
            if (propertyLookup.TransformType == TransformType.Transform3D)
            {
                this.CenterPointZEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterZ", attributes);
            }
            else
            {
                this.CenterPointZEditor.PropertyEntry = (PropertyEntry)null;
            }
        }
Exemple #9
0
        private void SetLineSegmentUsingMinimalDiff(LineSegment currentSegment, LineSegment pathSegment, PropertyReference segmentReference)
        {
            PropertyReference propertyReference = segmentReference.Append(PathElement.LineSegmentPointProperty);

            if (VectorUtilities.ArePathPointsVeryClose(currentSegment.Point, pathSegment.Point))
            {
                return;
            }
            this.targetElement.SetValueAsWpf(propertyReference, (object)pathSegment.Point);
        }
        public GradientStopEditor(BrushEditor brushEditor, SceneNodeProperty basisProperty, int propertyIndex)
            : base(brushEditor, basisProperty)
        {
            ITypeResolver typeResolver = (ITypeResolver)basisProperty.SceneNodeObjectSet.ProjectContext;
            IType         type         = typeResolver.ResolveType(PlatformTypes.GradientStopCollection);

            if (type == null)
            {
                return;
            }
            IndexedClrPropertyReferenceStep referenceStep = IndexedClrPropertyReferenceStep.GetReferenceStep(typeResolver, type.RuntimeType, propertyIndex);
            PropertyReference propertyReference           = basisProperty.Reference.Append((ReferenceStep)referenceStep);

            this.gradientStopProperty = basisProperty.SceneNodeObjectSet.CreateSceneNodeProperty(propertyReference, (AttributeCollection)null);
            ReferenceStep step1 = (ReferenceStep)typeResolver.ResolveProperty(GradientStopNode.ColorProperty);
            ReferenceStep step2 = (ReferenceStep)typeResolver.ResolveProperty(GradientStopNode.OffsetProperty);

            this.colorProperty  = this.RequestUpdates(propertyReference.Append(step1), new PropertyChangedEventHandler(this.OnColorChanged));
            this.offsetProperty = this.RequestUpdates(propertyReference.Append(step2), new PropertyChangedEventHandler(this.OnOffsetChanged));
            this.propertyIndex  = propertyIndex;
        }
Exemple #11
0
        private void SetPathGeometryUsingMinimalDiff(PathGeometry path, PathGeometry currentGeometry)
        {
            PropertyReference propertyReference = new PropertyReference(this.platformMetadata.ResolveProperty((IPropertyId)this.pathProperty) as ReferenceStep).Append(PathElement.FiguresProperty);

            for (int index = 0; index < path.Figures.Count; ++index)
            {
                ReferenceStep     step            = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, index);
                PropertyReference figureReference = propertyReference.Append(step);
                PathFigure        currentFigure   = currentGeometry.Figures[index];
                this.SetFigureUsingMinimalDiff(path.Figures[index], currentFigure, figureReference);
            }
        }
Exemple #12
0
        private void SetPolyLineSegmentUsingMinimalDiff(PolyLineSegment currentSegment, PolyLineSegment pathSegment, PropertyReference segmentReference)
        {
            PropertyReference propertyReference1 = segmentReference.Append(PathElement.PolyLineSegmentPointsProperty);

            for (int index = 0; index < currentSegment.Points.Count; ++index)
            {
                ReferenceStep     step = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PointCollection, index);
                PropertyReference propertyReference2 = propertyReference1.Append(step);
                if (!VectorUtilities.ArePathPointsVeryClose(currentSegment.Points[index], pathSegment.Points[index]))
                {
                    this.targetElement.SetValueAsWpf(propertyReference2, (object)pathSegment.Points[index]);
                }
            }
        }
        public override void Draw(DrawingContext context, Matrix matrix)
        {
            if (this.Hidden || !this.ShouldDraw || !PlatformTypes.IsInstance(this.PlatformBrush, PlatformTypes.GradientBrush, (ITypeResolver)this.Element.ProjectContext))
            {
                return;
            }
            Matrix            matrix1            = this.GetCompleteBrushTransformMatrix(true) * matrix;
            PropertyReference propertyReference1 = this.AdornerSet.BrushPropertyReference.Append(GradientBrushNode.GradientStopsProperty);
            int   num1 = (int)this.Element.GetComputedValue(propertyReference1.Append(GradientStopCollectionNode.CountProperty));
            Point startPoint;
            Point endPoint;

            if (!this.GetBrushEndpoints(out startPoint, out endPoint) || this.Index < 0 || this.Index >= num1)
            {
                return;
            }
            PropertyReference propertyReference2 = propertyReference1.Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.Element.ViewModel.ProjectContext.Platform.Metadata, PlatformTypes.GradientStopCollection, this.Index));
            PropertyReference propertyReference3 = propertyReference2.Append(GradientStopNode.OffsetProperty);
            PropertyReference propertyReference4 = propertyReference2.Append(GradientStopNode.ColorProperty);
            double            num2 = (double)this.Element.GetComputedValue(propertyReference3);
            int    index           = this.DesignerContext.GradientToolSelectionService.Index;
            Point  point           = (endPoint - startPoint) * num2 + startPoint;
            double num3            = 3.5;
            Color  color           = (Color)this.Element.GetComputedValueAsWpf(propertyReference4);

            color.A = byte.MaxValue;
            SolidColorBrush solidColorBrush = new SolidColorBrush(color);
            Pen             pen             = this.ThinPen;

            if (index == this.Index)
            {
                pen  = this.ThickPen;
                num3 = 4.5;
            }
            context.DrawEllipse((Brush)Brushes.Transparent, (Pen)null, point * matrix1, num3 + 4.0, num3 + 4.0);
            context.DrawEllipse((Brush)solidColorBrush, pen, point * matrix1, num3, num3);
        }
        protected void SetBrushValue(IPropertyId property, object valueToSet)
        {
            SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection;

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

            if (propertyReference == null)
            {
                return;
            }
            this.SetBrushValue(propertyReference.Append(property), valueToSet);
        }
        private void SetBrushTransformValue(PropertyReference propertyReference, double valueToSet)
        {
            SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection;

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

            if (propertyReference1 == null)
            {
                return;
            }
            this.SetBrushValue(propertyReference1.Append(propertyReference), (object)valueToSet);
        }
        protected object GetBrushValue(IPropertyId property)
        {
            SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection;

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

            if (propertyReference1 == null)
            {
                return((object)null);
            }
            PropertyReference propertyReference2 = propertyReference1.Append(property);

            return(primarySelection.GetComputedValueAsWpf(propertyReference2));
        }
Exemple #17
0
 private void ChangeAnimationProperty(PropertyReference fromProperty, PropertyReference toProperty, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toAdd, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toRemove, bool exactMatch)
 {
     foreach (StoryboardTimelineSceneNode timelineSceneNode in this.targetElement.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(this.targetElement.StoryboardContainer))
     {
         foreach (TimelineSceneNode timeline in (IEnumerable <TimelineSceneNode>)timelineSceneNode.Children)
         {
             if (timeline.TargetElement == this.targetElement && timeline.TargetProperty != null)
             {
                 PropertyReference propertyReference = toProperty;
                 bool flag1 = AnimationProxyManager.IsOptimizedAnimation(timeline);
                 bool flag2 = !flag1 && fromProperty.Equals((object)timeline.TargetProperty);
                 if (!flag1 && !exactMatch && !flag2)
                 {
                     flag2 = fromProperty.IsPrefixOf(timeline.TargetProperty);
                     if (flag2)
                     {
                         for (int count = toProperty.Count; count < timeline.TargetProperty.Count; ++count)
                         {
                             propertyReference = propertyReference.Append(timeline.TargetProperty[count]);
                         }
                     }
                 }
                 if (flag2)
                 {
                     if (toRemove != null)
                     {
                         toRemove[timeline] = timelineSceneNode;
                     }
                     TimelineSceneNode index = (TimelineSceneNode)this.targetElement.ViewModel.GetSceneNode(timeline.DocumentNode.Clone(timeline.DocumentContext));
                     index.TargetProperty  = propertyReference;
                     index.ShouldSerialize = true;
                     KeyFrameAnimationSceneNode animationSceneNode = index as KeyFrameAnimationSceneNode;
                     if (animationSceneNode != null)
                     {
                         animationSceneNode.IsAnimationProxy = false;
                     }
                     toAdd[index] = timelineSceneNode;
                 }
             }
         }
     }
 }
Exemple #18
0
        protected override void ModifyValue(PropertyReference propertyReference, object valueToSet, SceneNode.Modification modification, int index)
        {
            bool flag = DesignTimeProperties.EulerAnglesProperty.Equals((object)propertyReference.LastStep);

            if (!flag || !this.ViewModel.AnimationEditor.IsKeyFraming || this.ViewModel.IsForcingBaseValue)
            {
                base.ModifyValue(propertyReference, valueToSet, modification, index);
            }
            if (!flag)
            {
                return;
            }
            propertyReference = propertyReference.Subreference(0, propertyReference.Count - 2);
            propertyReference = propertyReference.Append(Base3DElement.RotateTransform3DRotationProperty);
            if (valueToSet is Vector3D)
            {
                Quaternion quaternion = Helper3D.QuaternionFromEulerAngles((Vector3D)valueToSet);
                valueToSet = (object)new AxisAngleRotation3D(RoundingHelper.RoundDirection(quaternion.Axis), RoundingHelper.RoundAngle(quaternion.Angle));
            }
            base.ModifyValue(propertyReference, valueToSet, modification, index);
        }
        protected void ClearBrushTransform()
        {
            SceneElement primarySelection = this.ActiveView.ElementSelectionSet.PrimarySelection;

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

            if (propertyReference1 == null)
            {
                return;
            }
            this.EnsureEditTransaction();
            PropertyReference propertyReference2 = propertyReference1.Append(BrushNode.RelativeTransformProperty);

            foreach (SceneNode sceneNode in this.ActiveView.ElementSelectionSet.Selection)
            {
                sceneNode.ClearValue(propertyReference2);
            }
        }
Exemple #20
0
 protected override bool OnDragEnd(Point dragStartPosition, Point dragEndPosition)
 {
     if (this.isDraggedOff)
     {
         PropertyReference propertyReference1 = this.GetBrushPropertyReference((SceneNode)this.EditingElement).Append(GradientBrushNode.GradientStopsProperty);
         PropertyReference propertyReference2 = propertyReference1.Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.ActiveView.ViewModel.ProjectContext.Platform.Metadata, PlatformTypes.GradientStopCollection, this.ActiveAdorner.Index));
         foreach (SceneElement sceneElement in this.ActiveView.ElementSelectionSet.Selection)
         {
             if (sceneElement.IsSet(propertyReference2) == PropertyState.Set)
             {
                 sceneElement.RemoveValueAt(propertyReference1, this.ActiveAdorner.Index);
             }
         }
         this.isDraggedOff = false;
     }
     if (this.HasMouseMovedAfterDown)
     {
         this.CommitEditTransaction();
     }
     this.isDragInterrupted = false;
     return(base.OnDragEnd(dragStartPosition, dragEndPosition));
 }
 private void EnsurePropertyReferences()
 {
     if (!this.initialized)
     {
         this.initialized = true;
         if (!this.PlatformMetadata.IsCapabilitySet(PlatformCapability.SupportsCompositeTransform))
         {
             PropertyReference propertyReference  = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.TransformGroup.GetMember(MemberType.Property, "Children", MemberAccessTypes.Public)));
             PropertyReference propertyReference1 = propertyReference.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.TransformCollection, CanonicalTransformOrder.ScaleIndex));
             PropertyReference propertyReference2 = propertyReference.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.TransformCollection, CanonicalTransformOrder.SkewIndex));
             PropertyReference propertyReference3 = propertyReference.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.TransformCollection, CanonicalTransformOrder.RotateIndex));
             PropertyReference propertyReference4 = propertyReference.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.TransformCollection, CanonicalTransformOrder.TranslateIndex));
             this.scaleX          = propertyReference1.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.ScaleTransform.GetMember(MemberType.Property, "ScaleX", MemberAccessTypes.Public)));
             this.scaleY          = propertyReference1.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.ScaleTransform.GetMember(MemberType.Property, "ScaleY", MemberAccessTypes.Public)));
             this.scaleCenterX    = propertyReference1.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.ScaleTransform.GetMember(MemberType.Property, "CenterX", MemberAccessTypes.Public)));
             this.scaleCenterY    = propertyReference1.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.ScaleTransform.GetMember(MemberType.Property, "CenterY", MemberAccessTypes.Public)));
             this.skewX           = propertyReference2.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.SkewTransform.GetMember(MemberType.Property, "AngleX", MemberAccessTypes.Public)));
             this.skewY           = propertyReference2.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.SkewTransform.GetMember(MemberType.Property, "AngleY", MemberAccessTypes.Public)));
             this.skewCenterX     = propertyReference2.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.SkewTransform.GetMember(MemberType.Property, "CenterX", MemberAccessTypes.Public)));
             this.skewCenterY     = propertyReference2.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.SkewTransform.GetMember(MemberType.Property, "CenterY", MemberAccessTypes.Public)));
             this.rotationAngle   = propertyReference3.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.RotateTransform.GetMember(MemberType.Property, "Angle", MemberAccessTypes.Public)));
             this.rotationCenterX = propertyReference3.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.RotateTransform.GetMember(MemberType.Property, "CenterX", MemberAccessTypes.Public)));
             this.rotationCenterY = propertyReference3.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.RotateTransform.GetMember(MemberType.Property, "CenterY", MemberAccessTypes.Public)));
             this.translationX    = propertyReference4.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.TranslateTransform.GetMember(MemberType.Property, "X", MemberAccessTypes.Public)));
             this.translationY    = propertyReference4.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.TranslateTransform.GetMember(MemberType.Property, "Y", MemberAccessTypes.Public)));
         }
         else
         {
             PropertyReference propertyReference5 = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.CenterXProperty));
             PropertyReference propertyReference6 = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.CenterYProperty));
             this.scaleX          = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.ScaleXProperty));
             this.scaleY          = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.ScaleYProperty));
             this.scaleCenterX    = propertyReference5;
             this.scaleCenterY    = propertyReference6;
             this.skewX           = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.SkewXProperty));
             this.skewY           = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.SkewYProperty));
             this.skewCenterX     = propertyReference5;
             this.skewCenterY     = propertyReference6;
             this.rotationAngle   = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.RotationProperty));
             this.rotationCenterX = propertyReference5;
             this.rotationCenterY = propertyReference6;
             this.translationX    = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.TranslateXProperty));
             this.translationY    = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty(KnownProperties.TranslateYProperty));
         }
         this.renderTransform              = new PropertyReference(this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.FrameworkElement.GetMember(MemberType.Property, "RenderTransform", MemberAccessTypes.Public)) as ReferenceStep);
         this.renderTransformScaleX        = this.RenderTransform.Append(this.ScaleX);
         this.renderTransformScaleY        = this.RenderTransform.Append(this.ScaleY);
         this.renderTransformSkewX         = this.RenderTransform.Append(this.SkewX);
         this.renderTransformSkewY         = this.RenderTransform.Append(this.SkewY);
         this.renderTransformRotationAngle = this.RenderTransform.Append(this.rotationAngle);
         this.renderTransformTranslationX  = this.RenderTransform.Append(this.translationX);
         this.renderTransformTranslationY  = this.RenderTransform.Append(this.translationY);
         if (!this.PlatformMetadata.IsNullType(this.PlatformMetadata.ResolveType(PlatformTypes.Transform3DGroup)))
         {
             PropertyReference propertyReference7 = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.Transform3DGroup.GetMember(MemberType.Property, "Children", MemberAccessTypes.Public)));
             this.scaleTransform3DReference          = propertyReference7.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.Transform3DCollection, 1));
             this.rotateTransform3DReference         = propertyReference7.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.Transform3DCollection, 2));
             this.translateTransform3DReference      = propertyReference7.Append(IndexedClrPropertyReferenceStep.GetReferenceStep(this.PlatformMetadata, PlatformTypes.Transform3DCollection, 4));
             this.rotateTransform3DRotationReference = this.rotateTransform3DReference.Append((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.RotateTransform3D.GetMember(MemberType.Property, "Rotation", MemberAccessTypes.Public)));
         }
         this.brushRelativeTransformReference = new PropertyReference((ReferenceStep)this.PlatformMetadata.ResolveProperty((IPropertyId)PlatformTypes.Brush.GetMember(MemberType.Property, "RelativeTransform", MemberAccessTypes.Public)));
         this.brushScaleXReference            = this.BrushRelativeTransformReference.Append(this.ScaleX);
         this.brushScaleYReference            = this.BrushRelativeTransformReference.Append(this.ScaleY);
         this.brushScaleCenterXReference      = this.BrushRelativeTransformReference.Append(this.ScaleCenterX);
         this.brushScaleCenterYReference      = this.BrushRelativeTransformReference.Append(this.ScaleCenterY);
         this.brushSkewXReference             = this.BrushRelativeTransformReference.Append(this.SkewX);
         this.brushSkewYReference             = this.BrushRelativeTransformReference.Append(this.SkewY);
         this.brushSkewCenterXReference       = this.BrushRelativeTransformReference.Append(this.SkewCenterX);
         this.brushSkewCenterYReference       = this.BrushRelativeTransformReference.Append(this.SkewCenterY);
         this.brushRotationAngleReference     = this.BrushRelativeTransformReference.Append(this.RotationAngle);
         this.brushRotationCenterXReference   = this.BrushRelativeTransformReference.Append(this.RotationCenterX);
         this.brushRotationCenterYReference   = this.BrushRelativeTransformReference.Append(this.RotationCenterY);
         this.brushTranslationXReference      = this.BrushRelativeTransformReference.Append(this.TranslationX);
         this.brushTranslationYReference      = this.BrushRelativeTransformReference.Append(this.TranslationY);
     }
 }
Exemple #22
0
 public EmissiveMaterialEditor(SceneNodeObjectSet objectSet, PropertyReference materialReference)
     : base(objectSet, materialReference)
 {
     this.ColorProperty = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.EmissiveColorProperty), (AttributeCollection)null);
     this.BrushProperty = objectSet.CreateSceneNodeProperty(materialReference.Append(MaterialNode.EmissiveBrushProperty), (AttributeCollection)null);
 }
Exemple #23
0
        private void ApplyAnimationChanges(PathGeometry oldGeometry, PathGeometry newGeometry, PathAction action)
        {
            PropertyReference propertyReference1 = new PropertyReference(this.platformMetadata.ResolveProperty((IPropertyId)this.pathProperty) as ReferenceStep).Append(PathElement.FiguresProperty);
            ReferenceStep     step1 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, action.Figure);
            PropertyReference propertyReference2 = propertyReference1.Append(step1);

            propertyReference2.Append(PathElement.PathFigureSegmentsProperty);
            Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toRemove1             = new Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode>();
            Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> dictionary1           = new Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode>();
            Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> subdivisionProperties = new Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode>();

            foreach (PathStructureChange pathStructureChange in action.PathStructureChanges)
            {
                int index1 = action.Figure;
                int index2 = action.Figure;
                PropertyReference propertyReference3 = propertyReference2;
                PropertyReference propertyReference4 = propertyReference2;
                if (pathStructureChange.OldFigureIndex != -1)
                {
                    ReferenceStep step2 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, pathStructureChange.OldFigureIndex);
                    propertyReference3 = propertyReference1.Append(step2);
                    index1             = pathStructureChange.OldFigureIndex;
                }
                if (pathStructureChange.NewFigureIndex != -1)
                {
                    ReferenceStep step2 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, pathStructureChange.NewFigureIndex);
                    propertyReference4 = propertyReference1.Append(step2);
                    index2             = pathStructureChange.NewFigureIndex;
                }
                PropertyReference propertyReference5 = propertyReference3.Append(PathElement.PathFigureSegmentsProperty);
                PropertyReference propertyReference6 = propertyReference4.Append(PathElement.PathFigureSegmentsProperty);
                PropertyReference propertyReference7 = (PropertyReference)null;
                bool flag1 = false;
                if (pathStructureChange.OldSegmentIndex == PathStructureChange.StartPointIndex)
                {
                    propertyReference7 = propertyReference3.Append(PathElement.PathFigureStartPointProperty);
                    flag1 = true;
                }
                else if (pathStructureChange.OldSegmentIndex != PathStructureChange.DeletedPointIndex)
                {
                    ReferenceStep step2 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, pathStructureChange.OldSegmentIndex);
                    propertyReference7 = propertyReference5.Append(step2);
                    if (pathStructureChange.OldPointProperty != null)
                    {
                        ReferenceStep step3 = (ReferenceStep)PathDiff.GetReferenceStepFromWpf(this.targetElement.DesignerContext, this.targetElement.Platform, pathStructureChange.OldPointProperty.OwnerType, pathStructureChange.OldPointProperty);
                        propertyReference7 = propertyReference7.Append(step3);
                        flag1 = true;
                    }
                    else if (pathStructureChange.NewSegmentIndex == PathStructureChange.StartPointIndex)
                    {
                        if (pathStructureChange.OldSegmentIndex < oldGeometry.Figures[index1].Segments.Count)
                        {
                            propertyReference7 = propertyReference7.Append(this.LastPointProperty(oldGeometry.Figures[index1].Segments[pathStructureChange.OldSegmentIndex]));
                            flag1 = true;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                PropertyReference propertyReference8 = (PropertyReference)null;
                bool flag2 = false;
                if (pathStructureChange.NewSegmentIndex == PathStructureChange.StartPointIndex)
                {
                    propertyReference8 = propertyReference4.Append(PathElement.PathFigureStartPointProperty);
                    flag2 = true;
                }
                else if (pathStructureChange.NewSegmentIndex != PathStructureChange.DeletedPointIndex)
                {
                    ReferenceStep step2 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, pathStructureChange.NewSegmentIndex);
                    propertyReference8 = propertyReference6.Append(step2);
                    if (pathStructureChange.NewPointProperty != null)
                    {
                        ReferenceStep step3 = (ReferenceStep)PathDiff.GetReferenceStepFromWpf(this.targetElement.DesignerContext, this.targetElement.Platform, pathStructureChange.NewPointProperty.OwnerType, pathStructureChange.NewPointProperty);
                        propertyReference8 = propertyReference8.Append(step3);
                        flag2 = true;
                    }
                    else if (pathStructureChange.OldSegmentIndex == PathStructureChange.StartPointIndex)
                    {
                        if (pathStructureChange.NewSegmentIndex < newGeometry.Figures[index2].Segments.Count)
                        {
                            propertyReference8 = propertyReference8.Append(this.LastPointProperty(newGeometry.Figures[index2].Segments[pathStructureChange.NewSegmentIndex]));
                            flag2 = true;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toRemove2 = pathStructureChange.PathChangeType == PathChangeType.Move ? toRemove1 : (Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode>)null;
                Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> toAdd     = pathStructureChange.PathChangeType == PathChangeType.InferSubdivision ? subdivisionProperties : dictionary1;
                if (pathStructureChange.NewSegmentIndex == PathStructureChange.DeletedPointIndex)
                {
                    this.RemoveAnimation(propertyReference7, toRemove1);
                }
                else if (pathStructureChange.NewSegmentIndex == PathStructureChange.StartPointIndex || pathStructureChange.OldSegmentIndex == PathStructureChange.StartPointIndex)
                {
                    this.ChangeAnimationProperty(propertyReference7, propertyReference8, toAdd, toRemove2);
                    if (pathStructureChange.NewSegmentIndex == PathStructureChange.StartPointIndex && pathStructureChange.NewSegmentIndex != pathStructureChange.OldSegmentIndex)
                    {
                        this.RemoveAnimation(propertyReference8, toRemove1);
                    }
                }
                else if (pathStructureChange.OldSegmentIndex >= 0 && pathStructureChange.OldSegmentIndex < oldGeometry.Figures[index1].Segments.Count && (pathStructureChange.NewSegmentIndex >= 0 && pathStructureChange.NewSegmentIndex < newGeometry.Figures[index2].Segments.Count))
                {
                    if (oldGeometry.Figures[index1].Segments[pathStructureChange.OldSegmentIndex].GetType() != newGeometry.Figures[index2].Segments[pathStructureChange.NewSegmentIndex].GetType())
                    {
                        if (!flag1)
                        {
                            propertyReference7 = propertyReference7.Append(this.LastPointProperty(oldGeometry.Figures[index1].Segments[pathStructureChange.OldSegmentIndex]));
                        }
                        if (!flag2)
                        {
                            propertyReference8 = propertyReference8.Append(this.LastPointProperty(newGeometry.Figures[index2].Segments[pathStructureChange.NewSegmentIndex]));
                        }
                        this.ChangeAnimationProperty(propertyReference7, propertyReference8, toAdd, toRemove2);
                        if (pathStructureChange.OldPointProperty == null && pathStructureChange.PathChangeType == PathChangeType.Move)
                        {
                            ReferenceStep step2 = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, pathStructureChange.OldSegmentIndex);
                            this.RemoveAnimation(propertyReference5.Append(step2), toRemove1);
                        }
                    }
                    else if (pathStructureChange.OldPointProperty == null && pathStructureChange.NewPointProperty == null)
                    {
                        this.ChangeAnimationProperty(propertyReference7, propertyReference8, toAdd, toRemove2, false);
                    }
                    else
                    {
                        if (!flag1)
                        {
                            propertyReference7 = propertyReference7.Append(this.LastPointProperty(oldGeometry.Figures[index1].Segments[pathStructureChange.OldSegmentIndex]));
                        }
                        if (!flag2)
                        {
                            propertyReference8 = propertyReference8.Append(this.LastPointProperty(newGeometry.Figures[index2].Segments[pathStructureChange.NewSegmentIndex]));
                        }
                        this.ChangeAnimationProperty(propertyReference7, propertyReference8, toAdd, toRemove2);
                    }
                }
            }
            if (action.Action == PathActionType.InsertPoint)
            {
                this.SubdivideSegment(oldGeometry, action.Figure, action.Segment, action.PointIndex, action.Parameter, subdivisionProperties);
            }
            foreach (KeyValuePair <TimelineSceneNode, StoryboardTimelineSceneNode> keyValuePair in toRemove1)
            {
                keyValuePair.Value.Children.Remove(keyValuePair.Key);
            }
            foreach (KeyValuePair <TimelineSceneNode, StoryboardTimelineSceneNode> keyValuePair in dictionary1)
            {
                keyValuePair.Value.Children.Add(keyValuePair.Key);
            }
            Dictionary <StoryboardTimelineSceneNode, HashSet <TimelineSceneNode.PropertyNodePair> > dictionary2 = new Dictionary <StoryboardTimelineSceneNode, HashSet <TimelineSceneNode.PropertyNodePair> >();

            foreach (KeyValuePair <TimelineSceneNode, StoryboardTimelineSceneNode> keyValuePair in subdivisionProperties)
            {
                HashSet <TimelineSceneNode.PropertyNodePair> hashSet = (HashSet <TimelineSceneNode.PropertyNodePair>)null;
                if (!dictionary2.TryGetValue(keyValuePair.Value, out hashSet))
                {
                    hashSet = new HashSet <TimelineSceneNode.PropertyNodePair>();
                    dictionary2[keyValuePair.Value] = hashSet;
                }
                if (!hashSet.Contains(keyValuePair.Key.TargetElementAndProperty))
                {
                    hashSet.Add(keyValuePair.Key.TargetElementAndProperty);
                    keyValuePair.Value.Children.Add(keyValuePair.Key);
                }
            }
        }
Exemple #24
0
        private void FireSelectivePropertyChangedEvents(SceneUpdatePhaseEventArgs args)
        {
            SceneNode[] selectedNodes = this.designerContext.SelectionManager.SelectedNodes;
            DocumentNodeMarkerSortedList markerSortedList;

            if (selectedNodes == null)
            {
                markerSortedList = new DocumentNodeMarkerSortedList();
            }
            else
            {
                markerSortedList = new DocumentNodeMarkerSortedList(selectedNodes.Length);
                foreach (SceneNode sceneNode in selectedNodes)
                {
                    TextRangeElement          textRangeElement  = sceneNode as TextRangeElement;
                    BehaviorTriggerActionNode triggerActionNode = sceneNode as BehaviorTriggerActionNode;
                    if (textRangeElement != null)
                    {
                        this.FireAllPropertyChangedEvents(args);
                        return;
                    }
                    if (triggerActionNode != null && triggerActionNode.Parent != null)
                    {
                        markerSortedList.Add(triggerActionNode.Parent.DocumentNode.Marker);
                    }
                    markerSortedList.Add(sceneNode.DocumentNode.Marker);
                }
            }
            foreach (DocumentNodeChange documentNodeChange in args.DocumentChanges.DistinctChanges)
            {
                if (SceneView.HandleAnimationChanges(args.ViewModel, documentNodeChange, new SceneView.HandleAnimationChange(this.InvalidatePropertyFromAnimationChange)) == SceneView.AnimationChangeResult.InvalidateAll)
                {
                    this.FireAllPropertyChangedEvents(args);
                    return;
                }
            }
            if (this.designerContext.SelectionManager.SecondarySelectedNodes != null)
            {
                foreach (SceneNode sceneNode in this.designerContext.SelectionManager.SecondarySelectedNodes)
                {
                    if (sceneNode.DocumentNode.Marker != null)
                    {
                        markerSortedList.Add(sceneNode.DocumentNode.Marker);
                    }
                }
            }
            foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in args.DocumentChanges.Intersect((DocumentNodeMarkerSortedListBase)markerSortedList, DocumentNodeMarkerSortedListBase.Flags.ContainedBy))
            {
                Stack <ReferenceStep> input = DocumentNodeMarkerUtilities.PropertyReferencePath(args.DocumentChanges.MarkerAt(intersectionResult.LeftHandSideIndex), markerSortedList.MarkerAt(intersectionResult.RightHandSideIndex));
                if (input.Count > 0)
                {
                    PropertyReference propertyReference1 = new PropertyReference(input);
                    this.AddPropertyReferenceToSortedList(propertyReference1, this.changedPropertyReferences);
                    if (PlatformTypes.Style.IsAssignableFrom(propertyReference1.FirstStep.DeclaringTypeId))
                    {
                        int startIndex;
                        for (startIndex = 0; startIndex < propertyReference1.Count; ++startIndex)
                        {
                            if (PlatformTypes.Setter.IsAssignableFrom(propertyReference1.ReferenceSteps[startIndex].DeclaringTypeId))
                            {
                                ++startIndex;
                                break;
                            }
                        }
                        foreach (SceneChange sceneChange in SceneChange.ChangesOfType <SceneChange>(args.DocumentChanges, args.ViewModel.RootNode))
                        {
                            PropertyReferenceSceneChange referenceSceneChange = sceneChange as PropertyReferenceSceneChange;
                            if (referenceSceneChange != null && referenceSceneChange.PropertyChanged != null)
                            {
                                PropertyReference propertyReference2 = referenceSceneChange.PropertyChanged.Subreference(0);
                                if (startIndex < propertyReference1.Count)
                                {
                                    propertyReference2 = propertyReference2.Append(propertyReference1.Subreference(startIndex));
                                }
                                this.AddPropertyReferenceToSortedList(propertyReference2, this.changedPropertyReferences);
                            }
                        }
                    }
                }
            }
            this.FireSelectivePropertyChangedEventsWorker(args.DirtyViewState);
        }
Exemple #25
0
        private void UpdateTranslation()
        {
            SceneViewModel    viewModel          = this.ActiveView.ViewModel;
            PropertyReference propertyReference1 = this.GetBrushPropertyReference((SceneNode)this.EditingElement);

            if (propertyReference1 == null)
            {
                return;
            }
            Matrix matrixToAdornerLayer = this.ActiveAdorner.AdornerSet.GetTransformMatrixToAdornerLayer();

            this.EnsureEditTransaction();
            Point startPoint;
            Point endPoint;

            if (PlatformTypes.IsInstance(this.ActiveAdorner.PlatformBrush, PlatformTypes.GradientBrush, (ITypeResolver)this.EditingElement.ProjectContext) && this.ActiveAdorner.GetBrushEndpoints(out startPoint, out endPoint))
            {
                if (!this.HasMouseMovedAfterDown)
                {
                    this.CopyPrimaryBrushToSelection();
                }
                PropertyReference      propertyReference2     = propertyReference1.Append(GradientBrushNode.GradientStopsProperty);
                PropertyReference      propertyReference3     = propertyReference2.Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)viewModel.ProjectContext.Platform.Metadata, PlatformTypes.GradientStopCollection, this.ActiveAdorner.Index));
                PropertyReference      propertyReference4     = propertyReference3.Append(GradientStopNode.OffsetProperty);
                PropertyReference      propertyReference5     = propertyReference3.Append(GradientStopNode.ColorProperty);
                Matrix                 matrix                 = this.ActiveAdorner.GetCompleteBrushTransformMatrix(true) * this.ActiveView.GetComputedTransformToRoot(this.EditingElement);
                GradientStopCollection gradientStopCollection = (GradientStopCollection)this.EditingElement.GetComputedValueAsWpf(propertyReference2);
                GradientStop           gradientStop           = gradientStopCollection[this.ActiveAdorner.Index];
                Vector                 perpendicular;
                double                 num1   = GradientStopBehavior.VectorProjection(startPoint * matrix, endPoint * matrix, this.dragCurrentPosition, gradientStop.Offset, out perpendicular);
                double                 length = (perpendicular * matrixToAdornerLayer).Length;
                int index = this.ActiveAdorner.Index + 1;
                if (index >= gradientStopCollection.Count)
                {
                    index = this.ActiveAdorner.Index - 1;
                }
                if (length > 30.0 && !this.isDraggedOff && gradientStopCollection.Count > 2)
                {
                    this.isDraggedOff         = true;
                    this.ActiveAdorner.Hidden = true;
                    this.saveDraggedOffColor  = gradientStop.Color;
                    this.SetBrushValue(propertyReference5, (object)gradientStopCollection[index].Color);
                    this.SetBrushValue(propertyReference4, (object)gradientStopCollection[index].Offset);
                    this.Cursor = ToolCursors.MinusArrowCursor;
                }
                if (length <= 30.0 && this.isDraggedOff)
                {
                    this.isDraggedOff         = false;
                    this.ActiveAdorner.Hidden = false;
                    this.SetBrushValue(propertyReference5, (object)this.saveDraggedOffColor);
                    this.Cursor = this.ActiveAdorner.AdornerSet.GetCursor((IAdorner)this.ActiveAdorner);
                }
                if (!this.isDraggedOff)
                {
                    double num2 = RoundingHelper.RoundLength(gradientStop.Offset + num1);
                    if (num2 > 1.0)
                    {
                        num2 = 1.0;
                    }
                    else if (num2 < 0.0)
                    {
                        num2 = 0.0;
                    }
                    this.SetBrushValue(propertyReference4, (object)num2);
                }
                else
                {
                    this.SetBrushValue(propertyReference4, (object)gradientStopCollection[index].Offset);
                }
            }
            if (!this.HasMouseMovedAfterDown)
            {
                this.SetSelectedStopIndex(this.ActiveAdorner.Index);
            }
            this.UpdateEditTransaction();
        }
Exemple #26
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);
            }
        }
Exemple #27
0
        private void Rebuild()
        {
            PropertyValue             propertyValue     = this.DataContext as PropertyValue;
            PropertyReferenceProperty referenceProperty = (PropertyReferenceProperty)null;

            if (propertyValue != null)
            {
                referenceProperty = (PropertyReferenceProperty)propertyValue.get_ParentProperty();
            }
            if (referenceProperty == this.editingProperty)
            {
                return;
            }
            this.Unhook();
            this.editingProperty = referenceProperty;
            if (this.editingProperty == null)
            {
                return;
            }
            PropertyReference  reference          = this.editingProperty.Reference;
            SceneNodeObjectSet sceneNodeObjectSet = (SceneNodeObjectSet)this.editingProperty.ObjectSet;
            IPlatformMetadata  platformMetadata   = reference.PlatformMetadata;
            ReferenceStep      step1 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.TopProperty);
            ReferenceStep      step2 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.LeftProperty);
            ReferenceStep      step3 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.RightProperty);
            ReferenceStep      step4 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.BottomProperty);
            Type runtimeType         = platformMetadata.ResolveType(PlatformTypes.Thickness).RuntimeType;

            this.top    = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step1), step1.Attributes);
            this.left   = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step2), step2.Attributes);
            this.right  = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step3), step3.Attributes);
            this.bottom = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step4), step4.Attributes);
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.left, "Left");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.top, "Top");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.right, "Right");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.bottom, "Bottom");
            this.TopPropertyContainer.set_PropertyEntry((PropertyEntry)this.top);
            this.LeftPropertyContainer.set_PropertyEntry((PropertyEntry)this.left);
            this.RightPropertyContainer.set_PropertyEntry((PropertyEntry)this.right);
            this.BottomPropertyContainer.set_PropertyEntry((PropertyEntry)this.bottom);
        }
Exemple #28
0
        private void Rebuild()
        {
            PropertyValue             propertyValue     = this.DataContext as PropertyValue;
            PropertyReferenceProperty referenceProperty = (PropertyReferenceProperty)null;

            if (propertyValue != null)
            {
                referenceProperty = (PropertyReferenceProperty)propertyValue.get_ParentProperty();
            }
            if (referenceProperty == this.editingProperty)
            {
                return;
            }
            this.Unhook();
            this.editingProperty = referenceProperty;
            if (this.editingProperty == null)
            {
                return;
            }
            PropertyReference  reference          = this.editingProperty.Reference;
            SceneNodeObjectSet sceneNodeObjectSet = (SceneNodeObjectSet)this.editingProperty.ObjectSet;
            ITypeResolver      typeResolver       = (ITypeResolver)sceneNodeObjectSet.ProjectContext;

            ((PropertyEntry)this.editingProperty).get_PropertyType();
            IPropertyId propertyId1;
            IPropertyId propertyId2;

            if (PlatformTypes.Vector.IsAssignableFrom((ITypeId)this.editingProperty.PropertyTypeId))
            {
                propertyId1 = Point2DEditor.VectorXProperty;
                propertyId2 = Point2DEditor.VectorYProperty;
            }
            else if (PlatformTypes.Point.IsAssignableFrom((ITypeId)this.editingProperty.PropertyTypeId))
            {
                propertyId1 = Point2DEditor.PointXProperty;
                propertyId2 = Point2DEditor.PointYProperty;
            }
            else
            {
                Type nullableType = PlatformTypeHelper.GetNullableType(((PropertyEntry)this.editingProperty).get_PropertyType());
                if (nullableType == (Type)null)
                {
                    return;
                }
                IType type = typeResolver.GetType(nullableType);
                if (PlatformTypes.Vector.IsAssignableFrom((ITypeId)type))
                {
                    propertyId1 = Point2DEditor.VectorXProperty;
                    propertyId2 = Point2DEditor.VectorYProperty;
                }
                else
                {
                    if (!PlatformTypes.Point.IsAssignableFrom((ITypeId)type))
                    {
                        return;
                    }
                    propertyId1 = Point2DEditor.PointXProperty;
                    propertyId2 = Point2DEditor.PointYProperty;
                }
            }
            ReferenceStep step1 = (ReferenceStep)typeResolver.ResolveProperty(propertyId1);
            ReferenceStep step2 = (ReferenceStep)typeResolver.ResolveProperty(propertyId2);

            this.xProperty = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step1), step1.Attributes);
            this.yProperty = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step2), step2.Attributes);
            this.XPropertyContainer.set_PropertyEntry((PropertyEntry)this.xProperty);
            this.YPropertyContainer.set_PropertyEntry((PropertyEntry)this.yProperty);
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.xProperty, "X");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.yProperty, "Y");
        }
 protected override bool OnClickEnd(Point pointerPosition, int clickCount)
 {
     if (clickCount == 1 && this.ActiveAdorner != null && this.Tool is GradientBrushTool)
     {
         PropertyReference      propertyReference1     = this.GetBrushPropertyReference((SceneNode)this.EditingElement);
         GradientStopCollection gradientStopCollection = (GradientStopCollection)this.ActiveAdorner.GetBrushPropertyAsWpf(GradientBrushNode.GradientStopsProperty);
         Matrix matrix = this.ActiveAdorner.GetCompleteBrushTransformMatrix(true) * this.ActiveView.GetComputedTransformToRoot(this.EditingElement);
         Point  startPoint;
         Point  endPoint;
         if (gradientStopCollection == null || !this.ActiveAdorner.GetBrushEndpoints(out startPoint, out endPoint))
         {
             return(true);
         }
         Vector perpendicular;
         double offset = RoundingHelper.RoundLength(GradientStopBehavior.VectorProjection(startPoint * matrix, endPoint * matrix, this.dragStartPosition, 0.0, out perpendicular));
         int    index1 = 0;
         int    index2 = 0;
         for (int index3 = 0; index3 < gradientStopCollection.Count; ++index3)
         {
             if (gradientStopCollection[index1].Offset > offset || gradientStopCollection[index3].Offset > gradientStopCollection[index1].Offset && gradientStopCollection[index3].Offset <= offset)
             {
                 index1 = index3;
             }
             if (gradientStopCollection[index2].Offset < offset || gradientStopCollection[index3].Offset < gradientStopCollection[index2].Offset && gradientStopCollection[index3].Offset >= offset)
             {
                 index2 = index3;
             }
         }
         GradientStop gradientStop;
         if (gradientStopCollection.Count == 0)
         {
             gradientStop = new GradientStop(Colors.White, offset);
         }
         else
         {
             double num = (offset - gradientStopCollection[index1].Offset) / (gradientStopCollection[index2].Offset - gradientStopCollection[index1].Offset);
             if (num > 1.0)
             {
                 num = 1.0;
             }
             if (num < 0.0)
             {
                 num = 0.0;
             }
             gradientStop = new GradientStop(Color.FromArgb((byte)((double)gradientStopCollection[index1].Color.A * (1.0 - num) + (double)gradientStopCollection[index2].Color.A * num), (byte)((double)gradientStopCollection[index1].Color.R * (1.0 - num) + (double)gradientStopCollection[index2].Color.R * num), (byte)((double)gradientStopCollection[index1].Color.G * (1.0 - num) + (double)gradientStopCollection[index2].Color.G * num), (byte)((double)gradientStopCollection[index1].Color.B * (1.0 - num) + (double)gradientStopCollection[index2].Color.B * num)), offset);
         }
         this.CopyPrimaryBrushToSelection();
         PropertyReference propertyReference2 = propertyReference1.Append(GradientBrushNode.GradientStopsProperty);
         PropertyReference propertyReference3 = propertyReference2.Append(GradientStopCollectionNode.CountProperty);
         foreach (SceneElement sceneElement in this.ActiveView.ElementSelectionSet.Selection)
         {
             PropertyReference propertyReference4 = this.ActiveView.DesignerContext.PropertyManager.FilterProperty((SceneNode)sceneElement, propertyReference3);
             PropertyReference propertyReference5 = this.ActiveView.DesignerContext.PropertyManager.FilterProperty((SceneNode)sceneElement, propertyReference2);
             if (propertyReference4 != null && propertyReference5 != null)
             {
                 int index3 = (int)sceneElement.GetComputedValue(propertyReference4);
                 sceneElement.InsertValueAsWpf(propertyReference5, index3, (object)gradientStop);
             }
         }
         this.SetSelectedStopIndex(gradientStopCollection.Count);
         this.CommitEditTransaction();
     }
     return(base.OnClickEnd(pointerPosition, clickCount));
 }
Exemple #30
0
        private void SubdivideSegment(PathGeometry oldGeometry, int figure, int segment, int pointIndex, double parameter, Dictionary <TimelineSceneNode, StoryboardTimelineSceneNode> subdivisionProperties)
        {
            PropertyReference propertyReference1 = new PropertyReference(this.pathProperty).Append(PathElement.FiguresProperty).Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathFigureCollection, figure));
            PropertyReference propertyReference2 = propertyReference1.Append(PathElement.PathFigureSegmentsProperty);
            PropertyReference propertyReference3 = segment != oldGeometry.Figures[figure].Segments.Count ? propertyReference2.Append((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, segment)) : propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            PropertyReference propertyReference4;

            if (segment == 0)
            {
                propertyReference4 = propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            }
            else
            {
                ReferenceStep step = (ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((IPlatformMetadata)this.platformMetadata, PlatformTypes.PathSegmentCollection, segment - 1);
                propertyReference4 = propertyReference2.Append(step).Append(this.LastPointProperty(oldGeometry.Figures[figure].Segments[segment - 1]));
            }
            PropertyReference propertyReference5 = (PropertyReference)null;

            if (segment == oldGeometry.Figures[figure].Segments.Count - 1 && PathFigureUtilities.IsClosed(oldGeometry.Figures[figure]) && PathFigureUtilities.IsCloseSegmentDegenerate(oldGeometry.Figures[figure]))
            {
                propertyReference5 = propertyReference1.Append(PathElement.PathFigureStartPointProperty);
            }
            foreach (StoryboardTimelineSceneNode timelineSceneNode1 in this.targetElement.ViewModel.AnimationEditor.EnumerateStoryboardsForContainer(this.targetElement.StoryboardContainer))
            {
                Dictionary <double, List <KeyFrameSceneNode> > keyFrames1 = new Dictionary <double, List <KeyFrameSceneNode> >();
                foreach (KeyValuePair <TimelineSceneNode, StoryboardTimelineSceneNode> keyValuePair in subdivisionProperties)
                {
                    if (keyValuePair.Value == timelineSceneNode1)
                    {
                        KeyFrameAnimationSceneNode keyFrameNode = keyValuePair.Key as KeyFrameAnimationSceneNode;
                        if (keyFrameNode != null)
                        {
                            this.RecordKeyFrames(keyFrames1, keyFrameNode);
                        }
                    }
                }
                Dictionary <double, List <KeyFrameSceneNode> > keyFrames2 = new Dictionary <double, List <KeyFrameSceneNode> >();
                foreach (TimelineSceneNode timelineSceneNode2 in (IEnumerable <TimelineSceneNode>)timelineSceneNode1.Children)
                {
                    if (timelineSceneNode2.TargetElement == this.targetElement && timelineSceneNode2.TargetProperty != null && (propertyReference3.Equals((object)timelineSceneNode2.TargetProperty) || propertyReference3.IsPrefixOf(timelineSceneNode2.TargetProperty) || propertyReference4.Equals((object)timelineSceneNode2.TargetProperty) || propertyReference5 != null && propertyReference5.Equals((object)timelineSceneNode2.TargetProperty)))
                    {
                        KeyFrameAnimationSceneNode keyFrameNode = timelineSceneNode2 as KeyFrameAnimationSceneNode;
                        if (keyFrameNode != null)
                        {
                            this.RecordKeyFrames(keyFrames2, keyFrameNode);
                        }
                    }
                }
                foreach (KeyValuePair <double, List <KeyFrameSceneNode> > keyValuePair in keyFrames2)
                {
                    PathGeometry       path = oldGeometry.Clone();
                    PathGeometryEditor pathGeometryEditor = new PathGeometryEditor(path);
                    foreach (KeyFrameSceneNode keyFrameSceneNode in keyValuePair.Value)
                    {
                        PropertyReference propertyReference6 = this.targetElement.ViewModel.DefaultView.ConvertToWpfPropertyReference(keyFrameSceneNode.TargetProperty.Subreference(1));
                        object            valueToSet         = this.targetElement.ViewModel.DefaultView.ConvertToWpfValue(keyFrameSceneNode.Value);
                        propertyReference6.SetValue((object)path, valueToSet);
                    }
                    pathGeometryEditor.SubdivideSegment(figure, pointIndex, parameter);
                    List <KeyFrameSceneNode> list;
                    if (keyFrames1.TryGetValue(keyValuePair.Key, out list))
                    {
                        foreach (KeyFrameSceneNode keyFrameSceneNode in list)
                        {
                            object obj = this.targetElement.ViewModel.DefaultView.ConvertFromWpfValue(this.targetElement.ViewModel.DefaultView.ConvertToWpfPropertyReference(keyFrameSceneNode.TargetProperty.Subreference(1)).GetCurrentValue((object)path));
                            keyFrameSceneNode.Value = obj;
                        }
                    }
                }
            }
        }