Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ActionItemViewModel.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 
5 using SiliconStudio.ActionStack;
6 using SiliconStudio.Presentation.Services;
7 
8 namespace SiliconStudio.Presentation.ViewModel.ActionStack
9 {
10  /// <summary>
11  /// This class is a view model for object that implements the <see cref="IActionItem"/> interface. It inherits from the <see cref="DispatcherViewModel"/> class.
12  /// </summary>
14  {
15  private readonly IActionItem actionItem;
16  private bool isSavePoint;
17  private bool isDone = true;
18  private bool isFrozen;
19 
20  /// <summary>
21  /// Initializes a new instance of the <see cref="ActionItemViewModel"/> class.
22  /// </summary>
23  /// <param name="serviceProvider">A service provider that can provide a <see cref="IDispatcherService"/> to use for this view model.</param>
24  /// <param name="actionItem">The action item linked to this view model.</param>
25  public ActionItemViewModel(IViewModelServiceProvider serviceProvider, IActionItem actionItem)
26  : base(serviceProvider)
27  {
28  if (actionItem == null)
29  throw new ArgumentNullException("actionItem");
30 
31  this.actionItem = actionItem;
32  DisplayName = actionItem.Name;
33  Refresh();
34  }
35 
36  /// <summary>
37  /// Gets the display name of this action item.
38  /// </summary>
39  public string DisplayName { get; private set; }
40 
41  /// <summary>
42  /// Gets whether this action item is currently done.
43  /// </summary>
44  public bool IsDone { get { return isDone; } private set { SetValue(ref isDone, value); } }
45 
46  /// <summary>
47  /// Gets whether this action item is the current save point.
48  /// </summary>
49  public bool IsSavePoint { get { return isSavePoint; } internal set { SetValue(ref isSavePoint, value); } }
50 
51  /// <summary>
52  /// Gets whether this action item has been frozen.
53  /// </summary>
54  public bool IsFrozen { get { return isFrozen; } private set { SetValue(ref isFrozen, value); } }
55 
56  /// <summary>
57  /// Gets the action item linked to this view model
58  /// </summary>
59  internal IActionItem ActionItem { get { return actionItem; } }
60 
61  /// <summary>
62  /// Refreshes the properties of this view model according to the values of the linked action item.
63  /// </summary>
64  internal void Refresh()
65  {
66  IsDone = actionItem.IsDone;
67  IsFrozen = actionItem.IsFrozen;
68  }
69  }
70 }
ActionItemViewModel(IViewModelServiceProvider serviceProvider, IActionItem actionItem)
Initializes a new instance of the ActionItemViewModel class.
Base class for action items.
Definition: ActionItem.cs:13
This abstract class is an implementation of ViewModelBase that uses a dispatcher to invoke OnProperty...
Base interface for action items.
Definition: IActionItem.cs:10
This class is a view model for object that implements the IActionItem interface. It inherits from the...
This class represents a thread-safe stack of action items that can be undone/redone.
Definition: ActionStack.cs:12