Example for Squiggling lines (Underlining) needed

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Markus
Avatar
Hi folks,

I want to use squiggling lines under a word inside SyntaxEditor. (just like
VS.NET represents compiler errors).
But until now I dont have success with SpanIndicator (I am right - I need to use
this for squiggling lines??)
What I have tried:

editor.Document.Indicators.Add(New MySpanIndicator, 0, 20)
'0 means line 1?? and mark 20 charakters???

'And here my inherited SpanIndicator class - what is missing? ->No glue at the moment!
Public Class MySpanIndicator
Inherits SpanIndicator

Private backColor As Color
Private foreColor As Color

Public Sub New()
MyBase.New("test", 1, True, Nothing)
backColor = Color.AliceBlue
foreColor = Color.BlanchedAlmond
End Sub



Protected Overrides Sub DrawGlyph(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle)

End Sub

Protected Overrides Sub DrawMarks(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle)

End Sub

Protected Overrides Function GetHighlightingStyle() As ActiproSoftware.SyntaxEditor.HighlightingStyle
Return New HighlightingStyle("BreakpointStyle", "Breakpoint", foreColor, backColor, False, False, False)
End Function
End Class

So could please anyone post a simple example for
underlining let's say the first word on line 5 with a
suiggling line???


Thank you folks,

Markus

Comments (3)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Markus,

First off, the Indicators.Add method is based off of offsets. That means the first character in the document is offset 0, the second is offset 1, and so on. If you want to find the first char of a line you need to convert a Position to an offset. Read the Documentation topic "Offset, Positions, and Locations" for more info on that.

As a side node, in your code above where you're doing this:
Protected Overrides Function GetHighlightingStyle() As ActiproSoftware.SyntaxEditor.HighlightingStyle 
Return New HighlightingStyle("BreakpointStyle", "Breakpoint", foreColor, backColor, False, False, False) 
End Function 
End Class
It's much more efficient to create the highlighting style in the constructor and simply return the reference to it. Otherwise, you create an instance of the style every time it is drawn, which is bad.

We made a base class for squiggle lines to do the drawing for you. Just create a class that inherits from SquiggleLineIndicator and you'll be good to go!


Actipro Software Support

Posted 14 years ago by Markus
Avatar
Thank you very much for this quick help!!
Now everything works fine!

Markus
Posted 14 years ago by Markus
Avatar
Thank you very much for this quick help!!
Now everything works fine!

Markus
The latest build of this product (v2018.1 build 0341) was released 10 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.