예제 #1
0
        public bool SetHandoffKeyFrameEaseOutPoint(Point easeOutPoint)
        {
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;

            if (keyFrameCollection == null || keyFrameCollection.Count == 0)
            {
                return(false);
            }
            KeyFrameSceneNode keyFrame = keyFrameCollection[0];

            if (keyFrame.InterpolationType != KeyFrameInterpolationType.Spline)
            {
                return(this.ReplaceKeyFrame(keyFrame, KeyFrameInterpolationType.Spline, new KeySpline(easeOutPoint, new Point(1.0, 1.0))) != null);
            }
            if (keyFrame.KeySpline == null)
            {
                keyFrame.KeySpline = new KeySpline(easeOutPoint, new Point(1.0, 1.0));
            }
            else
            {
                KeySpline keySpline = new KeySpline(easeOutPoint, keyFrame.KeySpline.ControlPoint2);
                keyFrame.KeySpline = keySpline;
            }
            return(true);
        }
예제 #2
0
        public void MoveKeyFrame(double fromTime, double toTime)
        {
            int index = this.IndexOfKeyFrameAtTime(fromTime);

            if (index == -1)
            {
                return;
            }
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            KeyFrameSceneNode         unattachedKeyFrame = keyFrameCollection[index];

            this.ConvertKeySplineResourcesToLocalValues(unattachedKeyFrame);
            Point?nullable1 = new Point?();

            if (unattachedKeyFrame.CanSetEaseOutControlPoint)
            {
                nullable1 = new Point?(unattachedKeyFrame.EaseOutControlPoint);
            }
            Point?nullable2 = new Point?();

            if (index == keyFrameCollection.Count - 1)
            {
                if (keyFrameCollection.Count > 1)
                {
                    KeyFrameSceneNode keyFrameSceneNode = keyFrameCollection[index - 1];
                    if (keyFrameSceneNode.Time < toTime && keyFrameSceneNode.CanSetEaseOutControlPoint)
                    {
                        nullable2 = new Point?(keyFrameSceneNode.EaseOutControlPoint);
                    }
                }
                else if (unattachedKeyFrame.InterpolationType != KeyFrameInterpolationType.Discrete && unattachedKeyFrame.InterpolationType != KeyFrameInterpolationType.Easing)
                {
                    nullable2 = new Point?(this.GetHandoffKeyFrameEaseOutPoint());
                }
            }
            this.RemoveKeyFrame(fromTime);
            this.RemoveKeyFrame(toTime);
            KeyFrameSceneNode keyFrameSceneNode1 = (KeyFrameSceneNode)unattachedKeyFrame.ViewModel.GetSceneNode(unattachedKeyFrame.DocumentNode.Clone(unattachedKeyFrame.DocumentContext));

            keyFrameSceneNode1.Time = toTime;
            this.AddKeyFrame(keyFrameSceneNode1);
            if (nullable1.HasValue && keyFrameSceneNode1.CanSetEaseOutControlPoint)
            {
                keyFrameSceneNode1.EaseOutControlPoint = nullable1.Value;
            }
            if (!nullable2.HasValue)
            {
                return;
            }
            if (keyFrameCollection.Count > 1)
            {
                keyFrameCollection[index - 1].EaseOutControlPoint = nullable2.Value;
            }
            else
            {
                this.SetHandoffKeyFrameEaseOutPoint(nullable2.Value);
            }
        }
