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); }
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); }