Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
CombinedValueChangedActionItem.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 
6 using SiliconStudio.ActionStack;
7 
8 namespace SiliconStudio.Presentation.Quantum
9 {
11  {
12  private readonly ObservableViewModelService serviceProvider;
13  private readonly string observableNodePath;
14  private readonly ObservableViewModelIdentifier identifier;
15 
16  internal CombinedValueChangedActionItem(string displayName, ObservableViewModelService serviceProvider, string observableNodePath, ObservableViewModelIdentifier identifier, IEnumerable<IActionItem> actionItems)
17  : base(displayName, actionItems)
18  {
19  if (serviceProvider == null) throw new ArgumentNullException("serviceProvider");
20  this.serviceProvider = serviceProvider;
21  this.observableNodePath = observableNodePath;
22  this.identifier = identifier;
23  }
24 
25  public string ObservableNodePath { get { return observableNodePath; } }
26 
27  /// <inheritdoc/>
28  protected override void UndoAction()
29  {
30  base.UndoAction();
31  Refresh();
32  }
33  /// <inheritdoc/>
34  protected override void RedoAction()
35  {
36  base.RedoAction();
37  Refresh();
38  }
39 
40  private void Refresh()
41  {
42  var observableViewModel = serviceProvider.ViewModelProvider != null ? serviceProvider.ViewModelProvider(identifier) : null;
43  if (observableViewModel != null)
44  {
45  var combinedNode = observableViewModel.ResolveObservableNode(observableNodePath) as CombinedObservableNode;
46  if (combinedNode != null)
47  {
48  combinedNode.Refresh();
49  combinedNode.Owner.NotifyNodeChanged(combinedNode.Path);
50  }
51  }
52  }
53  }
54 }
override void RedoAction()
Invoked by Redo after setting IsDone to true.
override void UndoAction()
Invoked by Undo after setting IsDone to true.
An ActionItem that represents a set of multiple action items.
A class that provides various services to ObservableViewModel objects