&tag(WPF/Undo);
private UndoableProperty<double> _sliderText;
public double SliderText
{
get { return _sliderText.GetValue(); }
set { _sliderText.SetValue(value); }
}
/// <summary>
/// Tells the context that an action has occurred.
/// </summary>
/// <param name="action">The action that was executed.</param>
/// <param name="data">The data associated with the action.</param>
public void ActionExecuted(IUndoableAction action, object data)
{
object possible = null;
if (action is IUndoableProperty && (this.UndoStack.Count > 0 && this.UndoStack.First().Item1 == action.Name))
{
if ((DateTime.Now - lastModified).TotalMilliseconds < (action as IUndoableProperty).BatchingTimeout)
{
possible = this.UndoStack.Pop().Item2;
}
else
{
this.lastModified = DateTime.Now;
}
}
else
{
this.lastModified = DateTime.Now;
}
if (possible == null)
{
this.UndoStack.Push(new Tuple<string, object>(action.Name, data));
}
else
{
this.UndoStack.Push(new Tuple<string, object>(action.Name, possible));
}
this.RedoStack.Clear();
}
public UndoableDelegateCommand<string, char> TypeCharacterCommand { get; set; }
public char TypeCharacterCommand_Execute(string s)
{
var c = s.First();
this.SomeText += c;
return c;
}
public bool TypeCharacterCommand_CanExecute(string s)
{
if (string.IsNullOrEmpty(s))
{
return false;
}
var c = s.First();
if (char.IsDigit(c))
{
return true;
}
return false;
}