本文整理汇总了C#中LayoutWrapper.SetAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# LayoutWrapper.SetAttributes方法的具体用法?C# LayoutWrapper.SetAttributes怎么用?C# LayoutWrapper.SetAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutWrapper
的用法示例。
在下文中一共展示了LayoutWrapper.SetAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderLine
protected override LayoutWrapper RenderLine (long line)
{
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
layout.Tabs = tabArray;
StringBuilder sb = new StringBuilder ();
long startOffset = line * Editor.BytesInRow;
long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length);
byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset));
for (int i = 0; i < lineBytes.Length; i++) {
sb.Append (string.Format ("{0:X2}", lineBytes[i]));
if (i % Editor.Options.GroupBytes == 0)
sb.Append ("\t");
}
layout.SetText (sb.ToString ());
char[] lineChars = sb.ToString ().ToCharArray ();
Margin.LayoutWrapper result = new LayoutWrapper (layout);
uint curIndex = 0, byteIndex = 0;
if (Data.IsSomethingSelected) {
ISegment selection = Data.MainSelection.Segment;
HandleSelection (selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) {
Pango.AttrForeground selectedForeground = new Pango.AttrForeground (Style.Selection.Red,
Style.Selection.Green,
Style.Selection.Blue);
selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, TranslateColumn (start - startOffset), ref curIndex, ref byteIndex);
selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, TranslateColumn (end - startOffset) - 1, ref curIndex, ref byteIndex);
result.Add (selectedForeground);
Pango.AttrBackground attrBackground = new Pango.AttrBackground (Style.SelectionBg.Red,
Style.SelectionBg.Green,
Style.SelectionBg.Blue);
attrBackground.StartIndex = selectedForeground.StartIndex;
attrBackground.EndIndex = selectedForeground.EndIndex;
result.Add (attrBackground);
});
}
result.SetAttributes ();
return result;
}
示例2: RenderLine
protected override LayoutWrapper RenderLine (long line)
{
Pango.Layout layout = new Pango.Layout (Editor.PangoContext);
layout.FontDescription = Editor.Options.Font;
StringBuilder sb = new StringBuilder ();
long startOffset = line * Editor.BytesInRow;
long endOffset = System.Math.Min (startOffset + Editor.BytesInRow, Data.Length);
byte[] lineBytes = Data.GetBytes (startOffset, (int)(endOffset - startOffset));
for (int i = 0; i < lineBytes.Length; i++) {
byte b = lineBytes[i];
char ch = (char)b;
if (b < 128 && (Char.IsLetterOrDigit (ch) || Char.IsPunctuation (ch))) {
sb.Append (ch);
} else {
sb.Append (".");
}
}
layout.SetText (sb.ToString ());
char[] lineChars = layout.Text.ToCharArray ();
Margin.LayoutWrapper result = new LayoutWrapper (layout);
uint curIndex = 0, byteIndex = 0;
if (Data.IsSomethingSelected) {
ISegment selection = Data.MainSelection.Segment;
HandleSelection (selection.Offset, selection.EndOffset, startOffset, endOffset, null, delegate(long start, long end) {
Pango.AttrForeground selectedForeground = new Pango.AttrForeground (Style.Selection.Red,
Style.Selection.Green,
Style.Selection.Blue);
selectedForeground.StartIndex = TranslateToUTF8Index (lineChars, (uint)(start - startOffset), ref curIndex, ref byteIndex);
selectedForeground.EndIndex = TranslateToUTF8Index (lineChars, (uint)(end - startOffset), ref curIndex, ref byteIndex);
result.Add (selectedForeground);
Pango.AttrBackground attrBackground = new Pango.AttrBackground (Style.SelectionBg.Red,
Style.SelectionBg.Green,
Style.SelectionBg.Blue);
attrBackground.StartIndex = selectedForeground.StartIndex;
attrBackground.EndIndex = selectedForeground.EndIndex;
result.Add (attrBackground);
});
}
result.SetAttributes ();
return result;
}