本文整理汇总了C#中Gtk.RenderIcon方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.RenderIcon方法的具体用法?C# Gtk.RenderIcon怎么用?C# Gtk.RenderIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk
的用法示例。
在下文中一共展示了Gtk.RenderIcon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadIcon
public static Gdk.Pixbuf LoadIcon (Gtk.Widget widget, string name, Gtk.IconSize size)
{
Gdk.Pixbuf res = widget.RenderIcon (name, size, null);
if ((res != null)) {
return res;
} else {
int sz;
int sy;
global::Gtk.Icon.SizeLookup (size, out sz, out sy);
try {
return Gtk.IconTheme.Default.LoadIcon (name, sz, 0);
} catch (System.Exception) {
if ((name != "gtk-missing-image")) {
return Stetic.IconLoader.LoadIcon (widget, "gtk-missing-image", size);
} else {
Gdk.Pixmap pmap = new Gdk.Pixmap (Gdk.Screen.Default.RootWindow, sz, sz);
Gdk.GC gc = new Gdk.GC (pmap);
gc.RgbFgColor = new Gdk.Color (255, 255, 255);
pmap.DrawRectangle (gc, true, 0, 0, sz, sz);
gc.RgbFgColor = new Gdk.Color (0, 0, 0);
pmap.DrawRectangle (gc, false, 0, 0, (sz - 1), (sz - 1));
gc.SetLineAttributes (3, Gdk.LineStyle.Solid, Gdk.CapStyle.Round, Gdk.JoinStyle.Round);
gc.RgbFgColor = new Gdk.Color (255, 0, 0);
pmap.DrawLine (gc, (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)), ((sz - 1) - (sz / 4)));
pmap.DrawLine (gc, ((sz - 1) - (sz / 4)), (sz / 4), (sz / 4), ((sz - 1) - (sz / 4)));
return Gdk.Pixbuf.FromDrawable (pmap, pmap.Colormap, 0, 0, 0, 0, sz, sz);
}
}
}
}
示例2: SetRecognizeIcon
void SetRecognizeIcon(Gtk.Image img, float confidence)
{
if(confidence == 2) //Исправлено пользователем.
{
img.Pixbuf = img.RenderIcon(Stock.Apply, IconSize.Button, "");
img.TooltipText = String.Format("Исправлено.");
}
else if(confidence > 0.8)
{
img.Pixbuf = img.RenderIcon(Stock.Yes, IconSize.Button, "");
img.TooltipText = String.Format("ОК. Доверие: {0}", confidence);
}
else if(confidence == -1) //Распознования не проводилось
{
img.Pixbuf = img.RenderIcon(Stock.DialogQuestion, IconSize.Button, "");
img.TooltipText = String.Format("Распознование не проводилось.");
}
else if(confidence == -2) //Результат не прошел проверку.
{
img.Pixbuf = img.RenderIcon(Stock.No, IconSize.Button, "");
img.TooltipText = String.Format("Результат не прошёл проверку.");
}
else
{
img.Pixbuf = img.RenderIcon(Stock.DialogWarning, IconSize.Button, "");
img.TooltipText = String.Format("Не точно. Доверие: {0}", confidence);
}
}
示例3: LoadStockIcon
/// <summary>
/// Loads the stock icon for a given name and size.
/// </summary>
/// <returns>The stock icon.</returns>
/// <param name="widget">Widget to get the icon for. Themes can modify the stock icon for a specific widget.</param>
/// <param name="name">Name.</param>
/// <param name="size">Size as Gtk.IconSize.</param>
public static Gdk.Pixbuf LoadStockIcon(Gtk.Widget widget, string name, Gtk.IconSize size)
{
Gdk.Pixbuf res = widget.RenderIcon (name, size, null);
if ((res != null)) {
return res;
} else {
return LoadMissingIcon (size);
}
}
示例4: Render
protected override void Render (Gdk.Drawable window, Gtk.Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, Gtk.CellRendererState flags)
{
int x;
int y;
int width;
int height;
Gdk.Pixbuf buf = widget.RenderIcon(_stockId, Gtk.IconSize.Menu, string.Empty);
Gtk.StateType state = Gtk.StateType.Normal;
if (Prelight)
{
state = Gtk.StateType.Prelight;
}
if (Active)
{
state = Gtk.StateType.Active;
}
GetSize(widget, ref cell_area, out x, out y, out width, out height);
Gtk.Style.PaintBox(widget.Style, window, state,
Gtk.ShadowType.In, cell_area, widget, "buttondefault",
cell_area.X + x, cell_area.Y + y,
width, height);
Gdk.GC gc = new Gdk.GC(window);
if (buf != null)
{
int xOffset = 2 + ((width - buf.Width) / 2) + cell_area.X;
int yOffset = 2 + ((height - buf.Height) / 2) + cell_area.Y;
window.DrawPixbuf(gc, buf, 0, 0, xOffset, yOffset, buf.Width, buf.Height, Gdk.RgbDither.None, 0, 0);
}
_x = cell_area.X + x;
_y = cell_area.Y + y;
}
示例5: RenderDoc
public void RenderDoc(Cairo.Context CairoContext, Gtk.Widget widget, int height)
{
Pixbuf icon = widget.RenderIcon (_IconName, _IconsSize, "");
Pango.Layout Layout = Pango.CairoHelper.CreateLayout (CairoContext);
Layout.FontDescription = _font;
Layout.SetMarkup (_Text);
int layout_x = icon.Width + 5;
int layoutWidth, layoutHeight;
Layout.GetPixelSize (out layoutWidth, out layoutHeight);
int layout_y = (height - layoutHeight) / 2;
CairoContext.MoveTo ((double) layout_x, (double) layout_y);
Pango.CairoHelper.ShowLayout (CairoContext, Layout);
Gdk.CairoHelper.SetSourcePixbuf (CairoContext, icon, 0, 0);
CairoContext.Paint ();
Layout.FontDescription.Dispose ();
Layout.Dispose ();
}