static ExecutedRoutedEventHandler OnDelete(RoutedUICommand selectingCommand)
 {
     return((target, args) => {
         TextArea textArea = GetTextArea(target);
         if (textArea != null && textArea.Document != null)
         {
             // call BeginUpdate before running the 'selectingCommand'
             // so that undoing the delete does not select the deleted character
             using (textArea.Document.RunUpdate()) {
                 if (textArea.Selection.IsEmpty)
                 {
                     TextViewPosition oldCaretPosition = textArea.Caret.Position;
                     selectingCommand.Execute(args.Parameter, textArea);
                     bool hasSomethingDeletable = false;
                     foreach (ISegment s in textArea.Selection.Segments)
                     {
                         if (textArea.GetDeletableSegments(s).Length > 0)
                         {
                             hasSomethingDeletable = true;
                             break;
                         }
                     }
                     if (!hasSomethingDeletable)
                     {
                         // If nothing in the selection is deletable; then reset caret+selection
                         // to the previous value. This prevents the caret from moving through read-only sections.
                         textArea.Caret.Position = oldCaretPosition;
                         textArea.Selection = Selection.Empty;
                     }
                 }
                 textArea.RemoveSelectedText();
             }
             textArea.Caret.BringCaretToView();
             args.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;
         }
     });
 }
Ejemplo n.º 3
0
 public void Execute()
 {
     _command.Execute(null, _source);
 }
 private void DataGrid_Keys_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     InstallKey.Execute(null, this);
     e.Handled = true;
 }
Ejemplo n.º 5
0
 void Execute(RoutedUICommand command)
 {
     command.Execute(null, textArea);
 }
Ejemplo n.º 6
0
 public static void ExecuteOnMainWindow(this RoutedUICommand command, object parameter = null)
 {
     command.Execute(parameter, Application.Current.MainWindow);
 }
Ejemplo n.º 7
0
		void Execute(RoutedUICommand command)
		{
			TextArea textArea = this.TextArea;
			if (textArea != null)
				command.Execute(null, textArea);
		}
 private void ExecuteCommand(RoutedUICommand cmd, object data = null)
 {
     cmd.Execute(data, this);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="?"></param>
        private void ListBoxGraphItem_MouseDoubleClick(object sender, MouseButtonEventArgs arg_)
        {
            RoutedUICommand cmd = (RoutedUICommand)Application.Current.Resources["Commands.OpenGraph"];

            cmd.Execute(arg_, this);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds the new knowledge.
 /// </summary>
 public static void AddNewKnowledge()
 {
     Add.Execute(new ItemParams(ObjectType.Knowledge, 0), App.Current.MainWindow);
 }
Ejemplo n.º 11
0
        private void OnShowReport(object sender, RoutedEventArgs e)
        {
            RoutedUICommand cmd = AppCommands.CommandReportBudget;

            cmd.Execute(null, this);
        }