Xwt.Drawing.Image ExpandImageVertically(Xwt.Drawing.Image img, int newHeight) { if (newHeight <= img.Height) { return(img); } Xwt.Drawing.ImageBuilder ib = new Xwt.Drawing.ImageBuilder(img.Width, newHeight); int h1 = (int)img.Height / 2; int h2 = (int)img.Height - h1; var ctx = ib.Context; ctx.Save(); ctx.Rectangle(0, 0, img.Width, h1); ctx.Clip(); ctx.DrawImage(img, 0, 0); ctx.Restore(); ctx.Save(); ctx.Rectangle(0, newHeight - h2, img.Width, h2); ctx.Clip(); ctx.DrawImage(img, 0, newHeight - img.Height); ctx.Restore(); ctx.Rectangle(0, h1, img.Width, newHeight - h1 - h2); ctx.Clip(); ctx.DrawImage(img, 0, 0, img.Width, newHeight); return(ib.ToVectorImage()); }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { ProjectFile file = (ProjectFile)dataObject; nodeInfo.Label = GLib.Markup.EscapeText(file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName); if (!File.Exists(file.FilePath)) { nodeInfo.Label = "<span foreground='red'>" + nodeInfo.Label + "</span>"; } nodeInfo.Icon = DesktopService.GetIconForFile(file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && nodeInfo.Icon != null) { var overlay = ImageService.GetIcon("md-link-overlay").WithSize(Xwt.IconSize.Small); var cached = Context.GetComposedIcon(nodeInfo.Icon, overlay); if (cached != null) { nodeInfo.Icon = cached; } else { var ib = new Xwt.Drawing.ImageBuilder(nodeInfo.Icon.Width, nodeInfo.Icon.Height); ib.Context.DrawImage(nodeInfo.Icon, 0, 0); ib.Context.DrawImage(overlay, 0, 0); var res = ib.ToVectorImage(); ib.Dispose(); Context.CacheComposedIcon(nodeInfo.Icon, overlay, res); nodeInfo.Icon = res; } } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { ProtobuildPackage package = (ProtobuildPackage) dataObject; nodeInfo.Icon = Context.GetIcon(MonoDevelop.Ide.Gui.Stock.Reference); if (package.IsBinary) { var overlay = ImageService.GetIcon ("md-command").WithSize (Xwt.IconSize.Small); var cached = Context.GetComposedIcon (nodeInfo.Icon, overlay); if (cached != null) nodeInfo.Icon = cached; else { var ib = new Xwt.Drawing.ImageBuilder (nodeInfo.Icon.Width, nodeInfo.Icon.Height); ib.Context.DrawImage (nodeInfo.Icon, 0, 0); ib.Context.DrawImage (overlay, 8, 8, 8, 8); var res = ib.ToVectorImage (); ib.Dispose (); Context.CacheComposedIcon (nodeInfo.Icon, overlay, res); nodeInfo.Icon = res; } } nodeInfo.Label = GettextCatalog.GetString( "{0} <span foreground='grey'><span size='small'>({1}@{2})</span></span>", GLib.Markup.EscapeText(package.Folder), GLib.Markup.EscapeText(package.Uri), GLib.Markup.EscapeText(package.GitRef)); }
static Xwt.Drawing.Image CreateColorIcon(string name) { var color = Xwt.Drawing.Color.FromName(name); using (var ib = new Xwt.Drawing.ImageBuilder(16, 16)) { ib.Context.Rectangle(0, 0, 16, 16); ib.Context.SetColor(color); ib.Context.Fill(); return(ib.ToVectorImage()); } }
public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { ProtobuildContentSourceRule rule = (ProtobuildContentSourceRule) dataObject; nodeInfo.Icon = Context.GetIcon(Stock.OpenReferenceFolder); nodeInfo.ClosedIcon = Context.GetIcon(Stock.ClosedReferenceFolder); if (rule.Primary) { var overlay = ImageService.GetIcon ("md-done").WithSize (Xwt.IconSize.Small); var cached = Context.GetComposedIcon (nodeInfo.Icon, overlay); if (cached != null) nodeInfo.Icon = cached; else { var ib = new Xwt.Drawing.ImageBuilder (nodeInfo.Icon.Width, nodeInfo.Icon.Height); ib.Context.DrawImage (nodeInfo.Icon, 0, 0); ib.Context.DrawImage (overlay, 8, 8, 8, 8); var res = ib.ToVectorImage (); ib.Dispose (); Context.CacheComposedIcon (nodeInfo.Icon, overlay, res); nodeInfo.Icon = res; } cached = Context.GetComposedIcon (nodeInfo.ClosedIcon, overlay); if (cached != null) nodeInfo.ClosedIcon = cached; else { var ib = new Xwt.Drawing.ImageBuilder (nodeInfo.ClosedIcon.Width, nodeInfo.ClosedIcon.Height); ib.Context.DrawImage (nodeInfo.ClosedIcon, 0, 0); ib.Context.DrawImage (overlay, 8, 8, 8, 8); var res = ib.ToVectorImage (); ib.Dispose (); Context.CacheComposedIcon (nodeInfo.ClosedIcon, overlay, res); nodeInfo.ClosedIcon = res; } } nodeInfo.Label = GettextCatalog.GetString( "{0} <span foreground='grey'><span size='small'>(files matching {1})</span></span>", GLib.Markup.EscapeText(rule.Include), GLib.Markup.EscapeText(rule.Match)); }
static Xwt.Drawing.Image CreateColorIcon (string name) { var color = Xwt.Drawing.Color.FromName (name); using (var ib = new Xwt.Drawing.ImageBuilder (16, 16)) { ib.Context.Rectangle (0, 0, 16, 16); ib.Context.SetColor (color); ib.Context.Fill (); return ib.ToVectorImage (); } }
public override void BuildNode (ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo) { ProjectFile file = (ProjectFile) dataObject; nodeInfo.Label = GLib.Markup.EscapeText (file.Link.IsNullOrEmpty ? file.FilePath.FileName : file.Link.FileName); if (!File.Exists (file.FilePath)) { nodeInfo.Label = "<span foreground='red'>" + nodeInfo.Label + "</span>"; } nodeInfo.Icon = DesktopService.GetIconForFile (file.FilePath, Gtk.IconSize.Menu); if (file.IsLink && nodeInfo.Icon != null) { var overlay = ImageService.GetIcon ("md-link-overlay").WithSize (Xwt.IconSize.Small); var cached = Context.GetComposedIcon (nodeInfo.Icon, overlay); if (cached != null) nodeInfo.Icon = cached; else { var ib = new Xwt.Drawing.ImageBuilder (nodeInfo.Icon.Width, nodeInfo.Icon.Height); ib.Context.DrawImage (nodeInfo.Icon, 0, 0); ib.Context.DrawImage (overlay, 0, 0); var res = ib.ToVectorImage (); ib.Dispose (); Context.CacheComposedIcon (nodeInfo.Icon, overlay, res); nodeInfo.Icon = res; } } }
Xwt.Drawing.Image ExpandImageVertically (Xwt.Drawing.Image img, int newHeight) { if (newHeight <= img.Height) return img; Xwt.Drawing.ImageBuilder ib = new Xwt.Drawing.ImageBuilder (img.Width, newHeight); int h1 = (int)img.Height / 2; int h2 = (int)img.Height - h1; var ctx = ib.Context; ctx.Save (); ctx.Rectangle (0, 0, img.Width, h1); ctx.Clip (); ctx.DrawImage (img, 0, 0); ctx.Restore (); ctx.Save (); ctx.Rectangle (0, newHeight - h2, img.Width, h2); ctx.Clip (); ctx.DrawImage (img, 0, newHeight - img.Height); ctx.Restore (); ctx.Rectangle (0, h1, img.Width, newHeight - h1 - h2); ctx.Clip (); ctx.DrawImage (img, 0, 0, img.Width, newHeight); return ib.ToVectorImage (); }