diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs
index 8031bc157c..88f383c274 100644
--- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs
+++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs
@@ -26,7 +26,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
///
/// This popup is reused (closed and opened again).
///
- ContextActionsPopup popup = new ContextActionsPopup() { StaysOpen = true };
+ ContextActionsBulbPopup popup = new ContextActionsBulbPopup();
///
/// Delays the available actions resolution so that it does not get called too often when user holds an arrow.
@@ -87,7 +87,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
return;
this.popup.Actions = new ContextActionsViewModel {
- Title = "#",
//Image = ClassBrowserIconService.Class.ImageSource,
Actions = availableActionsVM
};
diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index 9f536bc5aa..2ee7b8a7e4 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -331,10 +331,16 @@
+
+ ContextActionsBulbControl.xaml
+ Code
+
+
ContextActionsHeaderedControl.xaml
Code
+
@@ -793,6 +799,7 @@
+
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml
new file mode 100644
index 0000000000..30694a9e3b
--- /dev/null
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs
new file mode 100644
index 0000000000..174d655fb0
--- /dev/null
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs
@@ -0,0 +1,57 @@
+//
+//
+//
+//
+// $Revision: $
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace ICSharpCode.SharpDevelop.Refactoring
+{
+ ///
+ /// Interaction logic for ContextActionsBulbControl.xaml
+ ///
+ public partial class ContextActionsBulbControl : UserControl
+ {
+ public ContextActionsBulbControl()
+ {
+ InitializeComponent();
+ }
+
+ public event EventHandler ActionExecuted
+ {
+ add { this.ActionsTreeView.ActionExecuted += value; }
+ remove { this.ActionsTreeView.ActionExecuted -= value; }
+ }
+
+ bool isOpen;
+ public bool IsOpen {
+ get { return isOpen; }
+ set {
+ isOpen = value;
+ this.Header.Opacity = isOpen ? 1.0 : 0.5;
+ this.Header.BorderThickness = isOpen ? new Thickness(1, 1, 1, 0) : new Thickness(1);
+ this.ActionsTreeView.Visibility = isOpen ? Visibility.Visible : Visibility.Collapsed;
+ }
+ }
+
+ public new void Focus()
+ {
+ if (this.ActionsTreeView != null)
+ this.ActionsTreeView.Focus();
+ }
+
+ void Header_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ this.IsOpen = !this.IsOpen;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbPopup.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbPopup.cs
new file mode 100644
index 0000000000..4577d593cd
--- /dev/null
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbPopup.cs
@@ -0,0 +1,53 @@
+//
+//
+//
+//
+// $Revision: $
+//
+using System;
+using ICSharpCode.SharpDevelop.Editor;
+
+namespace ICSharpCode.SharpDevelop.Refactoring
+{
+ ///
+ /// Description of ContextActionsBulbPopup.
+ ///
+ public class ContextActionsBulbPopup : ContextActionsPopupBase
+ {
+ public ContextActionsBulbPopup()
+ {
+ this.StaysOpen = true;
+ this.AllowsTransparency = true;
+ this.ActionsControl = new ContextActionsBulbControl();
+ // Close when any action excecuted
+ this.ActionsControl.ActionExecuted += delegate { this.Close(); };
+ }
+
+ public ContextActionsBulbControl ActionsControl
+ {
+ get { return (ContextActionsBulbControl)this.Child; }
+ set { this.Child = value; }
+ }
+
+ public ContextActionsViewModel Actions
+ {
+ get { return (ContextActionsViewModel)ActionsControl.DataContext; }
+ set {
+ ActionsControl.DataContext = value;
+ }
+ }
+
+ public bool IsDropdownOpen { get { return ActionsControl.IsOpen; } set {ActionsControl.IsOpen = value; } }
+
+ public new void Focus()
+ {
+ this.ActionsControl.Focus();
+ }
+
+ public void OpenAtLineStart(ITextEditor editor)
+ {
+ OpenAtPosition(editor, editor.Caret.Line, 1, false);
+ this.VerticalOffset -= 16;
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml
index fdca32c814..8044f150a8 100644
--- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml
@@ -18,8 +18,8 @@
-
+
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs
index 95d51890c8..b8fe260a35 100644
--- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs
@@ -24,31 +24,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
public ContextActionsHeaderedControl()
{
InitializeComponent();
- this.IsAlwaysOpen = false;
- this.IsOpen = false;
- }
-
- bool isAlwaysOpen;
- public bool IsAlwaysOpen {
- get { return isAlwaysOpen; }
- set {
- isAlwaysOpen = value;
- if (value)
- IsOpen = true;
- }
- }
-
- bool isOpen;
- public bool IsOpen {
- get { return isOpen; }
- set {
- if (IsAlwaysOpen && !value)
- throw new InvalidOperationException("Cannot set IsOpen to false when IsAlwaysOpen is true");
- isOpen = value;
- this.Header.Opacity = isOpen ? 1.0 : 0.5;
- this.Header.BorderThickness = isOpen ? new Thickness(1, 1, 1, 0) : new Thickness(1);
- this.ActionsTreeView.Visibility = isOpen ? Visibility.Visible : Visibility.Collapsed;
- }
}
public event EventHandler ActionExecuted
@@ -62,13 +37,5 @@ namespace ICSharpCode.SharpDevelop.Refactoring
if (this.ActionsTreeView != null)
this.ActionsTreeView.Focus();
}
-
- void Header_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!this.IsAlwaysOpen)
- {
- this.IsOpen = !this.IsOpen;
- }
- }
}
}
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs
index f231beec87..adbe7f8102 100644
--- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs
@@ -16,29 +16,19 @@ namespace ICSharpCode.SharpDevelop.Refactoring
///
/// Description of ContextActionsPopup.
///
- public class ContextActionsPopup : Popup
+ public class ContextActionsPopup : ContextActionsPopupBase
{
public ContextActionsPopup()
{
- this.StaysOpen = false;
// Close on lost focus
+ this.StaysOpen = false;
this.AllowsTransparency = true;
this.ActionsControl = new ContextActionsHeaderedControl();
// Close when any action excecuted
this.ActionsControl.ActionExecuted += delegate { this.Close(); };
- this.KeyDown += new KeyEventHandler(ContextActionsPopup_KeyDown);
- }
-
- void ContextActionsPopup_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.Escape)
- Close();
}
- public bool IsDropdownOpen { get { return ActionsControl.IsOpen; } set {ActionsControl.IsOpen = value; } }
- public bool IsDropdownAlwaysOpen { get { return ActionsControl.IsAlwaysOpen; } set {ActionsControl.IsAlwaysOpen = value; } }
-
- ContextActionsHeaderedControl ActionsControl
+ public ContextActionsHeaderedControl ActionsControl
{
get { return (ContextActionsHeaderedControl)this.Child; }
set { this.Child = value; }
@@ -57,16 +47,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring
this.ActionsControl.Focus();
}
- public void Open()
- {
- this.IsOpen = true;
- }
-
- public void Close()
- {
- this.IsOpen = false;
- }
-
public void OpenAtCaretAndFocus()
{
OpenAtMousePosition();
@@ -74,49 +54,10 @@ namespace ICSharpCode.SharpDevelop.Refactoring
this.Focus();
}
- public void OpenAtLineStart(ITextEditor editor)
- {
- OpenAtPosition(editor, editor.Caret.Line, 1, false);
- this.VerticalOffset -= 16;
- }
-
void OpenAtMousePosition()
{
this.Placement = PlacementMode.MousePoint;
this.Open();
}
-
- void OpenAtPosition(ITextEditor editor, int line, int column, bool openAtWordStart)
- {
- var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService;
- if (editorUIService != null) {
- var document = editor.Document;
- int offset = document.PositionToOffset(line, column);
- if (openAtWordStart) {
- int wordStart = document.FindPrevWordStart(offset);
- if (wordStart != -1) {
- var wordStartLocation = document.OffsetToPosition(wordStart);
- line = wordStartLocation.Line;
- column = wordStartLocation.Column;
- }
- }
- this.Placement = PlacementMode.Absolute;
- try
- {
- var caretScreenPos = editorUIService.GetScreenPosition(line, column);
- this.HorizontalOffset = caretScreenPos.X;
- this.VerticalOffset = caretScreenPos.Y;
- }
- catch
- {
- this.Placement = PlacementMode.MousePoint;
- }
-
- } else {
- // if no editor information, open at mouse positions
- this.Placement = PlacementMode.MousePoint;
- }
- this.Open();
- }
}
}
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs
new file mode 100644
index 0000000000..5fc944ed98
--- /dev/null
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopupBase.cs
@@ -0,0 +1,74 @@
+//
+//
+//
+//
+// $Revision: $
+//
+using System;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+
+using ICSharpCode.SharpDevelop.Editor;
+
+namespace ICSharpCode.SharpDevelop.Refactoring
+{
+ ///
+ /// Description of ContextActionsPopupBase.
+ ///
+ public abstract class ContextActionsPopupBase : Popup
+ {
+ protected ContextActionsPopupBase()
+ {
+ this.KeyDown += OnKeyDown;
+ }
+
+ void OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Escape)
+ Close();
+ }
+
+ public void Open()
+ {
+ this.IsOpen = true;
+ }
+
+ public void Close()
+ {
+ this.IsOpen = false;
+ }
+
+ protected void OpenAtPosition(ITextEditor editor, int line, int column, bool openAtWordStart)
+ {
+ var editorUIService = editor == null ? null : editor.GetService(typeof(IEditorUIService)) as IEditorUIService;
+ if (editorUIService != null) {
+ var document = editor.Document;
+ int offset = document.PositionToOffset(line, column);
+ if (openAtWordStart) {
+ int wordStart = document.FindPrevWordStart(offset);
+ if (wordStart != -1) {
+ var wordStartLocation = document.OffsetToPosition(wordStart);
+ line = wordStartLocation.Line;
+ column = wordStartLocation.Column;
+ }
+ }
+ this.Placement = PlacementMode.Absolute;
+ try
+ {
+ var caretScreenPos = editorUIService.GetScreenPosition(line, column);
+ this.HorizontalOffset = caretScreenPos.X;
+ this.VerticalOffset = caretScreenPos.Y;
+ }
+ catch
+ {
+ this.Placement = PlacementMode.MousePoint;
+ }
+
+ } else {
+ // if no editor information, open at mouse positions
+ this.Placement = PlacementMode.MousePoint;
+ }
+ this.Open();
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs
index c1889cb01d..08fe044ca6 100644
--- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs
+++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActionsHelper.cs
@@ -27,7 +27,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.ClassesDerivingFrom}", new StringTagPair("Name", baseClass.Name)))};
popupViewModel.Actions = new PopupTreeViewModelBuilder().BuildTreeViewModel(derivedClassesTree);
- return new ContextActionsPopup { Actions = popupViewModel, IsDropdownAlwaysOpen = true };
+ return new ContextActionsPopup { Actions = popupViewModel };
}
public static ContextActionsPopup MakePopupWithBaseClasses(IClass @class)
@@ -40,7 +40,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.BaseClassesOf}", new StringTagPair("Name", @class.Name)))};
popupViewModel.Actions = new PopupListViewModelBuilder().BuildListViewModel(baseClassList);
- return new ContextActionsPopup { Actions = popupViewModel, IsDropdownAlwaysOpen = true };
+ return new ContextActionsPopup { Actions = popupViewModel };
}
public static ContextActionsPopup MakePopupWithOverrides(IMember member)
@@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
var popupViewModel = new ContextActionsViewModel { Title = MenuService.ConvertLabel(StringParser.Parse(
"${res:SharpDevelop.Refactoring.OverridesOf}", new string[,] {{ "Name", member.FullyQualifiedName }}))};
popupViewModel.Actions = new OverridesPopupTreeViewModelBuilder(member).BuildTreeViewModel(derivedClassesTree);
- return new ContextActionsPopup { Actions = popupViewModel, IsDropdownAlwaysOpen = true };
+ return new ContextActionsPopup { Actions = popupViewModel };
}
class PopupViewModelBuilder