• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Pango类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Pango的典型用法代码示例。如果您正苦于以下问题:C# Pango类的具体用法?C# Pango怎么用?C# Pango使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pango类属于命名空间,在下文中一共展示了Pango类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: FormattedTextImpl

        public FormattedTextImpl(
            Pango.Context context,
            string text,
            string fontFamily,
            double fontSize,
            FontStyle fontStyle,
            TextAlignment textAlignment,
            FontWeight fontWeight)
        {
            Contract.Requires<ArgumentNullException>(context != null);
            Contract.Requires<ArgumentNullException>(text != null);
            Layout = new Pango.Layout(context);
            _text = text;
            Layout.SetText(text);
            Layout.FontDescription = new Pango.FontDescription
            {
                Family = fontFamily,
                Size = Pango.Units.FromDouble(CorrectScale(fontSize)),
                Style = (Pango.Style)fontStyle,
                Weight = fontWeight.ToCairo()
            };

            Layout.Alignment = textAlignment.ToCairo();
            Layout.Attributes = new Pango.AttrList();
        }
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:25,代码来源:FormattedTextImpl.cs


示例3: 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


示例4: Write

 public static void Write(BinaryWriter file, Pango.Rectangle box)
 {
     file.Write(box.X);
     file.Write(box.Y);
     file.Write(box.Width);
     file.Write(box.Height);
 }
开发者ID:MagistrTot,项目名称:DGLE,代码行数:7,代码来源:DftUtil.cs


