private static void OnEnter(Object sender, ExecutedRoutedEventArgs e) { if (e.Handled) { return; } EditView editor = sender as EditView; if (editor != null && editor.Document != null) { using (editor.Document.AutoUpdate()) { editor.InsertText(CommonUtilities.LineBreak); editor.Caret.RestartAnimation(); editor.Redraw(); } e.Handled = true; } }
private static void OnPaste(Object sender, ExecutedRoutedEventArgs e) { EditView editor = sender as EditView; if (editor != null && editor.Document != null) { IDataObject obj = null; try { obj = Clipboard.GetDataObject(); } catch (ExternalException) { return; } if (obj == null) { return; } String text = (String)obj.GetData(DataFormats.UnicodeText); text = CommonUtilities.NormalizeText(new StringReader(text)); if (!String.IsNullOrEmpty(text)) { using (editor.Document.AutoUpdate()) { if (obj.GetDataPresent(LineCopyFormat)) { // 粘贴整行 editor.InsertLine(text); editor.Redraw(); } else { editor.InsertText(text); editor.Redraw(); } } } e.Handled = true; } }