예제 #1
0
 public ExpandProxiesToken(AnimationProxyManager manager, StoryboardTimelineSceneNode storyboard)
 {
     this.manager    = manager;
     this.storyboard = storyboard;
     this.proxyTable = new Dictionary <AnimationProxyManager.TargetNamePropertyPair, AnimationProxyManager.AnimationProxyData>();
     this.manager.UpdateProxyTable(this.proxyTable, this.storyboard, AnimationProxyManager.AllowedChange.OnlyNonSerializing);
 }
예제 #2
0
        public void Update(SceneUpdateTypeFlags updateType, DocumentNodeChangeList damage, uint changeStamp)
        {
            if (this.activeStoryboard == null || damage.Count == 0 || ((int)this.lastUpdateChangeStamp == (int)changeStamp || !this.activeStoryboard.IsInDocument))
            {
                return;
            }
            this.lastUpdateChangeStamp = changeStamp;
            bool flag = false;

            foreach (DocumentNodeChange documentNodeChange in damage.DistinctChanges)
            {
                if (this.activeStoryboard.DocumentNode.Marker.Equals((object)documentNodeChange.ParentNode.Marker) || this.activeStoryboard.DocumentNode.Marker.Contains(documentNodeChange.ParentNode.Marker))
                {
                    if (documentNodeChange.IsPropertyChange && documentNodeChange.ParentNode.IsInDocument)
                    {
                        DocumentCompositeNode documentCompositeNode = documentNodeChange.ParentNode;
                        while (documentCompositeNode != null && !PlatformTypes.Timeline.IsAssignableFrom((ITypeId)documentCompositeNode.Type))
                        {
                            documentCompositeNode = documentCompositeNode.Parent;
                        }
                        FromToAnimationSceneNode animationSceneNode = this.viewModel.GetSceneNode((DocumentNode)documentCompositeNode) as FromToAnimationSceneNode;
                        AnimationProxyManager.AnimationProxyData animationProxyData;
                        if (animationSceneNode != null && animationSceneNode.IsOptimized && this.targetPathToProxyData.TryGetValue(new AnimationProxyManager.TargetNamePropertyPair((TimelineSceneNode)animationSceneNode), out animationProxyData))
                        {
                            animationProxyData.OptimizedAnimationPropertyChanged = true;
                        }
                    }
                    else if (documentNodeChange.Action == DocumentNodeChangeAction.Add && PlatformTypes.Timeline.IsAssignableFrom((ITypeId)documentNodeChange.NewChildNode.Type))
                    {
                        TimelineSceneNode timeline = this.viewModel.GetSceneNode(documentNodeChange.NewChildNode) as TimelineSceneNode;
                        AnimationProxyManager.AnimationProxyData animationProxyData;
                        if (timeline != null && AnimationProxyManager.IsOptimizedAnimation(timeline) && this.targetPathToProxyData.TryGetValue(new AnimationProxyManager.TargetNamePropertyPair(timeline), out animationProxyData))
                        {
                            animationProxyData.OptimizedAnimationAdded = true;
                        }
                    }
                    flag = true;
                }
            }
            if (!flag)
            {
                return;
            }
            if ((updateType & SceneUpdateTypeFlags.UndoRedo) == SceneUpdateTypeFlags.None && (updateType & SceneUpdateTypeFlags.Canceled) == SceneUpdateTypeFlags.None)
            {
                this.UpdateProxyTable(AnimationProxyManager.AllowedChange.Any);
            }
            else
            {
                this.UpdateProxyTable(AnimationProxyManager.AllowedChange.None);
            }
        }
예제 #3
0
            public ExpandAllProxiesToken(AnimationProxyManager manager)
            {
                this.manager = manager;
                SceneViewModel sceneViewModel = this.manager.viewModel;
                StoryboardTimelineSceneNode storyboardTimeline = sceneViewModel.ActiveStoryboardTimeline;

                foreach (StoryboardTimelineSceneNode storyboard in sceneViewModel.AnimationEditor.EnumerateStoryboardsForContainer(sceneViewModel.ActiveStoryboardContainer))
                {
                    if (storyboard != storyboardTimeline)
                    {
                        this.proxyTokens.Add(new AnimationProxyManager.ExpandProxiesToken(this.manager, storyboard));
                    }
                }
            }
