-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAvalonTools.cs
46 lines (40 loc) · 1.63 KB
/
AvalonTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using ICSharpCode.AvalonEdit.Rendering;
using ICSharpCode.AvalonEdit;
using System.Windows.Media;
using System.Windows;
namespace ESPEDfGK
{
//*****************************************************************************************
internal class HighlightCurrentLineBackgroundRenderer : IBackgroundRenderer
{
private TextEditor _editor;
public int LineNumber;
//*****************************************************************************************
public HighlightCurrentLineBackgroundRenderer(TextEditor editor)
{
_editor = editor;
}
//*****************************************************************************************
public KnownLayer Layer
{
get { return KnownLayer.Selection; }
}
//*****************************************************************************************
public void Draw(TextView textView, DrawingContext drawingContext)
{
if (_editor.Document == null)
return;
textView.EnsureVisualLines();
if ((LineNumber > 0) && (LineNumber<_editor.Document.Lines.Count))
{
Brush highlight = Brushes.LightGreen;
var currentLine = _editor.Document.GetLineByNumber(LineNumber);
foreach (var rect in BackgroundGeometryBuilder.GetRectsForSegment(textView, currentLine))
{
drawingContext.DrawRectangle(highlight,
null, new Rect(rect.Location, new Size(rect.Width, rect.Height)));
}
}
}
}
}