|
|
@ -3,7 +3,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel; |
|
|
|
|
|
|
|
using System.Threading; |
|
|
|
using System.Threading; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls; |
|
|
@ -17,7 +16,6 @@ using ICSharpCode.NRefactory.CSharp; |
|
|
|
using ICSharpCode.NRefactory.CSharp.Refactoring; |
|
|
|
using ICSharpCode.NRefactory.CSharp.Refactoring; |
|
|
|
using ICSharpCode.NRefactory.Editor; |
|
|
|
using ICSharpCode.NRefactory.Editor; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
|
|
|
|
using CSharpBinding.Refactoring; |
|
|
|
using CSharpBinding.Refactoring; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
|
|
|
|
|
|
|
@ -25,6 +23,36 @@ namespace CSharpBinding.Refactoring |
|
|
|
{ |
|
|
|
{ |
|
|
|
public abstract class AbstractInlineRefactorDialog : GroupBox, IOptionBindingContainer, IActiveElement |
|
|
|
public abstract class AbstractInlineRefactorDialog : GroupBox, IOptionBindingContainer, IActiveElement |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
private class UndoableInlineDialogCreation : IUndoableOperation |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
private AbstractInlineRefactorDialog _dialog; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UndoableInlineDialogCreation(AbstractInlineRefactorDialog dialog) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_dialog = dialog; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Reset() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Remove dialog reference
|
|
|
|
|
|
|
|
_dialog = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Undo() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (_dialog != null) { |
|
|
|
|
|
|
|
// Close the dialog
|
|
|
|
|
|
|
|
_dialog.Deactivate(); |
|
|
|
|
|
|
|
Reset(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Redo() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// We don't react to Redo command here...
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected ITextAnchor anchor; |
|
|
|
protected ITextAnchor anchor; |
|
|
|
protected ITextAnchor insertionEndAnchor; |
|
|
|
protected ITextAnchor insertionEndAnchor; |
|
|
|
protected ITextEditor editor; |
|
|
|
protected ITextEditor editor; |
|
|
@ -32,6 +60,8 @@ namespace CSharpBinding.Refactoring |
|
|
|
protected SDRefactoringContext refactoringContext; |
|
|
|
protected SDRefactoringContext refactoringContext; |
|
|
|
protected InsertionContext insertionContext; |
|
|
|
protected InsertionContext insertionContext; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UndoableInlineDialogCreation undoableCreationOperation; |
|
|
|
|
|
|
|
|
|
|
|
public IInlineUIElement Element { get; set; } |
|
|
|
public IInlineUIElement Element { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
protected AbstractInlineRefactorDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor) |
|
|
|
protected AbstractInlineRefactorDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor) |
|
|
@ -44,6 +74,16 @@ namespace CSharpBinding.Refactoring |
|
|
|
this.insertionContext = context; |
|
|
|
this.insertionContext = context; |
|
|
|
|
|
|
|
|
|
|
|
this.Background = SystemColors.ControlBrush; |
|
|
|
this.Background = SystemColors.ControlBrush; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
undoableCreationOperation = new UndoableInlineDialogCreation(this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IUndoableOperation UndoableCreationOperation |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return undoableCreationOperation; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void FocusFirstElement() |
|
|
|
protected virtual void FocusFirstElement() |
|
|
@ -127,29 +167,6 @@ namespace CSharpBinding.Refactoring |
|
|
|
protected virtual void Initialize() |
|
|
|
protected virtual void Initialize() |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.refactoringContext = SDRefactoringContext.Create(editor, CancellationToken.None); |
|
|
|
this.refactoringContext = SDRefactoringContext.Create(editor, CancellationToken.None); |
|
|
|
|
|
|
|
|
|
|
|
TextDocument textDocument = editor.Document as TextDocument; |
|
|
|
|
|
|
|
if (textDocument != null) { |
|
|
|
|
|
|
|
textDocument.UndoStack.PropertyChanged += UndoStackPropertyChanged; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UndoStackPropertyChanged(object sender, PropertyChangedEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (e.PropertyName == "CanRedo") { |
|
|
|
|
|
|
|
// Undo command has been triggered?
|
|
|
|
|
|
|
|
OnUndoTriggered(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Unregister from event, again
|
|
|
|
|
|
|
|
TextDocument textDocument = editor.Document as TextDocument; |
|
|
|
|
|
|
|
if (textDocument != null) { |
|
|
|
|
|
|
|
textDocument.UndoStack.PropertyChanged -= UndoStackPropertyChanged; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnUndoTriggered() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnInsertionCompleted() |
|
|
|
protected virtual void OnInsertionCompleted() |
|
|
@ -165,11 +182,6 @@ namespace CSharpBinding.Refactoring |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TextDocument textDocument = editor.Document as TextDocument; |
|
|
|
|
|
|
|
if (textDocument != null) { |
|
|
|
|
|
|
|
textDocument.UndoStack.PropertyChanged -= UndoStackPropertyChanged; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e.Reason == DeactivateReason.ReturnPressed) |
|
|
|
if (e.Reason == DeactivateReason.ReturnPressed) |
|
|
|
OKButtonClick(null, null); |
|
|
|
OKButtonClick(null, null); |
|
|
|
|
|
|
|
|
|
|
@ -191,6 +203,9 @@ namespace CSharpBinding.Refactoring |
|
|
|
deactivated = true; |
|
|
|
deactivated = true; |
|
|
|
Element.Remove(); |
|
|
|
Element.Remove(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cut connection with UndoableInlineDialogCreation
|
|
|
|
|
|
|
|
undoableCreationOperation.Reset(); |
|
|
|
|
|
|
|
|
|
|
|
insertionContext.Deactivate(null); |
|
|
|
insertionContext.Deactivate(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|