port from perforce
This commit is contained in:
36
intromat/Intromat/ViewModels/UndoItemGroup.cs
Normal file
36
intromat/Intromat/ViewModels/UndoItemGroup.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Intromat.Interfaces;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Intromat.ViewModels
|
||||
{
|
||||
public class UndoItemGroup : ReactiveObject, IUndoItem
|
||||
{
|
||||
public List<IUndoItem> Items = new();
|
||||
|
||||
public UndoItemGroup(IFile file)
|
||||
{
|
||||
File = file;
|
||||
}
|
||||
|
||||
public IFile File { get; }
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
item.Redo();
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
foreach (var item in Items.Reverse<IUndoItem>())
|
||||
item.Undo();
|
||||
}
|
||||
|
||||
public void Push(IUndoItem item)
|
||||
{
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user