Browse Source

fix #292: Implement interface does not show generated code

pull/297/head
Siegfried Pammer 12 years ago
parent
commit
daf9b5571f
  1. 26
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs
  2. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditEditorUIService.cs
  3. 30
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/InlineUIElementGenerator.cs
  4. 22
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/NewLineConsistencyCheck.cs
  5. 8
      src/Main/Base/Project/Editor/IEditorUIService.cs

26
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs

@ -7,6 +7,7 @@ using System.ComponentModel.Design; @@ -7,6 +7,7 @@ using System.ComponentModel.Design;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
@ -285,6 +286,7 @@ namespace CSharpBinding.Refactoring @@ -285,6 +286,7 @@ namespace CSharpBinding.Refactoring
this.editor.TextView.InsertLayer(this, KnownLayer.Text, LayerInsertionPosition.Above);
this.editor.TextView.ScrollOffsetChanged += TextViewScrollOffsetChanged;
ScrollToInsertionPoint();
AttachToCodeEditor();
}
static readonly Pen markerPen = new Pen(Brushes.Blue, 1);
@ -331,6 +333,7 @@ namespace CSharpBinding.Refactoring @@ -331,6 +333,7 @@ namespace CSharpBinding.Refactoring
public void Dispose()
{
groupBox.Remove();
editor.TextView.Layers.Remove(this);
editor.ActiveInputHandler = editor.DefaultInputHandler;
editor.TextView.ScrollOffsetChanged -= TextViewScrollOffsetChanged;
@ -351,6 +354,7 @@ namespace CSharpBinding.Refactoring @@ -351,6 +354,7 @@ namespace CSharpBinding.Refactoring
{
FireExited(false);
}
/// <summary>
/// call this somewhere useful, please... :)
/// </summary>
@ -365,6 +369,28 @@ namespace CSharpBinding.Refactoring @@ -365,6 +369,28 @@ namespace CSharpBinding.Refactoring
Exited(this, new InsertionCursorEventArgs(insertionPoints[CurrentInsertionPoint], success));
}
}
IOverlayUIElement groupBox;
void AttachToCodeEditor()
{
if (editor.Document == null)
return; // editor was disposed
var content = new StackPanel {
Children = {
new TextBlock {
Text = "Use Up/Down to move to another location.\r\n" +
"Press Enter to select the location.\r\n" +
"Press Esc to cancel this operation."
}
}
};
groupBox = editor.GetService<IEditorUIService>().CreateOverlayUIElement(content);
groupBox.Title = operation;
}
}
public class InsertionCursorEventArgs : EventArgs

15
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditEditorUIService.cs

@ -34,6 +34,21 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -34,6 +34,21 @@ namespace ICSharpCode.AvalonEdit.AddIn
return inline;
}
/// <inheritdoc />
public IOverlayUIElement CreateOverlayUIElement(UIElement element)
{
if (element == null)
throw new ArgumentNullException("element");
CodeEditor codeEditor = textView.GetService<CodeEditor>();
if (codeEditor == null)
throw new NotSupportedException("This feature is not supported!");
var groupBox = new OverlayUIElementContainer(codeEditor);
groupBox.Content = element;
codeEditor.Children.Add(groupBox);
System.Windows.Controls.Grid.SetRow(groupBox, 1);
return groupBox;
}
/// <inheritdoc />
public Point GetScreenPosition(int line, int column)
{

30
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/InlineUIElementGenerator.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.NRefactory.Editor;
@ -45,4 +46,33 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -45,4 +46,33 @@ namespace ICSharpCode.AvalonEdit.AddIn
this.textView.ElementGenerators.Remove(this);
}
}
sealed class OverlayUIElementContainer : GroupBox, IOverlayUIElement
{
CodeEditor codeEditor;
public OverlayUIElementContainer(CodeEditor codeEditor)
{
if (codeEditor == null)
throw new ArgumentNullException("codeEditor");
this.codeEditor = codeEditor;
Background = SystemColors.WindowBrush;
Foreground = SystemColors.WindowTextBrush;
HorizontalAlignment = HorizontalAlignment.Right;
VerticalAlignment = VerticalAlignment.Bottom;
MaxWidth = 300;
Margin = new Thickness(0, 0, 20, 20);
}
public void Remove()
{
codeEditor.Children.Remove(this);
}
public string Title {
get { return Header.ToString(); }
set { Header = value; }
}
}
}

22
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/NewLineConsistencyCheck.cs

@ -9,6 +9,7 @@ using ICSharpCode.AvalonEdit.Document; @@ -9,6 +9,7 @@ using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.AvalonEdit.AddIn
{
@ -66,8 +67,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -66,8 +67,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
GroupBox groupBox;
IOverlayUIElement groupBox;
Button normalizeButton, cancelButton;
RadioButton windows, unix;
@ -76,16 +76,6 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -76,16 +76,6 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (editor.Document == null)
return; // editor was disposed
groupBox = new GroupBox();
groupBox.Background = SystemColors.WindowBrush;
groupBox.Foreground = SystemColors.WindowTextBrush;
groupBox.Header = ResourceService.GetString("AddIns.AvalonEdit.InconsistentNewlines.Header");
groupBox.HorizontalAlignment = HorizontalAlignment.Right;
groupBox.VerticalAlignment = VerticalAlignment.Bottom;
groupBox.MaxWidth = 300;
groupBox.Margin = new Thickness(0, 0, 20, 20);
Grid.SetRow(groupBox, 1);
windows = new RadioButton {
IsChecked = !preferUnixNewLines,
Content = ResourceService.GetString("Dialog.Options.IDEOptions.LoadSaveOptions.WindowsRadioButton"),
@ -99,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -99,7 +89,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
normalizeButton = new Button { Content = ResourceService.GetString("AddIns.AvalonEdit.InconsistentNewlines.Normalize") };
cancelButton = new Button { Content = ResourceService.GetString("Global.CancelButtonText") };
groupBox.Content = new StackPanel {
var content = new StackPanel {
Children = {
new TextBlock {
Text = ResourceService.GetString("AddIns.AvalonEdit.InconsistentNewlines.Description"),
@ -114,13 +104,15 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -114,13 +104,15 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
};
editor.Children.Add(groupBox);
groupBox = editor.GetService<IEditorUIService>().CreateOverlayUIElement(content);
groupBox.Title = ResourceService.GetString("AddIns.AvalonEdit.InconsistentNewlines.Header");
var featureUse = SD.AnalyticsMonitor.TrackFeature(typeof(NewLineConsistencyCheck));
EventHandler removeWarning = null;
removeWarning = delegate {
editor.Children.Remove(groupBox);
groupBox.Remove();
editor.PrimaryTextEditor.TextArea.Focus();
editor.LoadedFileContent -= removeWarning;

8
src/Main/Base/Project/Editor/IEditorUIService.cs

@ -18,6 +18,8 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -18,6 +18,8 @@ namespace ICSharpCode.SharpDevelop.Editor
{
IInlineUIElement CreateInlineUIElement(ITextAnchor position, UIElement element);
IOverlayUIElement CreateOverlayUIElement(UIElement element);
/// <summary>
/// Gets the absolute screen position of given position in the document.
/// </summary>
@ -33,4 +35,10 @@ namespace ICSharpCode.SharpDevelop.Editor @@ -33,4 +35,10 @@ namespace ICSharpCode.SharpDevelop.Editor
{
void Remove();
}
public interface IOverlayUIElement
{
void Remove();
string Title { get; set; }
}
}

Loading…
Cancel
Save