예제 #3
0
        public void RemoveKeyFrame(double time)
        {
            int index = this.IndexOfKeyFrameAtTime(time);

            if (index == -1)
            {
                return;
            }
            bool flag = this.ControllingState != null && this.ChangeAtIndexCanAffectTransition(index);
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            KeyFrameSceneNode         keyFrameSceneNode  = keyFrameCollection[index];
            Point?nullable = new Point?();

            this.ConvertKeySplineResourcesToLocalValues();
            if (index != 0)
            {
                nullable = new Point?(keyFrameCollection[index - 1].EaseOutControlPoint);
            }
            else if (keyFrameSceneNode.InterpolationType != KeyFrameInterpolationType.Discrete && keyFrameSceneNode.InterpolationType != KeyFrameInterpolationType.Easing)
            {
                nullable = new Point?(this.GetHandoffKeyFrameEaseOutPoint());
            }
            keyFrameCollection.Remove(keyFrameSceneNode);
            if (nullable.HasValue)
            {
                if (index != 0)
                {
                    KeyFrameSceneNode.SetEaseOutControlPoint(keyFrameCollection[index - 1], nullable.Value);
                }
                else if (keyFrameCollection.Count > 0)
                {
                    this.SetHandoffKeyFrameEaseOutPoint(nullable.Value);
                }
            }
            if (this.NaturalDuration == 0.001)
            {
                ;
            }
            if (!flag)
            {
                return;
            }
            object newValue = (object)null;

            if (keyFrameCollection.Count > 0)
            {
                if (index < keyFrameCollection.Count)
                {
                    newValue = keyFrameCollection[index].Value;
                }
                else if (index == keyFrameCollection.Count)
                {
                    newValue = keyFrameCollection[index - 1].Value;
                }
            }
            this.ControllingState.UpdateTransitionsForStateValueChange(this.TargetElementAndProperty, newValue);
        }
예제 #4
0
        public override bool ChangeCanAffectTransition(SceneNode node, PropertyReference changedProperty)
        {
            KeyFrameSceneNode keyFrameSceneNode = node as KeyFrameSceneNode;

            if (keyFrameSceneNode != null)
            {
                return(this.ChangeAtIndexCanAffectTransition(this.KeyFrameCollection.IndexOf(keyFrameSceneNode)));
            }
            return(false);
        }
예제 #5
0
        public KeyFrameSceneNode GetNextKeyFrame(KeyFrameSceneNode keyFrame)
        {
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            int num = keyFrameCollection.IndexOf(keyFrame);

            if (num < keyFrameCollection.Count - 1)
            {
                return(keyFrameCollection[num + 1]);
            }
            return((KeyFrameSceneNode)null);
        }
예제 #6
0
 public static KeyFrameSceneNode EnsureCanSetEaseInControlPoint(KeyFrameSceneNode node)
 {
     if (node.CanSetEaseInControlPoint)
     {
         return(node);
     }
     if (node.KeyFrameAnimation == null)
     {
         return((KeyFrameSceneNode)null);
     }
     return(node.KeyFrameAnimation.ReplaceKeyFrame(node, KeyFrameInterpolationType.Spline, (KeySpline)null));
 }
예제 #7
0
        int IComparable.CompareTo(object toCompare)
        {
            KeyFrameSceneNode keyFrameSceneNode = toCompare as KeyFrameSceneNode;

            if (keyFrameSceneNode == null)
            {
                return(1);
            }
            if (this.Time == keyFrameSceneNode.Time)
            {
                return(this.KeyFrameAnimation.CompareTo((object)keyFrameSceneNode.KeyFrameAnimation));
            }
            return(this.Time.CompareTo(keyFrameSceneNode.Time));
        }
예제 #8
0
        private void ConvertKeySplineResourcesToLocalValues(KeyFrameSceneNode unattachedKeyFrame)
        {
            bool flag = false;

            if (unattachedKeyFrame != null)
            {
                flag = this.ConvertKeyFrameKeysplineToLocalValue(unattachedKeyFrame);
            }
            foreach (KeyFrameSceneNode keyFrame in (IEnumerable <KeyFrameSceneNode>) this.KeyFrameCollection)
            {
                flag = flag || this.ConvertKeyFrameKeysplineToLocalValue(keyFrame);
            }
            if (!flag || !this.IsInDocument)
            {
                return;
            }
            this.ViewModel.DefaultView.ShowBubble(StringTable.KeySplineResourceResetWarningMessage, MessageBubbleType.Warning);
        }
