Ejemplo n.º 1
0
 /// <summary>Performs an action encapsulated in IEditAction.</summary>
 /// <remarks>
 /// There is an implementation of IEditAction for every action that
 /// the user can invoke using a shortcut key (arrow keys, Ctrl+X, etc.)
 /// The editor control doesn't provide a public funciton to perform one
 /// of these actions directly, so I wrote DoEditAction() based on the
 /// code in TextArea.ExecuteDialogKey(). You can call ExecuteDialogKey
 /// directly, but it is more fragile because it takes a Keys value (e.g.
 /// Keys.Left) instead of the action to perform.
 /// <para/>
 /// Clipboard commands could also be done by calling methods in
 /// editor.ActiveTextAreaControl.TextArea.ClipboardHandler.
 /// </remarks>
 private void DoEditAction(TextEditorControl editor, ICSharpCode.TextEditor.Actions.IEditAction action)
 {
     if (editor != null && action != null)
     {
         TextArea area = editor.ActiveTextAreaControl.TextArea;
         editor.BeginUpdate();
         try
         {
             lock (editor.Document)
             {
                 action.Execute(area);
                 if (area.SelectionManager.HasSomethingSelected && area.AutoClearSelection /*&& caretchanged*/)
                 {
                     if (area.Document.TextEditorProperties.DocumentSelectionMode == DocumentSelectionMode.Normal)
                     {
                         area.SelectionManager.ClearSelection();
                     }
                 }
             }
         }
         finally
         {
             editor.EndUpdate();
             area.Caret.UpdateCaretPosition();
         }
     }
 }
Ejemplo n.º 2
0
        private void DoEditAction(ICSharpCode.TextEditor.Actions.IEditAction action)
        {
            TextEditorControl editor = this.textEditorControl1;

            if (editor != null && action != null)
            {
                TextArea area = editor.ActiveTextAreaControl.TextArea;
                editor.BeginUpdate();
                try
                {
                    lock (editor.Document)
                    {
                        action.Execute(area);
                    }
                }
                finally
                {
                    editor.EndUpdate();
                    area.Caret.UpdateCaretPosition();
                }
            }
        }