Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
IDirtiableViewModel.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.ViewModel.ActionStack;
7 
8 namespace SiliconStudio.Presentation.ViewModel
9 {
10  public enum ActionStackChange
11  {
12  Save,
13  UndoRedo,
14  }
15 
16  /// <summary>
17  /// An interface that represents an object which can be in a dirty state (modified since last save). This interface provides access to the dirty state and methods to
18  /// bind <see cref="ViewModelActionItem"/> in order to update the dirtiness when the action stack is reset to the save marker and/or modified again.
19  /// </summary>
20  public interface IDirtiableViewModel
21  {
22  /// <summary>
23  /// Gets the dirty state of this object.
24  /// </summary>
25  bool IsDirty { get; }
26 
27  /// <summary>
28  /// Raised when the <see cref="IsDirty"/> property has changed.
29  /// </summary>
30  event EventHandler<DirtinessChangedEventArgs> DirtinessChanged;
31 
32  /// <summary>
33  /// Register a <see cref="ViewModelActionItem"/> object to this dirtiable object. A registered action item can modify the dirty state when
34  /// its <see cref="ActionItem.IsSaved"/> and/or its <see cref="ActionItem.IsDone"/> properties change.
35  /// </summary>
36  /// <param name="actionItem">The action item to register.</param>
37  /// <exception cref="ArgumentException">The given action item is already registered.</exception>
38  void RegisterActionItem(ViewModelActionItem actionItem);
39 
40  /// <summary>
41  /// Discard a previously registered <see cref="ViewModelActionItem"/>.
42  /// </summary>
43  /// <param name="actionItem">The action item to discard.</param>
44  /// <exception cref="ArgumentException">The given action item is not registered.</exception>
45  void DiscardActionItem(ViewModelActionItem actionItem);
46 
47  /// <summary>
48  /// Notify the <see cref="IDirtiableViewModel"/> that a registered action item has been modified and thus the dirty state must be re-evaluated.
49  /// </summary>
50  /// <param name="change">The type of change that occurred.</param>
51  void NotifyActionStackChange(ActionStackChange change);
52 
53  /// <summary>
54  /// Register a <see cref="IDirtiableViewModel"/> as a dependency of the current object. When a registered dependency object becomes dirty, the current object also become dirty.
55  /// </summary>
56  /// <param name="dirtiable">The dirtiable object to register as a dependency.</param>
57  /// <exception cref="ArgumentException">The given dirtiable object is already registered.</exception>
58  void RegisterDirtiableDependency(IDirtiableViewModel dirtiable);
59 
60  /// <summary>
61  /// Unregister a <see cref="IDirtiableViewModel"/> as a dependency of the current object.
62  /// </summary>
63  /// <param name="dirtiable">The dirtiable object to unregister.</param>
64  /// <exception cref="ArgumentException">The given dirtiable object is not registered.</exception>
65  void UnregisterDirtiableDependency(IDirtiableViewModel dirtiable);
66  }
67 }
An interface that represents an object which can be in a dirty state (modified since last save)...
EventHandler< DirtinessChangedEventArgs > DirtinessChanged
Raised when the IsDirty property has changed.
An abstact class that inherits from ActionItem and can be used to manage actions related to an IDirti...