本文整理汇总了C#中Xwt.Drawing.TextLayout.SetUnderline方法的典型用法代码示例。如果您正苦于以下问题:C# TextLayout.SetUnderline方法的具体用法?C# TextLayout.SetUnderline怎么用?C# TextLayout.SetUnderline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Drawing.TextLayout
的用法示例。
在下文中一共展示了TextLayout.SetUnderline方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLinePortion
int DrawLinePortion(Context cr, ChunkStyle style, TextLayout layout, DocumentLine line, int visualOffset, int logicalLength)
{
int logicalColumn = line.GetLogicalColumn(editor, visualOffset);
int logicalEndColumn = logicalColumn + logicalLength;
int visualEndOffset = line.GetVisualColumn(editor, logicalEndColumn);
int visualLength = visualEndOffset - visualOffset;
int indexOffset = visualOffset - 1;
layout.SetFontStyle(style.FontStyle, indexOffset, visualLength);
layout.SetFontWeight(style.FontWeight, indexOffset, visualLength);
if (style.Underline)
layout.SetUnderline(indexOffset, visualLength);
layout.SetForeground(style.Foreground, indexOffset, visualLength);
return visualEndOffset;
}
示例2: Texts
public virtual void Texts(Xwt.Drawing.Context ctx, double x, double y)
{
ctx.Save ();
ctx.Translate (x, y);
ctx.SetColor (Colors.Black);
var col1 = new Rectangle ();
var col2 = new Rectangle ();
var text = new TextLayout ();
text.Font = this.Font.WithSize (24);
Console.WriteLine (text.Font.Size);
// first text
text.Text = "Lorem ipsum dolor sit amet,";
var size1 = text.GetSize ();
col1.Width = size1.Width;
col1.Height += size1.Height + 10;
ctx.DrawTextLayout (text, 0, 0);
// proofing width; test should align with text above
ctx.SetColor (Colors.DarkMagenta);
text.Text = "consetetur sadipscing elitr, sed diam nonumy";
text.Width = col1.Width;
var size2 = text.GetSize ();
ctx.DrawTextLayout (text, 0, col1.Bottom);
col1.Height += size2.Height + 10;
ctx.SetColor (Colors.Black);
// proofing scale, on second col
ctx.Save ();
ctx.SetColor (Colors.Red);
col2.Left = col1.Right + 10;
text.Text = "eirmod tempor invidunt ut.";
var scale = 1.2;
text.Width = text.Width / scale;
var size3 = text.GetSize ();
col2.Height = size3.Height * scale;
col2.Width = size3.Width * scale + 5;
ctx.Scale (scale, scale);
ctx.DrawTextLayout (text, col2.Left / scale, col2.Top / scale);
ctx.Restore ();
// proofing heigth, on second col
ctx.Save ();
ctx.SetColor (Colors.DarkCyan);
text.Text = "Praesent ac lacus nec dolor pulvinar feugiat a id elit.";
var size4 = text.GetSize ();
text.Height = size4.Height / 2;
text.Trimming=TextTrimming.WordElipsis;
ctx.DrawTextLayout (text, col2.Left, col2.Bottom + 5);
ctx.SetLineWidth (1);
ctx.SetColor (Colors.Blue);
ctx.Rectangle (new Rectangle (col2.Left, col2.Bottom + 5, text.Width, text.Height));
ctx.Stroke();
ctx.Restore ();
// drawing col line
ctx.SetLineWidth (1);
ctx.SetColor (Colors.Black.WithAlpha (.5));
ctx.MoveTo (col1.Right + 5, col1.Top);
ctx.LineTo (col1.Right + 5, col1.Bottom);
ctx.Stroke ();
ctx.MoveTo (col2.Right + 5, col2.Top);
ctx.LineTo (col2.Right + 5, col2.Bottom);
ctx.Stroke ();
ctx.SetColor (Colors.Black);
// proofing rotate, and printing size to see the values
ctx.Save ();
text.Font = this.Font.WithSize (10);
text.Text = string.Format ("Size 1 {0}\r\nSize 2 {1}\r\nSize 3 {2} Scale {3}",
size1, size2, size3, scale);
text.Width = -1; // this clears textsize
text.Height = -1;
ctx.Rotate (5);
// maybe someone knows a formula with angle and textsize to calculyte ty
var ty = 30;
ctx.DrawTextLayout (text, ty, col1.Bottom + 10);
ctx.Restore ();
// scale example here:
ctx.Restore ();
TextLayout tl0 = new TextLayout (this);
tl0.Font = this.Font.WithSize (10);
tl0.Text = "This text contains attributes.";
tl0.SetUnderline ( 0, "This".Length);
//.........这里部分代码省略.........
示例3: Apply
internal override void Apply(TextLayout la)
{
la.SetUnderline (StartIndex, Count);
}