WPF/Undo
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
&tag(WPF, Undo);
*目次 [#c76f3e45]
#contents
*参考情報 [#ke8ad5f6]
-[[Notify Changed » Blog Archive » Using the Vi...
-[[Notify Changed » Blog Archive » Using MVVM t...
-[[danice/MVVMUndoRedo - GitHub:https://github.com/danice...
-[[WPF Undo/Redo Framework:http://wpfundoredo.codeplex.co...
*[[WPF Undo/Redo Framework:http://wpfundoredo.codeplex.co...
-サンプルはソースコードのダウンロードから入手可能(ダウン...
-UndoableActionBaseを継承したUndoablePropertyとDelegateUn...
-MVVM風にViewModelのプロパティの変更をUndoしたい場合は、...
#pre{{
private UndoableProperty<double> _sliderText;
public double SliderText
{
get { return _sliderText.GetValue(); }
set { _sliderText.SetValue(value); }
}
}}
-プロパティの変更はPropertyChangedで通知されるが、Undoは...
#pre{{
/// <summary>
/// Tells the context that an action has occurred.
/// </summary>
/// <param name="action">The action that was exec...
/// <param name="data">The data associated with t...
public void ActionExecuted(IUndoableAction action...
{
object possible = null;
if (action is IUndoableProperty && (this.Undo...
{
if ((DateTime.Now - lastModified).TotalMi...
{
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....
}
else
{
this.UndoStack.Push(new Tuple<string, object>(action....
}
this.RedoStack.Clear();
}
}}
-プロパティ以外のコマンドをUndoしたい場合次のようにする。...
#pre{{
public UndoableDelegateCommand<string, char> Type...
public char TypeCharacterCommand_Execute(string s)
{
var c = s.First();
this.SomeText += c;
return c;
}
public bool TypeCharacterCommand_CanExecute(strin...
{
if (string.IsNullOrEmpty(s))
{
return false;
}
var c = s.First();
if (char.IsDigit(c))
{
return true;
}
return false;
}
}}
終了行:
&tag(WPF, Undo);
*目次 [#c76f3e45]
#contents
*参考情報 [#ke8ad5f6]
-[[Notify Changed » Blog Archive » Using the Vi...
-[[Notify Changed » Blog Archive » Using MVVM t...
-[[danice/MVVMUndoRedo - GitHub:https://github.com/danice...
-[[WPF Undo/Redo Framework:http://wpfundoredo.codeplex.co...
*[[WPF Undo/Redo Framework:http://wpfundoredo.codeplex.co...
-サンプルはソースコードのダウンロードから入手可能(ダウン...
-UndoableActionBaseを継承したUndoablePropertyとDelegateUn...
-MVVM風にViewModelのプロパティの変更をUndoしたい場合は、...
#pre{{
private UndoableProperty<double> _sliderText;
public double SliderText
{
get { return _sliderText.GetValue(); }
set { _sliderText.SetValue(value); }
}
}}
-プロパティの変更はPropertyChangedで通知されるが、Undoは...
#pre{{
/// <summary>
/// Tells the context that an action has occurred.
/// </summary>
/// <param name="action">The action that was exec...
/// <param name="data">The data associated with t...
public void ActionExecuted(IUndoableAction action...
{
object possible = null;
if (action is IUndoableProperty && (this.Undo...
{
if ((DateTime.Now - lastModified).TotalMi...
{
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....
}
else
{
this.UndoStack.Push(new Tuple<string, object>(action....
}
this.RedoStack.Clear();
}
}}
-プロパティ以外のコマンドをUndoしたい場合次のようにする。...
#pre{{
public UndoableDelegateCommand<string, char> Type...
public char TypeCharacterCommand_Execute(string s)
{
var c = s.First();
this.SomeText += c;
return c;
}
public bool TypeCharacterCommand_CanExecute(strin...
{
if (string.IsNullOrEmpty(s))
{
return false;
}
var c = s.First();
if (char.IsDigit(c))
{
return true;
}
return false;
}
}}
ページ名: