forked from halad/PostSharp-Toolkits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UndoButton.cs
35 lines (31 loc) · 915 Bytes
/
UndoButton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Linq;
using System.Windows.Input;
namespace PostSharp.Toolkit.Domain.Controls
{
public class UndoButton : UndoRedoButtonBase
{
public UndoButton()
{
this.DefaultStyleKey = typeof(UndoButton);
}
protected override void SetOperations()
{
this.Operations = this.HistoryTracker.UndoOperations.Reverse().Take(this.MaxOperationsCount);
this.OnPropertyChanged("Operations");
}
public override ICommand RevertOperationCommand
{
get
{
return this.HistoryTracker != null ? new UndoRedoCommand(this, true) : null;
}
}
protected override void OnClickCore()
{
if (this.HistoryTracker != null && this.HistoryTracker.CanUndo())
{
this.HistoryTracker.Undo();
}
}
}
}