예제 #4
0
        private void UpdateProxyTable(Dictionary <AnimationProxyManager.TargetNamePropertyPair, AnimationProxyManager.AnimationProxyData> proxyTable, StoryboardTimelineSceneNode storyboard, AnimationProxyManager.AllowedChange allowedChange)
        {
            if (allowedChange != AnimationProxyManager.AllowedChange.Any)
            {
                proxyTable.Clear();
            }
            List <KeyFrameAnimationSceneNode> list1 = new List <KeyFrameAnimationSceneNode>();

            foreach (TimelineSceneNode timeline in (IEnumerable <TimelineSceneNode>)storyboard.Children)
            {
                FromToAnimationSceneNode   animationSceneNode = timeline as FromToAnimationSceneNode;
                KeyFrameAnimationSceneNode nodeToTest         = timeline as KeyFrameAnimationSceneNode;
                if (animationSceneNode != null && animationSceneNode.IsOptimized || nodeToTest != null && nodeToTest.IsAnimationProxy)
                {
                    AnimationProxyManager.TargetNamePropertyPair key = new AnimationProxyManager.TargetNamePropertyPair(timeline);
                    if (key.TargetName != null)
                    {
                        AnimationProxyManager.AnimationProxyData animationProxyData;
                        if (!proxyTable.TryGetValue(key, out animationProxyData))
                        {
                            animationProxyData = new AnimationProxyManager.AnimationProxyData((FromToAnimationSceneNode)null, (KeyFrameAnimationSceneNode)null);
                            proxyTable[key]    = animationProxyData;
                        }
                        if (animationSceneNode != null)
                        {
                            animationProxyData.OptimizedAnimation = animationSceneNode;
                        }
                        else
                        {
                            animationProxyData.ProxyAnimation = nodeToTest;
                        }
                    }
                }
                else if (nodeToTest != null && this.CanOptimizeAnimation(nodeToTest))
                {
                    list1.Add(nodeToTest);
                }
            }
            if (allowedChange != AnimationProxyManager.AllowedChange.OnlyNonSerializing && allowedChange != AnimationProxyManager.AllowedChange.Any)
            {
                return;
            }
            if (allowedChange == AnimationProxyManager.AllowedChange.Any)
            {
                foreach (KeyFrameAnimationSceneNode proxyAnimation in list1)
                {
                    FromToAnimationSceneNode optimizedAnimation      = this.ConvertToOptimizedAnimation(proxyAnimation);
                    AnimationProxyManager.TargetNamePropertyPair key = new AnimationProxyManager.TargetNamePropertyPair((TimelineSceneNode)proxyAnimation);
                    AnimationProxyManager.AnimationProxyData     animationProxyData;
                    if (proxyTable.TryGetValue(key, out animationProxyData))
                    {
                        if (animationProxyData.OptimizedAnimation != null && animationProxyData.OptimizedAnimation.IsInDocument)
                        {
                            animationProxyData.OptimizedAnimation.ControllingStoryboard.Children.Remove((TimelineSceneNode)animationProxyData.OptimizedAnimation);
                        }
                        if (animationProxyData.ProxyAnimation != null && animationProxyData.ProxyAnimation.IsInDocument)
                        {
                            animationProxyData.ProxyAnimation.ControllingStoryboard.Children.Remove((TimelineSceneNode)animationProxyData.ProxyAnimation);
                        }
                        proxyTable.Remove(key);
                    }
                    proxyTable.Add(key, new AnimationProxyManager.AnimationProxyData(optimizedAnimation, proxyAnimation));
                }
            }
            List <AnimationProxyManager.TargetNamePropertyPair> list2 = new List <AnimationProxyManager.TargetNamePropertyPair>();

            foreach (KeyValuePair <AnimationProxyManager.TargetNamePropertyPair, AnimationProxyManager.AnimationProxyData> keyValuePair in proxyTable)
            {
                AnimationProxyManager.AnimationProxyData animationProxyData = keyValuePair.Value;
                int count = list2.Count;
                if (animationProxyData.ProxyAnimation != null && !keyValuePair.Key.Equals((object)new AnimationProxyManager.TargetNamePropertyPair((TimelineSceneNode)animationProxyData.ProxyAnimation)))
                {
                    animationProxyData.ProxyAnimation = (KeyFrameAnimationSceneNode)null;
                }
                if (animationProxyData.OptimizedAnimation != null && !keyValuePair.Key.Equals((object)new AnimationProxyManager.TargetNamePropertyPair((TimelineSceneNode)animationProxyData.OptimizedAnimation)))
                {
                    animationProxyData.OptimizedAnimation = (FromToAnimationSceneNode)null;
                }
                if (animationProxyData.OptimizedAnimation == null && animationProxyData.ProxyAnimation == null)
                {
                    list2.Add(keyValuePair.Key);
                }
                else if (animationProxyData.OptimizedAnimation == null || !animationProxyData.OptimizedAnimation.IsInDocument)
                {
                    if (allowedChange == AnimationProxyManager.AllowedChange.Any)
                    {
                        if (animationProxyData.ProxyAnimation != null && animationProxyData.ProxyAnimation.IsInDocument)
                        {
                            this.viewModel.AnimationEditor.RemoveAnimation(storyboard, (TimelineSceneNode)animationProxyData.ProxyAnimation);
                            if (animationProxyData.OptimizedAnimation != null && animationProxyData.OptimizedAnimation.IsInDocument)
                            {
                                animationProxyData.OptimizedAnimation.IsOptimized = false;
                            }
                        }
                        list2.Add(keyValuePair.Key);
                    }
                }
                else if (animationProxyData.ProxyWasUserDeleted && !animationProxyData.OptimizedAnimationAdded)
                {
                    if (allowedChange == AnimationProxyManager.AllowedChange.Any)
                    {
                        this.viewModel.AnimationEditor.RemoveAnimation(storyboard, (TimelineSceneNode)animationProxyData.OptimizedAnimation);
                        list2.Add(keyValuePair.Key);
                    }
                }
                else if (animationProxyData.ProxyAnimation == null || !animationProxyData.ProxyAnimation.IsInDocument)
                {
                    if (allowedChange == AnimationProxyManager.AllowedChange.OnlyNonSerializing || allowedChange == AnimationProxyManager.AllowedChange.Any)
                    {
                        animationProxyData.OptimizedAnimation.Invalidate();
                        if (animationProxyData.OptimizedAnimation.TargetElement != null)
                        {
                            KeyFrameAnimationSceneNode animationSceneNode = KeyFrameAnimationSceneNode.Factory.InstantiateWithTarget(this.viewModel, animationProxyData.OptimizedAnimation.TargetElement, animationProxyData.OptimizedAnimation.TargetProperty, animationProxyData.OptimizedAnimation.StoryboardContainer, KeyFrameAnimationSceneNode.GetKeyFrameAnimationForType(animationProxyData.OptimizedAnimation.AnimatedType, animationProxyData.OptimizedAnimation.ProjectContext));
                            animationSceneNode.AddKeyFrame(animationProxyData.OptimizedAnimation.Duration, animationProxyData.OptimizedAnimation.To);
                            KeyFrameSceneNode keyFrameAtIndex = animationSceneNode.GetKeyFrameAtIndex(0);
                            SceneNode.CopyPropertyValue((SceneNode)animationProxyData.OptimizedAnimation, animationProxyData.OptimizedAnimation.EasingFunctionProperty, (SceneNode)keyFrameAtIndex, keyFrameAtIndex.EasingFunctionProperty);
                            keyFrameAtIndex.ShouldSerialize     = false;
                            animationSceneNode.ShouldSerialize  = false;
                            animationSceneNode.IsAnimationProxy = true;
                            storyboard.Children.Insert(storyboard.Children.IndexOf((TimelineSceneNode)animationProxyData.OptimizedAnimation) + 1, (TimelineSceneNode)animationSceneNode);
                            animationProxyData.ProxyAnimation = animationSceneNode;
                        }
                    }
                }
                else if (!this.CanOptimizeAnimation(animationProxyData.ProxyAnimation))
                {
                    if (allowedChange == AnimationProxyManager.AllowedChange.Any)
                    {
                        this.RemoveOptimizedAndPromoteProxy(animationProxyData);
                        list2.Add(keyValuePair.Key);
                    }
                }
                else if ((!animationProxyData.OptimizedAnimation.IsOptimized || !AnimationProxyManager.CanFromToAnimationBeOptimized(animationProxyData.OptimizedAnimation)) && allowedChange == AnimationProxyManager.AllowedChange.Any)
                {
                    this.viewModel.AnimationEditor.RemoveAnimation(storyboard, (TimelineSceneNode)animationProxyData.ProxyAnimation);
                    animationProxyData.OptimizedAnimation.IsOptimized = false;
                    list2.Add(keyValuePair.Key);
                }
                if (count == list2.Count && allowedChange == AnimationProxyManager.AllowedChange.Any)
                {
                    if (!animationProxyData.OptimizedAnimationPropertyChanged && !animationProxyData.OptimizedAnimationAdded)
                    {
                        this.MovePropertiesFromProxyToOptimized(animationProxyData);
                    }
                    else
                    {
                        this.MovePropertiesFromOptimizedToProxy(animationProxyData);
                    }
                }
                animationProxyData.ResetUpdateState();
            }
            foreach (AnimationProxyManager.TargetNamePropertyPair key in list2)
            {
                proxyTable.Remove(key);
            }
        }