本文整理汇总了C#中Pango.SetText方法的典型用法代码示例。如果您正苦于以下问题:C# Pango.SetText方法的具体用法?C# Pango.SetText怎么用?C# Pango.SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pango
的用法示例。
在下文中一共展示了Pango.SetText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ellipsize
public static string Ellipsize(Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width)
{
int width, tmp;
layout.SetText (newtext);
layout.GetPixelSize (out width, out tmp);
if (width < bound)
return newtext;
if (bound <= ellipsis_width)
return ellipsis;
string ellipsized = "";
int i = 0;
i = (bound - ellipsis_width) / (en_width);
if (i >= newtext.Length)
i = 0;
ellipsized = newtext.Substring (0, i);
while (true)
{
ellipsized = ellipsized + newtext[i];
layout.SetText (ellipsized);
layout.GetPixelSize (out width, out tmp);
if (i == newtext.Length - 1) {
ellipsized = "";
i = 0;
continue;
}
if (width > bound - ellipsis_width)
break;
i++;
}
ellipsized = ellipsized.Remove (ellipsized.Length - 1, 1);
ellipsized += ellipsis;
return ellipsized;
}
示例2: DrawHorizontalSectionIndicator
protected void DrawHorizontalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, double w, out double h)
{
cr.MoveTo(x,y);
cr.LineTo(x,y+SectionSerifeWidth*2);
cr.MoveTo(x,y+SectionSerifeWidth);
cr.LineTo(x+w,y+SectionSerifeWidth);
cr.MoveTo(x+w,y);
cr.LineTo(x+w,y+SectionSerifeWidth*2);
cr.Color = new Cairo.Color(0, 0, 0);
cr.LineWidth = 1;
cr.Stroke();
layout.Width = (int)(w*Pango.Scale.PangoScale);
layout.Alignment = Pango.Alignment.Center;
layout.SetText (text);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
cr.Color = new Cairo.Color(0, 0, 0);
cr.MoveTo(x,y+SectionSerifeWidth*2);
Pango.CairoHelper.ShowLayout (cr, layout);
int lw,lh;
layout.GetPixelSize(out lw, out lh);
h=(double)lh+SectionSerifeWidth*2;
}
示例3: Ellipsize
public static string Ellipsize (Pango.Layout layout, string newtext, int bound, int ellipsis_width, int en_width)
{
int width, tmp;
layout.SetText (newtext);
layout.GetPixelSize (out width, out tmp);
if (width < bound)
return newtext;
if (bound <= ellipsis_width)
return ellipsis;
string ellipsized = "";
int i = 0;
//make a guess of where to start
i = (bound - ellipsis_width) / (en_width);
if (i >= newtext.Length)
i = 0;
ellipsized = newtext.Substring (0, i);
//add chars one by one to determine how many are allowed
while (true)
{
ellipsized = ellipsized + newtext[i];
layout.SetText (ellipsized);
layout.GetPixelSize (out width, out tmp);
if (i == newtext.Length - 1) {
//bad guess, start from the beginning
ellipsized = "";
i = 0;
continue;
}
if (width > bound - ellipsis_width)
break;
i++;
}
ellipsized = ellipsized.Remove (ellipsized.Length - 1, 1);
ellipsized += ellipsis;
return ellipsized;
}
示例4: UpdateLayout
private void UpdateLayout(Pango.Layout layout, string text)
{
string final_text = GetFormattedText (text);
if (SingleParagraphMode && final_text.IndexOfAny (lfcr) >= 0) {
final_text = final_text.Replace ("\r\n", "\x20").Replace ('\n', '\x20').Replace ('\r', '\x20');
}
if (use_markup) {
layout.SetMarkup (final_text);
} else {
layout.SetText (final_text);
}
}
示例5: DrawVerticalSectionIndicator
protected void DrawVerticalSectionIndicator(string text, Cairo.Context cr, Pango.Layout layout, double x, double y, out double w, double h)
{
cr.MoveTo(x,y);
cr.LineTo(x+SectionSerifeWidth*2,y);
cr.MoveTo(x+SectionSerifeWidth,y);
cr.LineTo(x+SectionSerifeWidth,y+h);
cr.MoveTo(x,y+h);
cr.LineTo(x+SectionSerifeWidth*2,y+h);
cr.Color = new Cairo.Color(0, 0, 0);
cr.LineWidth = 1;
layout.Alignment = Pango.Alignment.Left;
layout.SetText (text);
layout.Ellipsize = EllipsizeMode.Middle;
layout.Justify = true;
int lh,lw;
layout.GetPixelSize(out lw, out lh);
w=(double)lw+SectionSerifeWidth*2;
cr.Color = new Cairo.Color(0, 0, 0);
cr.MoveTo(x+SectionSerifeWidth*2,y+(h-lh)/2);
Pango.CairoHelper.ShowLayout (cr, layout);
}
示例6: GetPixelHeightSize
public static int GetPixelHeightSize(Text aText, Pango.Layout layout)
{
layout.SetText(aText.TextValue);
layout.FontDescription = Pango.FontDescription.FromString(aText.FontDescription);
int pixelSizeWidth, pixelSizeHeight;
layout.GetPixelSize(out pixelSizeWidth, out pixelSizeHeight);
return pixelSizeHeight;
}