private static void OnCut(Object sender, ExecutedRoutedEventArgs e) { EditView editor = sender as EditView; if (editor != null && editor.Document != null) { String targetText = String.Empty; if (editor.Selection.IsEmpty) { // 剪切整行 CopyWholeLine(editor); editor.SelectLine(); } else { // 剪切选中的文字 CopySelectedText(editor); } using (editor.Document.AutoUpdate()) { editor.RemoveSelection(); editor.Redraw(); } e.Handled = true; } }
/// <summary> /// 统一处理成删除selection,command是一个selection相关的命令。 /// </summary> /// <param name="command"></param> /// <returns></returns> private static ExecutedRoutedEventHandler RemoveHandler(RoutedUICommand command) { return((sender, e) => { if (e.Handled) { return; } EditView editor = sender as EditView; if (editor != null && editor.Document != null) { using (editor.Document.AutoUpdate()) { if (editor.Selection.IsEmpty) { command.Execute(e.Parameter, editor); } editor.RemoveSelection(); editor.Redraw(); } e.Handled = true; } }); }