public StateModel(VisualStateSceneNode node) { if (node == null) { throw new ArgumentException("Cannot have a null node as an argument to StateModel constructor"); } this.sceneNode = node; }
private void AddState() { using (SceneEditTransaction editTransaction = this.sceneNode.ViewModel.CreateEditTransaction(StringTable.AddNewVisualStateUndoUnit)) { VisualStateSceneNode visualStateSceneNode = this.sceneNode.AddState(this.sceneNode.ViewModel.ActiveEditingContainer, ProjectNeutralTypes.VisualState.Name); editTransaction.Commit(); this.ModelManager.LastStateAdded = visualStateSceneNode; } }
public void Add() { VisualStateGroupSceneNode stateGroupSceneNode = this.toModel != null ? this.toModel.GroupNode : this.fromModel.GroupNode; using (SceneEditTransaction editTransaction = stateGroupSceneNode.ViewModel.CreateEditTransaction(StringTable.AddNewTransitionUndoUnit)) { VisualStateSceneNode fromNode = this.fromModel != null ? this.fromModel.SceneNode : (VisualStateSceneNode)null; VisualStateSceneNode toNode = this.toModel != null ? this.toModel.SceneNode : (VisualStateSceneNode)null; stateGroupSceneNode.AddTransition(fromNode, toNode, stateGroupSceneNode.DefaultTransitionDuration); editTransaction.Commit(); } }
protected virtual void ExecuteInternal(SceneNode targetStateOrStateGroup) { VisualStateSceneNode sourceState = this.SourceState; using (SceneEditTransaction editTransaction = this.ViewModel.CreateEditTransaction(this.UndoString, false)) { VisualStateSceneNode visualStateSceneNode = targetStateOrStateGroup as VisualStateSceneNode; VisualStateGroupSceneNode stateGroupSceneNode = targetStateOrStateGroup as VisualStateGroupSceneNode; if (stateGroupSceneNode != null) { visualStateSceneNode = stateGroupSceneNode.AddState(this.ViewModel.ActiveEditingContainer, sourceState.Name + StringTable.SceneModelDuplicateLabelSuffix); } if (visualStateSceneNode.Storyboard == null) { visualStateSceneNode.Storyboard = StoryboardTimelineSceneNode.Factory.Instantiate(this.ViewModel); } Dictionary <TimelineSceneNode.PropertyNodePair, List <TimelineSceneNode> > dictionary = new Dictionary <TimelineSceneNode.PropertyNodePair, List <TimelineSceneNode> >(); foreach (TimelineSceneNode timelineSceneNode in (IEnumerable <TimelineSceneNode>)visualStateSceneNode.Storyboard.Children) { if (!dictionary.ContainsKey(timelineSceneNode.TargetElementAndProperty)) { dictionary.Add(timelineSceneNode.TargetElementAndProperty, new List <TimelineSceneNode>(1)); } dictionary[timelineSceneNode.TargetElementAndProperty].Add(timelineSceneNode); } List <TimelineSceneNode> animationsToCopy = this.GetAnimationsToCopy(); bool flag = false; foreach (SceneNode sceneNode in animationsToCopy) { TimelineSceneNode timelineSceneNode1 = this.ViewModel.GetSceneNode(sceneNode.DocumentNode.Clone(this.ViewModel.DocumentRoot.DocumentContext)) as TimelineSceneNode; visualStateSceneNode.Storyboard.Children.Add(timelineSceneNode1); if (dictionary.ContainsKey(timelineSceneNode1.TargetElementAndProperty)) { flag = true; foreach (TimelineSceneNode timelineSceneNode2 in dictionary[timelineSceneNode1.TargetElementAndProperty]) { visualStateSceneNode.Storyboard.Children.Remove(timelineSceneNode2); } } } if (flag && this.ViewModel.DefaultView != null) { this.ViewModel.DefaultView.ShowBubble(StringTable.AnimationAutoDeletedWarningMessage, MessageBubbleType.Warning); } editTransaction.Commit(); } }
public CopySelectedStatePropertiesCommand(SceneViewModel viewModel, VisualStateSceneNode sourceState) : base(viewModel, sourceState) { }
public CopyStatePropertiesCommand(SceneViewModel viewModel, VisualStateSceneNode sourceState) : base(viewModel) { this.sourceState = sourceState; }