예제 #9
0
        internal KeyFrameSceneNode ReplaceKeyFrame(KeyFrameSceneNode keyFrame, KeyFrameInterpolationType interpolationType, KeySpline keySpline)
        {
            ITypeId keyFrameType = this.GetKeyFrameType(interpolationType);

            if (keyFrameType == null)
            {
                return((KeyFrameSceneNode)null);
            }
            KeyFrameSceneNode keyFrameSceneNode = (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, keyFrameType);

            keyFrameSceneNode.Time = keyFrame.Time;
            using (keyFrame.ViewModel.ForceBaseValue())
                keyFrameSceneNode.ValueNode = keyFrame.ValueNode.Clone(keyFrame.ValueNode.Context);
            if (interpolationType == KeyFrameInterpolationType.Spline)
            {
                keyFrameSceneNode.KeySpline = keySpline;
            }
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;

            keyFrameCollection[keyFrameCollection.IndexOf(keyFrame)] = keyFrameSceneNode;
            return(keyFrameSceneNode);
        }
예제 #10
0
        public static bool SetEaseOutControlPoint(KeyFrameSceneNode node, Point newEaseOut)
        {
            bool flag = false;

            if (node.EaseOutControlPoint == newEaseOut)
            {
                return(false);
            }
            if (!node.CanSetEaseOutControlPoint)
            {
                KeyFrameSceneNode keyFrame = node.KeyFrameAnimation != null?node.KeyFrameAnimation.GetNextKeyFrame(node) : (KeyFrameSceneNode)null;

                if (keyFrame != null)
                {
                    flag = node.KeyFrameAnimation.ReplaceKeyFrame(keyFrame, KeyFrameInterpolationType.Spline, (KeySpline)null) != null;
                }
            }
            if (node.CanSetEaseOutControlPoint)
            {
                node.EaseOutControlPoint = newEaseOut;
            }
            return(flag);
        }
예제 #11
0
 protected override void SetTimeRegionCore(TimeRegionChangeDetails details, double scaleFactor, double originalRegionBegin, double originalRegionEnd, double finalRegionBegin, double finalRegionEnd)
 {
     if ((details & TimeRegionChangeDetails.ToZero) != TimeRegionChangeDetails.None)
     {
         IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
         if (keyFrameCollection.Count > 0)
         {
             for (int index = keyFrameCollection.Count - 1; index > 0; --index)
             {
                 this.RemoveKeyFrame(keyFrameCollection[index].Time);
             }
             keyFrameCollection[0].Time = finalRegionBegin;
         }
     }
     if ((details & TimeRegionChangeDetails.Scale) != TimeRegionChangeDetails.None && (details & TimeRegionChangeDetails.FromZero) == TimeRegionChangeDetails.None)
     {
         IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
         for (int index = 0; index < keyFrameCollection.Count; ++index)
         {
             KeyFrameSceneNode keyFrameSceneNode = keyFrameCollection[index];
             keyFrameSceneNode.Time = (keyFrameSceneNode.Time - originalRegionBegin) * scaleFactor + finalRegionBegin;
         }
     }
     else
     {
         if ((details & TimeRegionChangeDetails.Translate) == TimeRegionChangeDetails.None)
         {
             return;
         }
         double num = finalRegionBegin - originalRegionBegin;
         IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
         for (int index = 0; index < keyFrameCollection.Count; ++index)
         {
             keyFrameCollection[index].Time += num;
         }
     }
 }