示例5: Layout

		public Layout (Pango.Context context) : base (IntPtr.Zero)
		{
			if (GetType () != typeof (Layout)) {
				throw new InvalidOperationException ("Can't override this constructor.");
			}
			Raw = pango_layout_new(context == null ? IntPtr.Zero : context.Handle);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:7,代码来源:Layout.cs


示例6: Draw

		public override void Draw (TextEditor editor, Cairo.Context cr, Pango.Layout layout, bool selected, int startOffset, int endOffset, double y, double startXPos, double endXPos)
		{
			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;
			
			bool drawOverlay = result.InspectionMark == IssueMarker.GrayOut;
			
			if (drawOverlay && editor.IsSomethingSelected) {
				var selectionRange = editor.SelectionRange;
				if (selectionRange.Contains (markerStart) && selectionRange.Contains (markerEnd))
					return;
				if (selectionRange.Contains (markerEnd))
					markerEnd = selectionRange.Offset;
				if (selectionRange.Contains (markerStart))
					markerStart = selectionRange.EndOffset;
				if (markerEnd <= markerStart)
					return;
			}
			
			double drawFrom;
			double drawTo;
				
			if (markerStart < startOffset && endOffset < markerEnd) {
				drawFrom = startXPos;
				drawTo = endXPos;
			} else {
				int start = startOffset < markerStart ? markerStart : startOffset;
				int end = endOffset < markerEnd ? endOffset : markerEnd;
				int /*lineNr,*/ x_pos;
				
				x_pos = layout.IndexToPos (start - startOffset).X;
				drawFrom = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
				x_pos = layout.IndexToPos (end - startOffset).X;
	
				drawTo = startXPos + (int)(x_pos / Pango.Scale.PangoScale);
			}
			
			drawFrom = System.Math.Max (drawFrom, editor.TextViewMargin.XOffset);
			drawTo = System.Math.Max (drawTo, editor.TextViewMargin.XOffset);
			if (drawFrom >= drawTo)
				return;
			
			double height = editor.LineHeight / 5;
			cr.Color = ColorName == null ? Color : editor.ColorStyle.GetColorFromDefinition (ColorName);
			if (drawOverlay) {
				cr.Rectangle (drawFrom, y, drawTo - drawFrom, editor.LineHeight);
				var color = editor.ColorStyle.Default.CairoBackgroundColor;
				color.A = 0.6;
				cr.Color = color;
				cr.Fill ();
			} else if (Wave) {	
				Pango.CairoHelper.ShowErrorUnderline (cr, drawFrom, y + editor.LineHeight - height, drawTo - drawFrom, height);
			} else {
				cr.MoveTo (drawFrom, y + editor.LineHeight - 1);
				cr.LineTo (drawTo, y + editor.LineHeight - 1);
				cr.Stroke ();
			}
		}
开发者ID:nocache,项目名称:monodevelop,代码行数:60,代码来源:ResultMarker.cs


示例7: RenderPlaceholderText

		internal static void RenderPlaceholderText (Gtk.Entry entry, Gtk.ExposeEventArgs args, string placeHolderText, ref Pango.Layout layout)
		{
			// The Entry's GdkWindow is the top level window onto which
			// the frame is drawn; the actual text entry is drawn into a
			// separate window, so we can ensure that for themes that don't
			// respect HasFrame, we never ever allow the base frame drawing
			// to happen
			if (args.Event.Window == entry.GdkWindow)
				return;

			if (entry.Text.Length > 0)
				return;

			if (layout == null) {
				layout = new Pango.Layout (entry.PangoContext);
				layout.FontDescription = entry.PangoContext.FontDescription.Copy ();
			}

			int wh, ww;
			args.Event.Window.GetSize (out ww, out wh);

			int width, height;
			layout.SetText (placeHolderText);
			layout.GetPixelSize (out width, out height);
			using (var gc = new Gdk.GC (args.Event.Window)) {
				gc.Copy (entry.Style.TextGC (Gtk.StateType.Normal));
				Color color_a = entry.Style.Base (Gtk.StateType.Normal).ToXwtValue ();
				Color color_b = entry.Style.Text (Gtk.StateType.Normal).ToXwtValue ();
				gc.RgbFgColor = color_b.BlendWith (color_a, 0.5).ToGtkValue ();

				args.Event.Window.DrawLayout (gc, 2, (wh - height) / 2 + 1, layout);
			}
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:33,代码来源:TextEntryBackendGtk2.cs


示例8: AddTag

 /// <summary>
 /// Adds a tag to a text buffer.
 /// </summary>
 public static void AddTag(this TextBuffer buff, string tagName, string foreground, string family, Pango.Style style)
 {
     TextTag tag = new TextTag(tagName);
     tag.Foreground = foreground;
     tag.Family = family;
     tag.Style = style;
     buff.TagTable.Add(tag);
 }
开发者ID:2015SoftwarePrinciples,项目名称:GTKTestWindow,代码行数:11,代码来源:GTKExtensions.cs


示例9: GetRange

		public void GetRange (out int start, out int len, out Pango.Script script)
		{
			IntPtr start_ptr;
			IntPtr end_ptr;

			pango_script_iter_get_range (Handle, out start_ptr, out end_ptr, out script);
			start = (int)g_utf8_pointer_to_offset (native_text, start_ptr);
			len = (int)g_utf8_pointer_to_offset (start_ptr, end_ptr);
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:9,代码来源:ScriptIter.cs


示例10: GetGlyphExtents

		public void GetGlyphExtents(uint glyph, Pango.Rectangle ink_rect, Pango.Rectangle logical_rect) {
			IntPtr native_ink_rect = GLib.Marshaller.StructureToPtrAlloc (ink_rect);
			IntPtr native_logical_rect = GLib.Marshaller.StructureToPtrAlloc (logical_rect);
			pango_font_get_glyph_extents(Handle, glyph, native_ink_rect, native_logical_rect);
			ink_rect = Pango.Rectangle.New (native_ink_rect);
			Marshal.FreeHGlobal (native_ink_rect);
			logical_rect = Pango.Rectangle.New (native_logical_rect);
			Marshal.FreeHGlobal (native_logical_rect);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:9,代码来源:Font.cs


示例11: LayoutProxy

			public LayoutProxy (LayoutCache layoutCache, Pango.Layout layout)
			{
				if (layoutCache == null)
					throw new ArgumentNullException ("layoutCache");
				if (layout == null)
					throw new ArgumentNullException ("layout");
				this.layoutCache = layoutCache;
				this.layout = layout;
			}
开发者ID:kdubau,项目名称:monodevelop,代码行数:9,代码来源:LayoutCache.cs


示例12: GetExtents

		public void GetExtents(ref Pango.Rectangle ink_rect, ref Pango.Rectangle logical_rect) {
			IntPtr native_ink_rect = GLib.Marshaller.StructureToPtrAlloc (ink_rect);
			IntPtr native_logical_rect = GLib.Marshaller.StructureToPtrAlloc (logical_rect);
			pango_layout_line_get_extents(Handle, native_ink_rect, native_logical_rect);
			ink_rect = Pango.Rectangle.New (native_ink_rect);
			Marshal.FreeHGlobal (native_ink_rect);
			logical_rect = Pango.Rectangle.New (native_logical_rect);
			Marshal.FreeHGlobal (native_logical_rect);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:9,代码来源:LayoutLine.cs


示例13: ExtentsRange

		public void ExtentsRange(int start, int end, Pango.Font font, Pango.Rectangle ink_rect, Pango.Rectangle logical_rect) {
			IntPtr native_ink_rect = GLib.Marshaller.StructureToPtrAlloc (ink_rect);
			IntPtr native_logical_rect = GLib.Marshaller.StructureToPtrAlloc (logical_rect);
			pango_glyph_string_extents_range(Handle, start, end, font == null ? IntPtr.Zero : font.Handle, native_ink_rect, native_logical_rect);
			ink_rect = Pango.Rectangle.New (native_ink_rect);
			Marshal.FreeHGlobal (native_ink_rect);
			logical_rect = Pango.Rectangle.New (native_logical_rect);
			Marshal.FreeHGlobal (native_logical_rect);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:9,代码来源:GlyphString.cs


示例14: GetClusterExtents

		public void GetClusterExtents(out Pango.Rectangle ink_rect, out Pango.Rectangle logical_rect) {
			IntPtr native_ink_rect = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Pango.Rectangle)));
			IntPtr native_logical_rect = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Pango.Rectangle)));
			pango_layout_iter_get_cluster_extents(Handle, native_ink_rect, native_logical_rect);
			ink_rect = Pango.Rectangle.New (native_ink_rect);
			Marshal.FreeHGlobal (native_ink_rect);
			logical_rect = Pango.Rectangle.New (native_logical_rect);
			Marshal.FreeHGlobal (native_logical_rect);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:9,代码来源:LayoutIter.cs


示例15: CopyModified

        public static FontDescription CopyModified(this FontDescription font, double? scale = null, Pango.Weight? weight = null)
        {
            font = font.Copy ();

            if (scale.HasValue)
                Scale (font, scale.Value);

            if (weight.HasValue)
                font.Weight = weight.Value;

            return font;
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:12,代码来源:FontService.cs


示例16: FromPangoStyle

        // Pango Style sounds like some sort of dance
        private static FontStyle FromPangoStyle(Pango.Style pangoStyle, Pango.Weight pangoWeight)
        {
            FontStyle result = FontStyle.Regular;

            if (pangoWeight == Pango.Weight.Bold)
                result |= FontStyle.Bold;

            if (pangoStyle == Pango.Style.Italic)
                result |= FontStyle.Italic;

            return FontStyle.Regular;
        }
开发者ID:jasemagee,项目名称:FontWhiz,代码行数:13,代码来源:FontResolver.cs


示例17: ContextSetShapeRenderer

		public static void ContextSetShapeRenderer(Pango.Context context, Pango.CairoShapeRendererFunc func) {
			PangoSharp.CairoShapeRendererFuncWrapper func_wrapper = new PangoSharp.CairoShapeRendererFuncWrapper (func);
			IntPtr data;
			GLib.DestroyNotify dnotify;
			if (func == null) {
				data = IntPtr.Zero;
				dnotify = null;
			} else {
				data = (IntPtr) GCHandle.Alloc (func_wrapper);
				dnotify = GLib.DestroyHelper.NotifyHandler;
			}
			pango_cairo_context_set_shape_renderer(context == null ? IntPtr.Zero : context.Handle, func_wrapper.NativeDelegate, data, dnotify);
		}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:13,代码来源:CairoHelper.cs


示例18: ParseMarkup

		public static bool ParseMarkup (string markup, char accel_marker, out Pango.AttrList attrs, out string text, out char accel_char)
		{
			uint ucs4_accel_char;
			IntPtr text_as_native;
			IntPtr attrs_handle;
			IntPtr native_markup = GLib.Marshaller.StringToPtrGStrdup (markup);
			bool result = pango_parse_markup (native_markup, -1, GLib.Marshaller.CharToGUnichar (accel_marker), out attrs_handle, out text_as_native, out ucs4_accel_char, IntPtr.Zero);
			GLib.Marshaller.Free (native_markup);
			accel_char = GLib.Marshaller.GUnicharToChar (ucs4_accel_char);
			text = GLib.Marshaller.Utf8PtrToString (text_as_native);
			attrs = new Pango.AttrList (attrs_handle);
			return result;
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:13,代码来源:Global.cs


示例19: ApplyAttrs

		public GlyphItem[] ApplyAttrs (string text, Pango.AttrList list)
		{
			IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup (text);
			IntPtr list_handle = pango_glyph_item_apply_attrs (ref this, native_text, list.Handle);
			GLib.Marshaller.Free (native_text);
			if (list_handle == IntPtr.Zero)
				return new GlyphItem [0];
			GLib.SList item_list = new GLib.SList (list_handle, typeof (GlyphItem));
			GlyphItem[] result = new GlyphItem [item_list.Count];
			int i = 0;
			foreach (GlyphItem item in item_list)
				result [i++] = item;
			return result;
		}
开发者ID:liberostelios,项目名称:gtk-sharp,代码行数:14,代码来源:GlyphItem.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Pango.FontDescription类代码示例发布时间:2022-05-24
下一篇:
C# PanelPreferences类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap