Files
DynamicDataDisplay/Common/UndoSystem/DependencyPropertyChangedUndoAction.cs
2024-02-23 00:46:06 -05:00

43 lines
1.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
namespace Microsoft.Research.DynamicDataDisplay.Common.UndoSystem
{
public class DependencyPropertyChangedUndoAction : UndoAction
{
private readonly DependencyProperty property;
private readonly DependencyObject target;
private readonly object oldValue;
private readonly object newValue;
public DependencyPropertyChangedUndoAction(DependencyObject target, DependencyProperty property, object oldValue, object newValue)
{
this.target = target;
this.property = property;
this.oldValue = oldValue;
this.newValue = newValue;
}
public DependencyPropertyChangedUndoAction(DependencyObject target, DependencyPropertyChangedEventArgs e)
{
this.target = target;
this.property = e.Property;
this.oldValue = e.OldValue;
this.newValue = e.NewValue;
}
public override void Do()
{
target.SetValue(property, newValue);
}
public override void Undo()
{
target.SetValue(property, oldValue);
}
}
}