예제 #12
0
        private bool ConvertKeyFrameKeysplineToLocalValue(KeyFrameSceneNode keyFrame)
        {
            IPropertyId keySplineProperty = keyFrame.KeySplineProperty;

            if (keySplineProperty != null)
            {
                DocumentCompositeNode documentCompositeNode = keyFrame.DocumentNode as DocumentCompositeNode;
                if (documentCompositeNode != null)
                {
                    DocumentNode expression = documentCompositeNode.Properties[keySplineProperty];
                    if (expression != null && expression.Type.IsResource)
                    {
                        DocumentNode documentNode = new ExpressionEvaluator(this.ViewModel.DocumentRootResolver).EvaluateExpression(this.ViewModel.ActiveEditingContainerPath, expression);
                        if (documentNode != null)
                        {
                            KeySpline keySpline = (KeySpline)this.ViewModel.CreateInstance(new DocumentNodePath(documentNode, documentNode));
                            keyFrame.KeySpline = keySpline;
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
예제 #13
0
        public void ReverseKeyFrames(double startTime, double endTime)
        {
            if (this.KeyFrameCount == 0)
            {
                return;
            }
            this.ConvertKeySplineResourcesToLocalValues();
            int capacity = 0;
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            int index1 = 0;

            while (index1 < keyFrameCollection.Count && keyFrameCollection[index1].Time < startTime)
            {
                ++index1;
            }
            int index2 = index1;

            for (; index1 < keyFrameCollection.Count && keyFrameCollection[index1].Time <= endTime; ++index1)
            {
                ++capacity;
            }
            if (capacity == 0)
            {
                return;
            }
            bool flag = startTime == 0.0 && keyFrameCollection[0].Time != 0.0;

            if (flag)
            {
                ++capacity;
            }
            List <KeyFrameSceneNode> list1 = new List <KeyFrameSceneNode>(capacity);
            List <Point?>            list2 = new List <Point?>(capacity);

            if (flag)
            {
                KeyFrameSceneNode keyFrameSceneNode = this.IsDiscreteOnly ? (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Discrete)) : (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Spline));
                keyFrameSceneNode.Time = 0.0;
                SceneElement sceneElement = this.TargetElement as SceneElement;
                IViewObject  viewObject   = sceneElement.ViewTargetElement;
                if (PlatformTypes.Viewport3D.Equals((object)viewObject.GetIType((ITypeResolver)this.ProjectContext)))
                {
                    viewObject = sceneElement.ViewObject;
                }
                PropertyReference propertyReference = DesignTimeProperties.GetAppliedShadowPropertyReference(this.TargetProperty, (ITypeId)this.Type);
                keyFrameSceneNode.Value = viewObject.GetBaseValue(propertyReference);
                list1.Add(keyFrameSceneNode);
                if (keyFrameCollection[0].InterpolationType == KeyFrameInterpolationType.Spline && keyFrameCollection[0].KeySpline != null)
                {
                    list2.Add(new Point?(keyFrameCollection[0].KeySpline.ControlPoint1));
                }
                else if (!this.IsDiscreteOnly)
                {
                    list2.Add(new Point?(new Point()));
                }
                else
                {
                    list2.Add(new Point?());
                }
            }
            int num1 = 0;

            while (list1.Count < capacity)
            {
                if (keyFrameCollection[index2].InterpolationType != KeyFrameInterpolationType.Discrete)
                {
                    list2.Add(new Point?(keyFrameCollection[index2].EaseOutControlPoint));
                }
                else
                {
                    list2.Add(new Point?());
                }
                list1.Add(keyFrameCollection[index2]);
                keyFrameCollection.RemoveAt(index2);
                ++num1;
            }
            for (int index3 = 0; index3 < list1.Count; ++index3)
            {
                KeyFrameSceneNode keyFrameSceneNode1 = list1[index3];
                Point?            nullable1          = list2[index3];
                Point?            nullable2          = new Point?();
                if (keyFrameSceneNode1.InterpolationType != KeyFrameInterpolationType.Discrete)
                {
                    nullable2 = new Point?(keyFrameSceneNode1.EaseInControlPoint);
                }
                double            num2 = endTime - (keyFrameSceneNode1.Time - startTime);
                KeyFrameSceneNode node;
                if (nullable1.HasValue)
                {
                    KeyFrameSceneNode keyFrameSceneNode2 = (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Spline));
                    keyFrameSceneNode2.ValueNode = keyFrameSceneNode1.ValueNode.Clone(keyFrameSceneNode2.DocumentContext);
                    node = keyFrameSceneNode2;
                    node.EaseInControlPoint = new Point(1.0 - nullable1.Value.X, 1.0 - nullable1.Value.Y);
                }
                else
                {
                    KeyFrameSceneNode keyFrameSceneNode2 = (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Discrete));
                    keyFrameSceneNode2.ValueNode = keyFrameSceneNode1.ValueNode.Clone(keyFrameSceneNode2.DocumentContext);
                    node = keyFrameSceneNode2;
                }
                node.Time = num2;
                keyFrameCollection.Insert(index2, node);
                if (nullable2.HasValue)
                {
                    Point newEaseOut = new Point(1.0 - nullable2.Value.X, 1.0 - nullable2.Value.Y);
                    KeyFrameSceneNode.SetEaseOutControlPoint(node, newEaseOut);
                }
            }
            if (!flag)
            {
                return;
            }
            Point?nullable = new Point?(keyFrameCollection[0].EaseOutControlPoint);

            if (nullable.HasValue)
            {
                this.SetHandoffKeyFrameEaseOutPoint(nullable.Value);
            }
            this.RemoveKeyFrame(0.0);
        }
예제 #14
0
        public void AddKeyFrame(KeyFrameSceneNode keyFrameSceneNode)
        {
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            double time = keyFrameSceneNode.Time;

            this.ConvertKeySplineResourcesToLocalValues(keyFrameSceneNode);
            Point?nullable = new Point?();
            int   index    = 0;

            while (keyFrameCollection.Count > index && keyFrameCollection[index].Time < time)
            {
                ++index;
            }
            KeyFrameSceneNode keyFrameAtTime = this.GetKeyFrameAtTime(time);

            if (keyFrameAtTime != null)
            {
                int num = this.IndexOfKeyFrameAtTime(time);
                if (num != 0)
                {
                    nullable = new Point?(keyFrameCollection[num - 1].EaseOutControlPoint);
                }
                else if (keyFrameCollection[0].InterpolationType != KeyFrameInterpolationType.Discrete)
                {
                    nullable = new Point?(this.GetHandoffKeyFrameEaseOutPoint());
                }
                keyFrameCollection.Remove(keyFrameAtTime);
            }
            else if (index > 0)
            {
                nullable = new Point?(keyFrameCollection[index - 1].EaseOutControlPoint);
            }
            else if (keyFrameCollection.Count > 0 && keyFrameCollection[0].InterpolationType != KeyFrameInterpolationType.Discrete && keyFrameCollection[0].InterpolationType != KeyFrameInterpolationType.Easing)
            {
                nullable = new Point?(this.GetHandoffKeyFrameEaseOutPoint());
            }
            keyFrameCollection.Insert(index, keyFrameSceneNode);
            if (index != keyFrameCollection.Count - 1 && keyFrameSceneNode.CanSetEaseOutControlPoint)
            {
                keyFrameSceneNode.EaseOutControlPoint = new Point();
            }
            if (nullable.HasValue)
            {
                if (index != 0)
                {
                    if (keyFrameCollection[index - 1].CanSetEaseOutControlPoint)
                    {
                        keyFrameCollection[index - 1].EaseOutControlPoint = nullable.Value;
                    }
                }
                else
                {
                    this.SetHandoffKeyFrameEaseOutPoint(nullable.Value);
                }
            }
            if (this.ControllingState == null || !this.ChangeAtIndexCanAffectTransition(index) && !this.NoAutoTransitionsProvided)
            {
                return;
            }
            this.ControllingState.UpdateTransitionsForStateValueChange(this.TargetElementAndProperty, keyFrameSceneNode.Value);
        }