|
|
|
|
@ -4,36 +4,37 @@
@@ -4,36 +4,37 @@
|
|
|
|
|
using System; |
|
|
|
|
using System.Windows; |
|
|
|
|
using System.Windows.Media; |
|
|
|
|
|
|
|
|
|
using ICSharpCode.AvalonEdit.Rendering; |
|
|
|
|
using ICSharpCode.AvalonEdit.Utils; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.AvalonEdit |
|
|
|
|
{ |
|
|
|
|
/// <summary>
|
|
|
|
|
/// Redners a ruler at a certain colum
|
|
|
|
|
/// Renders a ruler at a certain column.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ColumnRulerRenderer : IBackgroundRenderer |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
Pen pen; |
|
|
|
|
int column; |
|
|
|
|
TextView textView; |
|
|
|
|
|
|
|
|
|
public const string Name = "Column ruler"; |
|
|
|
|
public static readonly Color DefaultForeground = Colors.LightGray; |
|
|
|
|
|
|
|
|
|
public ColumnRulerRenderer(TextView textView) |
|
|
|
|
{ |
|
|
|
|
if (textView == null) |
|
|
|
|
throw new ArgumentNullException("textView"); |
|
|
|
|
|
|
|
|
|
this.pen = new Pen(Brushes.LightGray, 1); |
|
|
|
|
this.pen = new Pen(new SolidColorBrush(DefaultForeground), 1); |
|
|
|
|
this.pen.Freeze(); |
|
|
|
|
this.textView = textView; |
|
|
|
|
this.textView.BackgroundRenderers.Add(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public KnownLayer Layer { |
|
|
|
|
get { |
|
|
|
|
return KnownLayer.Background; |
|
|
|
|
} |
|
|
|
|
get { return KnownLayer.Background; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void SetRuler(int column, Brush brush) |
|
|
|
|
@ -51,11 +52,9 @@ namespace ICSharpCode.AvalonEdit
@@ -51,11 +52,9 @@ namespace ICSharpCode.AvalonEdit
|
|
|
|
|
|
|
|
|
|
public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext) |
|
|
|
|
{ |
|
|
|
|
if(column < 1) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
if (column < 1) return; |
|
|
|
|
double offset = textView.WideSpaceWidth * column; |
|
|
|
|
System.Windows.Size pixelSize = PixelSnapHelpers.GetPixelSize(textView); |
|
|
|
|
Size pixelSize = PixelSnapHelpers.GetPixelSize(textView); |
|
|
|
|
double markerXPos = PixelSnapHelpers.PixelAlign(offset, pixelSize.Width); |
|
|
|
|
Point start = new Point(markerXPos, 0); |
|
|
|
|
Point end = new Point(markerXPos, Math.Max(textView.DocumentHeight, textView.ActualHeight)); |
|
|
|
|
|