4 using System.Collections.Generic;
6 using SiliconStudio.ActionStack;
7 using SiliconStudio.Core.Extensions;
8 using SiliconStudio.Presentation.Services;
10 namespace SiliconStudio.Presentation.ViewModel.
ActionStack
14 private readonly List<ViewModelActionItem> discardedActionItems =
new List<ViewModelActionItem>();
19 if (serviceProvider == null)
throw new ArgumentNullException(
"serviceProvider");
20 ServiceProvider = serviceProvider;
25 : base(capacity, initialActionsItems)
27 if (serviceProvider == null)
throw new ArgumentNullException(
"serviceProvider");
28 ServiceProvider = serviceProvider;
38 Dispatcher.Invoke(() => base.Add(item));
43 var savePoint = base.CreateSavePoint(markActionsAsSaved);
44 if (markActionsAsSaved)
46 discardedActionItems.ForEach(x => x.Dirtiables.ForEach(
y => y.DiscardActionItem(x)));
47 discardedActionItems.Clear();
54 base.OnActionItemsAdded(e);
55 RegisterActionItemsRecursively(e.ActionItems);
60 base.OnActionItemsDiscarded(e);
61 DiscardActionItemsRecursively(e.ActionItems, e.Type);
66 foreach (var actionItem
in actionItems)
69 if (viewModelActionItem != null)
71 viewModelActionItem.Dirtiables.ForEach(x => x.RegisterActionItem(viewModelActionItem));
74 if (aggregateActionItem != null)
76 RegisterActionItemsRecursively(aggregateActionItem.ActionItems);
83 foreach (var actionItem
in actionItems)
85 var viewModelActionItem = actionItem as ViewModelActionItem;
86 if (viewModelActionItem != null)
90 discardedActionItems.Add(viewModelActionItem);
94 viewModelActionItem.Dirtiables.ForEach(x => x.DiscardActionItem(viewModelActionItem));
98 if (aggregateActionItem != null)
100 DiscardActionItemsRecursively(aggregateActionItem.ActionItems, discardType);
ActionItemDiscardType
This enum describes how an action item is being discarded when the ActionStack.ActionItemsDiscarded e...
This class is an implementation of the ITransactionalActionStack interface.
Represents a save point marker in the undo/redo action items stack.
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float size_t y
A service provider class for view model objects.
ViewModelTransactionalActionStack(int capacity, IViewModelServiceProvider serviceProvider)
An abstact class that inherits from ActionItem and can be used to manage actions related to an IDirti...
override void OnActionItemsAdded(ActionItemsEventArgs< IActionItem > e)
Invoked whenever action items are added to the stack.
ViewModelTransactionalActionStack(int capacity, IViewModelServiceProvider serviceProvider, IEnumerable< IActionItem > initialActionsItems)
Base interface for action items.
override SavePoint CreateSavePoint(bool markActionsAsSaved)
Creates a save point at the current index of the action stack. Indicate whether to set the IActionIte...
override void Add(IActionItem item)
Adds an action item to the stack. Discards any action item that is currently undone. The action item to add to the stack.
Base interface of aggregate of action items.
override void OnActionItemsDiscarded(DiscardedActionItemsEventArgs< IActionItem > e)
Invoked whenever action items are discarded from the stack.
This class represents a thread-safe stack of action items that can be undone/redone.