本文整理汇总了C#中TextEditor.GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C# TextEditor.GetWidth方法的具体用法?C# TextEditor.GetWidth怎么用?C# TextEditor.GetWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextEditor
的用法示例。
在下文中一共展示了TextEditor.GetWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(TextEditor editor, Gdk.Drawable win,Pango.Layout layout, bool selected, int startOffset, int endOffset, int y, int startXPos, int endXPos)
{
int markerStart = LineSegment.Offset + System.Math.Max (StartCol, 0);
int markerEnd = LineSegment.Offset + (EndCol < 0? LineSegment.Length : EndCol);
if (markerEnd < startOffset || markerStart > endOffset)
return;
int from;
int to;
if (markerStart < startOffset && endOffset < markerEnd) {
from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
from = startXPos + editor.GetWidth (editor.Document.GetTextAt (startOffset, start - startOffset));
to = startXPos + editor.GetWidth (editor.Document.GetTextAt (startOffset, end - startOffset));
}
from = System.Math.Max (from, editor.TextViewMargin.XOffset);
to = System.Math.Max (to, editor.TextViewMargin.XOffset);
if (from >= to) {
return;
}
using (Gdk.GC gc = new Gdk.GC (win)) {
// gc.RgbFgColor = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
int drawY = y + editor.LineHeight - 1;
win.DrawLine (gc, from, drawY, to, drawY);
if(@from<to){
//gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.BackgroundColor;
//win.DrawRectangle (gc, true, @from + 1, y + 1, to - @from - 1, editor.LineHeight - 2);
gc.RgbFgColor = editor.ColorStyle.BracketHighlightRectangle.Color;
win.DrawRectangle (gc, false, @from, y, to - @from, editor.LineHeight - 1);
}
}
}