Initial Commit

This commit is contained in:
2024-02-23 00:46:06 -05:00
commit 2bbedc0178
470 changed files with 46035 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace Microsoft.Research.DynamicDataDisplay.Common.UndoSystem
{
[DebuggerDisplay("Count = {Count}")]
public sealed class ActionStack
{
private readonly Stack<UndoAction> stack = new Stack<UndoAction>();
public void Push(UndoAction action)
{
stack.Push(action);
if (stack.Count == 1)
RaiseIsEmptyChanged();
}
public UndoAction Pop()
{
var action = stack.Pop();
if (stack.Count == 0)
RaiseIsEmptyChanged();
return action;
}
public int Count { get { return stack.Count; } }
public void Clear()
{
stack.Clear();
RaiseIsEmptyChanged();
}
public bool IsEmpty
{
get { return stack.Count == 0; }
}
private void RaiseIsEmptyChanged()
{
IsEmptyChanged.Raise(this);
}
public event EventHandler IsEmptyChanged;
}
}