当前位置: 首页>>代码示例>>C#>>正文


C# Pango.SetText方法代码示例

本文整理汇总了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;
 }
开发者ID:RoDaniel,项目名称:featurehouse,代码行数:33,代码来源:elabel.cs

示例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;
        }
开发者ID:konne88,项目名称:MyInventory,代码行数:25,代码来源:PaperPreview.cs

示例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;
	}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:47,代码来源:elabel.cs

示例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);
     }
 }
开发者ID:knocte,项目名称:hyena,代码行数:12,代码来源:ColumnCellText.cs

示例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);
 }
开发者ID:konne88,项目名称:MyInventory,代码行数:21,代码来源:PaperPreview.cs

示例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;
        }
开发者ID:TheProjecter,项目名称:zaspe-sharp,代码行数:10,代码来源:Utils.cs


注:本文中的Pango.SetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。