Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ViewModelActionItem.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 using System.Linq;
6 
7 using SiliconStudio.ActionStack;
8 
9 namespace SiliconStudio.Presentation.ViewModel.ActionStack
10 {
11  /// <summary>
12  /// An abstact class that inherits from <see cref="ActionItem"/> and can be used to manage actions related to an <see cref="IDirtiableViewModel"/>
13  /// </summary>
14  public abstract class ViewModelActionItem : ActionItem
15  {
16  private readonly List<IDirtiableViewModel> dirtiables;
17  private bool isSaved;
18 
19  /// <summary>
20  /// Initializes a new instance of the <see cref="ViewModelActionItem"/> class with the specified name and dirtiable object.
21  /// </summary>
22  /// <param name="name">The name of the action item.</param>
23  /// <param name="dirtiables">The dirtiable objects associated to this action item.</param>
24  protected ViewModelActionItem(string name, IEnumerable<IDirtiableViewModel> dirtiables)
25  : base(name)
26  {
27  if (dirtiables == null) throw new ArgumentNullException("dirtiables");
28  this.dirtiables = dirtiables.ToList();
29  }
30 
31  /// <summary>
32  /// Gets the dirtiable view modle associated to this object, or <c>null</c> if no dirtiable is associated.
33  /// </summary>
34  public IReadOnlyCollection<IDirtiableViewModel> Dirtiables { get { return dirtiables; } }
35 
36  /// <inheritdoc/>
37  public override bool IsSaved { get { return isSaved; } set { if (isSaved != value) { isSaved = value; dirtiables.ForEach(x => x.NotifyActionStackChange(ActionStackChange.Save)); } } }
38 
39  /// <inheritdoc/>
40  public override bool IsDone { get { return base.IsDone; } protected set { base.IsDone = value; dirtiables.ForEach(x => x.NotifyActionStackChange(ActionStackChange.UndoRedo)); } }
41  }
42 }
ViewModelActionItem(string name, IEnumerable< IDirtiableViewModel > dirtiables)
Initializes a new instance of the ViewModelActionItem class with the specified name and dirtiable obj...
Base class for action items.
Definition: ActionItem.cs:13
An abstact class that inherits from ActionItem and can be used to manage actions related to an IDirti...
This class represents a thread-safe stack of action items that can be undone/redone.
Definition: ActionStack.cs:12