private bool CanOptimizeAnimation(KeyFrameAnimationSceneNode nodeToTest) { TimelineSceneNode.PropertyNodePair elementAndProperty = nodeToTest.TargetElementAndProperty; if (elementAndProperty.PropertyReference == null || FromToAnimationSceneNode.GetFromToAnimationForType((ITypeId)elementAndProperty.PropertyReference.ValueTypeId, nodeToTest.ProjectContext) == null || (nodeToTest.KeyFrameCount != 1 || DesignTimeProperties.ExplicitAnimationProperty.Equals((object)elementAndProperty.PropertyReference[0]))) { return(false); } KeyFrameSceneNode keyFrameAtIndex = nodeToTest.GetKeyFrameAtIndex(0); Duration? nullable = nodeToTest.GetLocalOrDefaultValueAsWpf(TimelineSceneNode.DurationProperty) as Duration?; bool flag = !nullable.HasValue || nullable.Value == Duration.Automatic || nullable.Value.HasTimeSpan && nullable.Value.TimeSpan.TotalSeconds == keyFrameAtIndex.Time; if (keyFrameAtIndex.InterpolationType != KeyFrameInterpolationType.Easing || !flag) { return(false); } foreach (IMemberId memberId in (IEnumerable <IProperty>)((DocumentCompositeNode)nodeToTest.DocumentNode).Properties.Keys) { switch (memberId.Name) { case "Duration": case "TargetName": case "TargetProperty": case "BeginTime": case "IsAnimationProxy": case "KeyFrames": case "ShouldSerialize": continue; default: return(false); } } return(true); }
private void UpdateConflicts(TimelineSceneNode.PropertyNodePair propertyNodePair, Dictionary <TimelineSceneNode.PropertyNodePair, Dictionary <StateGroupModel, int> > conflictsCollection) { ConflictModel conflictModel = Enumerable.FirstOrDefault <ConflictModel>((IEnumerable <ConflictModel>) this.conflicts, (Func <ConflictModel, bool>)(conflict => conflict.TargetElementAndProperty.Equals((object)propertyNodePair))); if (conflictModel != null) { this.conflicts.Remove(conflictModel); } Dictionary <StateGroupModel, int> dictionary; if (!this.IsConflictListFull && conflictsCollection.TryGetValue(propertyNodePair, out dictionary) && (dictionary.Keys.Count > 1 && dictionary.ContainsKey(this))) { this.conflicts.Add(new ConflictModel(propertyNodePair, (IEnumerable <StateGroupModel>)dictionary.Keys)); } this.NotifyPropertyChanged("IsConflictListFull"); }
protected override List <TimelineSceneNode> GetAnimationsToCopy() { List <TimelineSceneNode> list = new List <TimelineSceneNode>(); if (this.ViewModel.ElementSelectionSet.Count == 0 && this.ViewModel.KeyFrameSelectionSet.Count > 0) { Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode> dictionary = new Dictionary <TimelineSceneNode.PropertyNodePair, KeyFrameAnimationSceneNode>(); foreach (KeyFrameSceneNode keyFrameSceneNode1 in this.ViewModel.KeyFrameSelectionSet.Selection) { if (!AnimationProxyManager.IsAnimationProxy((TimelineSceneNode)keyFrameSceneNode1.KeyFrameAnimation)) { KeyFrameSceneNode keyFrameSceneNode2 = this.ViewModel.GetSceneNode(keyFrameSceneNode1.DocumentNode.Clone(keyFrameSceneNode1.DocumentNode.DocumentRoot.DocumentContext)) as KeyFrameSceneNode; if (keyFrameSceneNode2 != null) { TimelineSceneNode.PropertyNodePair key1 = new TimelineSceneNode.PropertyNodePair(keyFrameSceneNode1.TargetElement, keyFrameSceneNode1.TargetProperty); KeyFrameAnimationSceneNode animationSceneNode; if (!dictionary.ContainsKey(key1)) { animationSceneNode = (KeyFrameAnimationSceneNode)KeyFrameAnimationSceneNode.Factory.Instantiate(this.ViewModel, (ITypeId)keyFrameSceneNode1.KeyFrameAnimation.Type); DocumentCompositeNode documentCompositeNode = (DocumentCompositeNode)animationSceneNode.DocumentNode; foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)((DocumentCompositeNode)keyFrameSceneNode1.KeyFrameAnimation.DocumentNode).Properties) { IProperty key2 = keyValuePair.Key; if (!keyFrameSceneNode1.KeyFrameAnimation.KeyFramesProperty.Equals((object)key2) && !DesignTimeProperties.ShouldSerializeProperty.Equals((object)key2) && !DesignTimeProperties.IsAnimationProxyProperty.Equals((object)key2)) { documentCompositeNode.Properties[(IPropertyId)key2] = keyValuePair.Value.Clone(documentCompositeNode.Context); } } dictionary.Add(key1, animationSceneNode); list.Add((TimelineSceneNode)animationSceneNode); } else { animationSceneNode = dictionary[key1]; } animationSceneNode.AddKeyFrame(keyFrameSceneNode2); } } else { FromToAnimationSceneNode animationSceneNode1 = this.ViewModel.AnimationProxyManager != null?this.ViewModel.AnimationProxyManager.GetAnimationForProxy(keyFrameSceneNode1.KeyFrameAnimation) : (FromToAnimationSceneNode)null; if (animationSceneNode1 != null) { FromToAnimationSceneNode animationSceneNode2 = this.ViewModel.GetSceneNode(animationSceneNode1.DocumentNode.Clone(animationSceneNode1.DocumentContext)) as FromToAnimationSceneNode; list.Add((TimelineSceneNode)animationSceneNode2); dictionary.Add(animationSceneNode1.TargetElementAndProperty, (KeyFrameAnimationSceneNode)null); } } } } else if (this.ViewModel.ElementSelectionSet.Count > 0 && this.ViewModel.KeyFrameSelectionSet.Count == 0) { foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>) this.SourceState.Storyboard.Children) { if (timelineSceneNode.ShouldSerialize) { SceneElement sceneElement = timelineSceneNode.TargetElement as SceneElement; if (sceneElement != null && this.ViewModel.ElementSelectionSet.IsSelected(sceneElement)) { list.Add(timelineSceneNode); } } } } return(list); }
public ConflictModel(TimelineSceneNode.PropertyNodePair propertyNode, IEnumerable <StateGroupModel> groups) { this.Groups = (IList <StateGroupModel>) new List <StateGroupModel>(groups); this.TargetElementAndProperty = propertyNode; }
public override DocumentNode GetLocalValueAsDocumentNode(SceneNodeProperty property, GetLocalValueFlags flags, out bool isMixed) { DocumentNode documentNode = (DocumentNode)null; bool flag = false; foreach (SceneNode sceneNode1 in this.Objects) { PropertyReference propertyReference1 = SceneNodeObjectSet.FilterProperty(sceneNode1, property.Reference); if (propertyReference1 != null) { DocumentNode other = (DocumentNode)null; if ((flags & GetLocalValueFlags.CheckKeyframes) != GetLocalValueFlags.None && sceneNode1.ViewModel.AnimationEditor.ActiveStoryboardTimeline != null && this.ShouldAllowAnimation) { SceneNode ancestor = (SceneNode)null; PropertyReference propertyReference2 = propertyReference1; SceneNode sceneNode2 = sceneNode1; if (this.FindAncestor(sceneNode1, out ancestor, ref propertyReference2, new Predicate <SceneNode>(SceneNodeObjectSetBase.IsAnimationParent))) { sceneNode2 = ancestor; } foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>)sceneNode1.ViewModel.AnimationEditor.ActiveStoryboardTimeline.Children) { TimelineSceneNode.PropertyNodePair elementAndProperty = timelineSceneNode.TargetElementAndProperty; if (elementAndProperty.SceneNode == sceneNode2 && elementAndProperty.PropertyReference != null) { PropertyReference propertyReference3 = SceneNodeObjectSet.FilterProperty(elementAndProperty.SceneNode, elementAndProperty.PropertyReference); if (propertyReference2.Equals((object)propertyReference3)) { KeyFrameAnimationSceneNode animationSceneNode1 = timelineSceneNode as KeyFrameAnimationSceneNode; FromToAnimationSceneNode animationSceneNode2 = timelineSceneNode as FromToAnimationSceneNode; if (animationSceneNode1 != null) { KeyFrameSceneNode keyFrameAtTime = animationSceneNode1.GetKeyFrameAtTime(sceneNode1.ViewModel.AnimationEditor.AnimationTime); if (keyFrameAtTime != null) { using ((flags & GetLocalValueFlags.Resolve) == GetLocalValueFlags.None ? this.ViewModel.ForceBaseValue() : (IDisposable)null) { other = keyFrameAtTime.ValueNode; break; } } else { break; } } else if (animationSceneNode2 != null) { double animationTime = sceneNode1.ViewModel.AnimationEditor.AnimationTime; using ((flags & GetLocalValueFlags.Resolve) == GetLocalValueFlags.None ? this.ViewModel.ForceBaseValue() : (IDisposable)null) { DocumentNodePath documentNodePath = (DocumentNodePath)null; if (animationTime == animationSceneNode2.Begin + animationSceneNode2.Duration) { documentNodePath = animationSceneNode2.GetLocalValueAsDocumentNode(animationSceneNode2.ToProperty); } else if (animationTime == animationSceneNode2.Begin) { documentNodePath = animationSceneNode2.GetLocalValueAsDocumentNode(animationSceneNode2.FromProperty); } other = documentNodePath != null ? documentNodePath.Node : (DocumentNode)null; break; } } else { break; } } } } } if (other == null) { if ((flags & GetLocalValueFlags.Resolve) != GetLocalValueFlags.None) { DocumentNodePath valueAsDocumentNode = sceneNode1.GetLocalValueAsDocumentNode(propertyReference1); if (valueAsDocumentNode != null) { other = valueAsDocumentNode.Node; } } else { other = (DocumentNode)sceneNode1.GetLocalValue(propertyReference1, PropertyContext.AsDocumentNodes); } } if (!flag) { if (other == null && (flags & GetLocalValueFlags.SkipCheckIfMixed) != GetLocalValueFlags.None) { isMixed = false; return((DocumentNode)null); } flag = true; documentNode = other; } else if (documentNode == null && other != null || documentNode != null && !documentNode.Equals(other)) { isMixed = true; return((DocumentNode)null); } } } isMixed = false; return(documentNode); }
public TimelineReferenceModel(StateGroupModel group, SceneNode stateOrTransition, TimelineSceneNode.PropertyNodePair propertyNode) { this.Group = group; this.TargetElementAndProperty = propertyNode; this.StateOrTransition = stateOrTransition; }