4 using System.Collections.Generic;
6 using SiliconStudio.ActionStack;
7 using SiliconStudio.Presentation.ViewModel;
8 using SiliconStudio.Quantum;
11 namespace SiliconStudio.Presentation.Quantum
21 public override string Name {
get {
return nodeCommand.Name; } }
26 : base(serviceProvider, dirtiables)
28 if (nodeCommand == null)
throw new ArgumentNullException(
"nodeCommand");
29 if (modelContainer == null)
throw new ArgumentNullException(
"modelContainer");
30 this.identifier = identifier;
31 this.nodePath = nodePath;
32 this.modelContainer = modelContainer;
33 this.nodeCommand = nodeCommand;
35 ObservableNodePath = observableNodePath;
40 return nodePath.RootNode;
43 protected override UndoToken Redo(
object parameter,
bool creatingActionItem)
46 var viewModelNode = nodePath.GetNode();
47 if (viewModelNode == null)
48 throw new InvalidOperationException(
"Unable to retrieve the node on which to apply the redo operation.");
50 var newValue = nodeCommand.Invoke(viewModelNode.Content.Value, viewModelNode.Content.Descriptor, parameter, out token);
51 Refresh(viewModelNode, newValue);
57 var viewModelNode = nodePath.GetNode();
58 if (viewModelNode == null)
59 throw new InvalidOperationException(
"Unable to retrieve the node on which to apply the redo operation.");
61 var newValue = nodeCommand.Undo(viewModelNode.Content.Value, viewModelNode.Content.Descriptor, token);
62 Refresh(viewModelNode, newValue);
65 private void Refresh(
IModelNode modelNode,
object newValue)
67 var observableViewModel = service.ViewModelProvider(identifier);
69 if (modelNode == null)
throw new ArgumentNullException(
"modelNode");
70 var observableNode = observableViewModel != null ? observableViewModel.ResolveObservableModelNode(ObservableNodePath, nodePath.RootNode) : null;
73 if (observableNode != null)
75 observableNode.Value = newValue;
76 observableNode.Owner.NotifyNodeChanged(observableNode.Path);
80 modelNode.Content.Value = newValue;
81 modelContainer.UpdateReferences(modelNode);
A container used to store models and resolve references between them.
ModelNodeCommandWrapper(IViewModelServiceProvider serviceProvider, INodeCommand nodeCommand, string observableNodePath, ObservableViewModelIdentifier identifier, ModelNodePath nodePath, ModelContainer modelContainer, IEnumerable< IDirtiableViewModel > dirtiables)
A service provider class for view model objects.
CombineMode
An enum that describes what to do with a node or a command when combining view models.
A class that provides various services to ObservableViewModel objects
Base interface for node commands.
A base class to wrap one or multiple INodeCommand instances into a CancellableCommand.
override UndoToken Redo(object parameter, bool creatingActionItem)
Does or redoes the execution of the command.
The IModelNode interface represents a node in a model object. A model object is represented by a grap...
override void Undo(object parameter, UndoToken token)
Undoes the execution of the command.
Represents a token that stores an unique identifier and an object. This token should be generated by ...
A class describing the path of a node, relative to a root node. The path can cross references...