本文整理汇总了C#中Mono.TextEditor.LineMetrics类的典型用法代码示例。如果您正苦于以下问题:C# LineMetrics类的具体用法?C# LineMetrics怎么用?C# LineMetrics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineMetrics类属于Mono.TextEditor命名空间,在下文中一共展示了LineMetrics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBackground
public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
// check, if a message bubble is active in that line.
if (LineSegment != null && LineSegment.Markers.Any (m => m != this && (m is IExtendingTextLineMarker)))
return false;
return base.DrawBackground (editor, cr, y, metrics);
}
示例2: DrawBackground
public override void DrawBackground (Mono.TextEditor.MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
int markerStart = usage.Offset;
int markerEnd = usage.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return;
double @from;
double to;
var startXPos = metrics.TextRenderStartPosition;
var endXPos = metrics.TextRenderEndPosition;
var y = metrics.LineYRenderStartPosition;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = Math.Max (@from, editor.TextViewMargin.XOffset);
to = Math.Max (to, editor.TextViewMargin.XOffset);
if (@from < to) {
Mono.TextEditor.Highlighting.AmbientColor colorStyle;
if ((usage.UsageType & ReferenceUsageType.Write) == ReferenceUsageType.Write ||
(usage.UsageType & ReferenceUsageType.Declariton) == ReferenceUsageType.Declariton) {
colorStyle = editor.ColorStyle.ChangingUsagesRectangle;
if (colorStyle.Color.A == 0.0)
colorStyle = editor.ColorStyle.UsagesRectangle;
} else {
colorStyle = editor.ColorStyle.UsagesRectangle;
}
using (var lg = new LinearGradient (@from + 1, y + 1.5, to , y + editor.LineHeight - 1)) {
lg.AddColorStop (0, colorStyle.Color);
lg.AddColorStop (1, colorStyle.SecondColor);
cr.SetSource (lg);
cr.RoundedRectangle (@from - 0.5, y + 0.5, to - @from + 1, editor.LineHeight - 1, 2);
cr.FillPreserve ();
}
cr.SetSourceColor (colorStyle.BorderColor);
cr.Stroke ();
}
}
示例3: DrawBackground
public override bool DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
{
if (metrics.SelectionStart > 0)
return true;
cr.SetSourceColor (color);
cr.Rectangle (metrics.TextRenderStartPosition, metrics.LineYRenderStartPosition, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
cr.Fill ();
return true;
}
示例4: DrawBackground
public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
if (metrics.SelectionStart > 0)
return true;
cr.Color = color;
cr.Rectangle (metrics.TextRenderStartPosition, y, metrics.TextRenderEndPosition - metrics.TextRenderStartPosition, editor.LineHeight);
cr.Fill ();
return true;
}
示例5: Draw
public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
this.editor = editor;
var line = editor.GetLine (loc.Line);
if (line == null)
return;
var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;
cr.Rectangle (Math.Floor (x), Math.Floor (metrics.LineYRenderStartPosition) + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight : 0), tagMarkerWidth, tagMarkerHeight);
cr.SetSourceColor ((HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5 ? Ide.Gui.Styles.Editor.SmartTagMarkerColorDark : Ide.Gui.Styles.Editor.SmartTagMarkerColorLight).ToCairoColor ());
cr.Fill ();
}
示例6: DrawBackground
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
this.editor = editor;
int markerStart = base.Offset;
int markerEnd = base.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return;
double @from;
double to;
var startXPos = metrics.TextRenderStartPosition;
var endXPos = metrics.TextRenderEndPosition;
var y = metrics.LineYRenderStartPosition;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = Math.Max (@from, editor.TextViewMargin.XOffset);
to = Math.Max (to, editor.TextViewMargin.XOffset);
if (@from < to) {
cr.SetSourceColor (background(editor).Color);
cr.RoundedRectangle (@from + 2.5, y + 0.5, to - @from, editor.LineHeight - 1, 2); // 2.5 to make space for the column guideline
if (background(editor).HasBorderColor) {
cr.FillPreserve ();
cr.SetSourceColor (background(editor).BorderColor);
cr.Stroke ();
} else {
cr.Fill ();
}
}
}
示例7: Draw
public override void Draw (Mono.TextEditor.MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
this.editor = editor;
var line = editor.GetLine (loc.Line);
if (line == null)
return;
var x = editor.ColumnToX (line, loc.Column) - editor.HAdjustment.Value + editor.TextViewMargin.XOffset + editor.TextViewMargin.TextStartPosition;
cr.Rectangle (Math.Floor (x) + 0.5, Math.Floor (metrics.LineYRenderStartPosition) + 0.5 + (line == editor.GetLineByOffset (startOffset) ? editor.LineHeight - tagMarkerHeight - 1 : 0), tagMarkerWidth * cr.LineWidth, tagMarkerHeight * cr.LineWidth);
if (HslColor.Brightness (editor.ColorStyle.PlainText.Background) < 0.5) {
cr.SetSourceRGBA (0.8, 0.8, 1, 0.9);
} else {
cr.SetSourceRGBA (0.2, 0.2, 1, 0.9);
}
cr.Stroke ();
}
示例8: DrawBackground
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
int markerStart = Offset;
int markerEnd = EndOffset;
double @from;
double to;
var startXPos = metrics.TextRenderStartPosition;
var endXPos = metrics.TextRenderEndPosition;
var y = metrics.LineYRenderStartPosition;
if (markerStart < startOffset && endOffset < markerEnd) {
@from = startXPos;
to = endXPos;
} else {
int start = startOffset < markerStart ? markerStart : startOffset;
int end = endOffset < markerEnd ? endOffset : markerEnd;
uint curIndex = 0, byteIndex = 0;
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
int x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
@from = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
TextViewMargin.TranslateToUTF8Index (metrics.Layout.LineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
x_pos = metrics.Layout.Layout.IndexToPos ((int)byteIndex).X;
to = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
@from = Math.Max (@from, editor.TextViewMargin.XOffset);
to = Math.Max (to, editor.TextViewMargin.XOffset);
if (@from <= to) {
if (metrics.TextEndOffset < markerEnd)
to = metrics.WholeLineWidth + metrics.TextRenderStartPosition;
var c1 = editor.Options.GetColorStyle ().PlainText.Background;
var c2 = editor.Options.GetColorStyle ().SelectedText.Background;
cr.SetSourceRGB ((c1.R + c2.R) / 2, (c1.G + c2.G) / 2, (c1.B + c2.B) / 2);
cr.Rectangle (@from, y, to - @from, metrics.LineHeight);
cr.Fill ();
}
}
示例9: DrawBackground
public override bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
// check, if a message bubble is active in that line.
if (LineSegment != null && LineSegment.Markers.Any (m => m != this && (m is IExtendingTextLineMarker)))
return false;
var sidePadding = 4;
var rounding = editor.LineHeight / 2 - 1;
var d = metrics.TextRenderEndPosition - metrics.TextRenderStartPosition;
if (d > 0) {
cr.LineWidth = 1;
cr.RoundedRectangle (metrics.TextRenderStartPosition, Math.Floor (y) + 0.5, d + sidePadding, metrics.LineHeight - 1, rounding);
cr.SetSourceColor (BackgroundColor);
cr.FillPreserve ();
cr.SetSourceColor (BorderColor);
cr.Stroke ();
}
return base.DrawBackground (editor, cr, y, metrics);
}
示例10: Draw
public override void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics)
{
var startOffset = metrics.TextStartOffset;
int endOffset = metrics.TextEndOffset;
double startXPos = metrics.TextRenderStartPosition;
double endXPos = metrics.TextRenderEndPosition;
double y = metrics.LineYRenderStartPosition;
var layout = metrics.Layout.Layout;
int markerStart = LineSegment.Offset + System.Math.Max (StartCol - 1, 0);
int markerEnd = LineSegment.Offset + (EndCol < 1 ? LineSegment.Length : EndCol - 1);
if (markerEnd < startOffset || markerStart > endOffset)
return;
if (editor.IsSomethingSelected) {
var range = editor.SelectionRange;
if (range.Contains (markerStart)) {
int end = System.Math.Min (markerEnd, range.EndOffset);
InternalDraw (markerStart, end, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
InternalDraw (range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
return;
}
if (range.Contains (markerEnd)) {
InternalDraw (markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
InternalDraw (range.Offset, markerEnd, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
return;
}
if (markerStart <= range.Offset && range.EndOffset <= markerEnd) {
InternalDraw (markerStart, range.Offset, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
InternalDraw (range.Offset, range.EndOffset, editor, cr, layout, true, startOffset, endOffset, y, startXPos, endXPos);
InternalDraw (range.EndOffset, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
return;
}
}
InternalDraw (markerStart, markerEnd, editor, cr, layout, false, startOffset, endOffset, y, startXPos, endXPos);
}
示例11: DrawBackground
public override void DrawBackground(MonoTextEditor editor, Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
int x1 = editor.LocationToPoint(editor.OffsetToLocation(this.Offset), false).X;
int x2 = editor.LocationToPoint(editor.OffsetToLocation(this.Offset + this.Length), false).X;
cr.Rectangle(x1, metrics.LineYRenderStartPosition + 0.5, x2 - x1, metrics.LineHeight - 1);
cr.SetSourceRGB(1.0, 1.0, 0.0);
cr.Fill();
}
示例12: DrawBackground
/// <summary>
/// Draws the background of the text.
/// </summary>
/// <returns><c>true</c>, if background was drawn, <c>false</c> otherwise.</returns>
/// <param name="editor">The editor.</param>
/// <param name="cr">The cairo context.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="metrics">The line metrics.</param>
public virtual bool DrawBackground (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
return false;
}
示例13: Draw
public virtual void Draw (TextEditor editor, Cairo.Context cr, double y, LineMetrics metrics)
{
Draw (editor, cr, metrics.Layout.Layout, false, metrics.TextStartOffset, metrics.TextEndOffset, y, metrics.TextRenderStartPosition, metrics.TextRenderEndPosition);
}
示例14: GetErrorCountBounds
Tuple<int, int> GetErrorCountBounds (LineMetrics metrics)
{
EnsureLayoutCreated (editor);
var lineTextPx = editor.TextViewMargin.XOffset + metrics.TextRenderEndPosition;
if (errors.Count > 1 && errorCountLayout != null || editor.Allocation.Width < lineTextPx + layouts [0].Width) {
int ew = 0, eh = 0;
if (errorCountLayout != null) {
errorCountLayout.GetPixelSize (out ew, out eh);
} else {
ew = 10;
}
return Tuple.Create (ew + 10, eh);
}
return Tuple.Create (0, 0);
}
示例15: Draw
public override void Draw (MonoTextEditor editor, Cairo.Context cr, LineMetrics layout, int startOffset, int endOffset)
{
if (DebuggingService.IsDebugging)
return;
int markerStart = Segment.Offset;
int markerEnd = Segment.EndOffset;
if (markerEnd < startOffset || markerStart > endOffset)
return;
double drawFrom;
double drawTo;
double y = layout.LineYRenderStartPosition;
double startXPos = layout.TextRenderStartPosition;
double endXPos = layout.TextRenderEndPosition;
if (markerStart < startOffset && endOffset < markerEnd) {
drawTo = endXPos;
var line = editor.GetLineByOffset (startOffset);
int offset = line.GetIndentation (editor.Document).Length;
drawFrom = startXPos + (layout.Layout.Layout.IndexToPos (offset).X / Pango.Scale.PangoScale);
} else {
int start;
if (startOffset < markerStart) {
start = markerStart;
} else {
var line = editor.GetLineByOffset (startOffset);
int offset = line.GetIndentation (editor.Document).Length;
start = startOffset + offset;
}
int end = endOffset < markerEnd ? endOffset : markerEnd;
int x_pos;
x_pos = layout.Layout.Layout.IndexToPos (start - startOffset).X;
drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
x_pos = layout.Layout.Layout.IndexToPos (end - startOffset).X;
drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
}
drawFrom = Math.Max (drawFrom, editor.TextViewMargin.XOffset);
drawTo = Math.Max (drawTo, editor.TextViewMargin.XOffset);
if (drawFrom >= drawTo)
return;
double height = editor.LineHeight / 5;
cr.SetSourceColor (color);
if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.WavedLine) {
Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
} else if (effect == MonoDevelop.Ide.Editor.TextSegmentMarkerEffect.DottedLine) {
cr.Save ();
cr.LineWidth = 1;
cr.MoveTo (drawFrom + 1, y + editor.LineHeight - 1 + 0.5);
cr.RelLineTo (Math.Min (drawTo - drawFrom, 4 * 3), 0);
cr.SetDash (new double[] { 2, 2 }, 0);
cr.Stroke ();
cr.Restore ();
} else {
cr.MoveTo (drawFrom, y + editor.LineHeight - 1);
cr.LineTo (drawTo, y + editor.LineHeight - 1);
cr.Stroke ();
}
}