From e1d7f1bf7f091b1ada90e746db852961c8af344e Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 22 Jul 2012 20:50:17 +0200 Subject: [PATCH] Show tooltips on EnhancedScrollBarTrack. Fixed NullReferenceException when showing tooltip after debugging. --- SharpDevelop.sln | 2 +- .../CSharpBinding/Project/CSharpBinding.addin | 2 +- .../Project/Src/CSharpSemanticHighlighter.cs | 1 + .../XamlBinding/XamlBinding.csproj | 3 ++- .../Debugger.AddIn/Service/WindowsDebugger.cs | 13 +++++------ .../Debugger.AddIn/TreeModel/ValueNode.cs | 2 ++ .../AvalonEdit.AddIn/Src/CodeEditorView.cs | 5 ++-- .../AvalonEdit.AddIn/Src/EnhancedScrollBar.cs | 23 ++++++++++++++++--- .../Project/ICSharpCode.SharpDevelop.addin | 2 -- 9 files changed, 36 insertions(+), 17 deletions(-) diff --git a/SharpDevelop.sln b/SharpDevelop.sln index 7841920cc8..08a82ab1b0 100644 --- a/SharpDevelop.sln +++ b/SharpDevelop.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.2.0.8783 +# SharpDevelop 4.3 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin index 88ecf0825c..8296fd29fe 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin @@ -20,7 +20,7 @@ + class = "ICSharpCode.NRefactory.CSharp.CSharpAmbience"/> diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs index 0bd9bfc4fd..5af7d7d95f 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpSemanticHighlighter.cs @@ -372,6 +372,7 @@ namespace CSharpBinding public override void VisitMethodDeclaration(MethodDeclaration methodDeclaration) { methodDeclaration.ReturnType.AcceptVisitor(this); + methodDeclaration.PrivateImplementationType.AcceptVisitor(this); Colorize(methodDeclaration.NameToken, methodCallColor); foreach (var node in methodDeclaration.TypeParameters) node.AcceptVisitor(this); diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj index 7e8fb9bb0e..0860aff571 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlBinding.csproj @@ -14,7 +14,8 @@ false C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis v4.5 - Client + + true diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs index 9c3d436a37..742d2cf239 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs @@ -710,22 +710,21 @@ namespace ICSharpCode.SharpDevelop.Services public void HandleToolTipRequest(ToolTipRequestEventArgs e) { + if (!(IsDebugging && CurrentProcess.IsPaused)) + return; if (e.ResolveResult == null) return; if (e.ResolveResult is LocalResolveResult || e.ResolveResult is MemberResolveResult || e.ResolveResult is InvocationResolveResult) { - Value result; - string text; try { ExpressionEvaluationVisitor eval = new ExpressionEvaluationVisitor(CurrentStackFrame, EvalThread, CurrentStackFrame.AppDomain.Compilation); - result = eval.Convert(e.ResolveResult); - text = new ResolveResultPrettyPrinter().Print(e.ResolveResult); + Value result = eval.Convert(e.ResolveResult); + string text = new ResolveResultPrettyPrinter().Print(e.ResolveResult); + e.SetToolTip(new DebuggerTooltipControl(ValueNode.GetTooltipFor(text, result))); } catch (GetValueException ex) { - text = ex.Message; - result = null; + e.SetToolTip(ex.Message); } catch (InvalidOperationException) { return; } - e.SetToolTip(new DebuggerTooltipControl(ValueNode.GetTooltipFor(text, result))); } } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs index 51ef3ac74f..d641d05005 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/TreeModel/ValueNode.cs @@ -279,6 +279,8 @@ namespace Debugger.AddIn.TreeModel public static TreeNode GetTooltipFor(string text, Value value) { + if (value == null) + throw new ArgumentNullException("value"); return new ValueNode("Icons.16x16.Local", text, () => value); } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index 8a95352026..636732b12d 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -298,9 +298,10 @@ namespace ICSharpCode.AvalonEdit.AddIn var popupPosition = GetPopupPosition(e); popupToolTip.HorizontalOffset = popupPosition.X; popupToolTip.VerticalOffset = popupPosition.Y; - popupToolTip.IsOpen = true; popupToolTip.StaysOpen = true; // We will close it ourselves + e.Handled = true; + popupToolTip.IsOpen = true; } else { if (toolTip == null) { toolTip = new ToolTip(); @@ -318,8 +319,8 @@ namespace ICSharpCode.AvalonEdit.AddIn else toolTip.Content = args.ContentToShow; - toolTip.IsOpen = true; e.Handled = true; + toolTip.IsOpen = true; } } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/EnhancedScrollBar.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/EnhancedScrollBar.cs index 9788a4d56e..b9faf7d5f2 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/EnhancedScrollBar.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/EnhancedScrollBar.cs @@ -10,7 +10,11 @@ using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; +using System.Windows.Threading; +using ICSharpCode.AvalonEdit.Rendering; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.AvalonEdit.AddIn { @@ -215,6 +219,7 @@ namespace ICSharpCode.AvalonEdit.AddIn this.textMarkerService = enhanchedScrollBar.textMarkerService; this.Cursor = Cursors.Hand; + this.ToolTip = string.Empty; triangleGeometry = new StreamGeometry(); using (var ctx = triangleGeometry.Open()) { @@ -282,7 +287,7 @@ namespace ICSharpCode.AvalonEdit.AddIn protected override void OnMouseDown(MouseButtonEventArgs e) { base.OnMouseDown(e); - var marker = FindNextMarker(e); + var marker = FindNextMarker(e.GetPosition(this)); if (marker != null) { var location = editor.Document.GetLocation(marker.StartOffset); // Use JumpTo() if possible @@ -291,12 +296,12 @@ namespace ICSharpCode.AvalonEdit.AddIn textEditor.JumpTo(location.Line, location.Column); else editor.ScrollTo(location.Line, location.Column); + e.Handled = true; } } - ITextMarker FindNextMarker(MouseButtonEventArgs e) + ITextMarker FindNextMarker(Point mousePos) { - var mousePos = e.GetPosition(this); var renderSize = this.RenderSize; var document = editor.Document; var textView = editor.TextArea.TextView; @@ -319,6 +324,18 @@ namespace ICSharpCode.AvalonEdit.AddIn } return bestMarker; } + + protected override void OnToolTipOpening(ToolTipEventArgs e) + { + base.OnToolTipOpening(e); + var marker = FindNextMarker(Mouse.GetPosition(this)); + if (marker != null && marker.ToolTip != null) { + this.ToolTip = marker.ToolTip; + } else { + // prevent tooltip from opening + e.Handled = true; + } + } } #endregion } diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin index caf3d4c544..7f65ae8d41 100755 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin @@ -65,8 +65,6 @@ -