static void InitializeIcons(AddInTreeNode treeNode) { extensionHashtable[".PRJX"] = "Icons.16x16.SolutionIcon"; extensionHashtable[".CMBX"] = "Icons.16x16.CombineIcon"; extensionHashtable[".SLN"] = "Icons.16x16.CombineIcon"; IconDescriptor[] icons = (IconDescriptor[])treeNode.BuildChildItems(null).ToArray(typeof(IconDescriptor)); for (int i = 0; i < icons.Length; ++i) { IconDescriptor iconCodon = icons[i]; string imageName = iconCodon.Resource != null ? iconCodon.Resource : iconCodon.Id; if (iconCodon.Extensions != null) { foreach (string ext in iconCodon.Extensions) { extensionHashtable[ext.ToUpperInvariant()] = imageName; } } //if (iconCodon.Language != null) //{ // projectFileHashtable[iconCodon.Language] = imageName; //} } }
public ICollection <IconDescriptor> GetIcons(CultureInfo culture) { if (Icons == null) { IconDescriptor png48 = new IconDescriptor { ColorDepth = 32, Width = 48, Height = 48, MimeType = "image/png", GetIconURLDelegate = (address, info) => GetIconUrl(48, "png") }; IconDescriptor png120 = new IconDescriptor { ColorDepth = 32, Width = 120, Height = 120, MimeType = "image/png", GetIconURLDelegate = (address, info) => GetIconUrl(120, "png") }; IconDescriptor png256 = new IconDescriptor { ColorDepth = 32, Width = 256, Height = 256, MimeType = "image/png", GetIconURLDelegate = (address, info) => GetIconUrl(256, "png") }; IconDescriptor jpg48 = new IconDescriptor { ColorDepth = 32, Width = 48, Height = 48, MimeType = "image/jpg", GetIconURLDelegate = (address, info) => GetIconUrl(48, "jpg") }; IconDescriptor jpg120 = new IconDescriptor { ColorDepth = 32, Width = 120, Height = 120, MimeType = "image/jpg", GetIconURLDelegate = (address, info) => GetIconUrl(120, "jpg") }; IconDescriptor jpg256 = new IconDescriptor { ColorDepth = 32, Width = 256, Height = 256, MimeType = "image/jpg", GetIconURLDelegate = (address, info) => GetIconUrl(256, "jpg") }; Icons = new List <IconDescriptor> { png48, png120, png256, jpg48, jpg120, jpg256 }; } return(Icons); }
public ICollection <IconDescriptor> GetIcons(CultureInfo culture) { if (_iconDescriptors == null) { IconDescriptor icon120 = new IconDescriptor { ColorDepth = 24, Width = 120, Height = 120, MimeType = "image/png", GetIconURLDelegate = (address, info) => GetIconUrl(120) }; IconDescriptor icon256 = new IconDescriptor { ColorDepth = 24, Width = 256, Height = 256, MimeType = "image/png", GetIconURLDelegate = (address, info) => GetIconUrl(256) }; _iconDescriptors = new List <IconDescriptor> { icon120, icon256 }; } return(_iconDescriptors); }
private void LoadIcons() { iconDescriptors.Clear(); var doc = XDocument.Load(GetFileName()); var root = doc.Root; if (root == null) { return; } foreach (var map in root.Elements()) { var mapName = map.GetAttributeValue("name"); var list = new List <IconDescriptor>(); foreach (var element in map.Elements()) { var name = element.GetAttributeValue("n"); var fileName = element.GetAttributeValue("p"); var c = element.GetAttributeValue("c"); var parts = c.Split(','); int x; int y; int.TryParse(parts[0], out x); int.TryParse(parts[1], out y); var iconDescriptor = new IconDescriptor { Name = name, FileName = fileName, MapName = mapName, X = x, Y = y }; list.Add(iconDescriptor); } iconDescriptors[mapName] = list; var checkBox = new CheckBox { HorizontalAlignment = HorizontalAlignment.Stretch, Content = mapName, Tag = mapName }; checkBox.Checked += Search; checkBox.Unchecked += Search; checkBox.PreviewMouseDown += Search; SearchFilterComboBox.Items.Add(checkBox); } }
public void DrawTheIcon(IconDescriptor icon, RectangleF bounds) { if (icon == null) { graphics.FillRectangle(Brushes.Black, bounds); return; } // if we have a sub-image, reduce the main bounds to accommodate it const float subImageReduction = .8f; RectangleF mainBounds = (icon.Sub == null) ? bounds : new RectangleF(bounds.X, bounds.Y, bounds.Width * subImageReduction, bounds.Height * subImageReduction); // -- Main - Background if (icon.BackgroundImg != default) { graphics.DrawImageFitBoth(imageDrawer.GetImage(icon.BackgroundImg), mainBounds); } // -- Main - Content -- if (icon.Text != null || icon.ContentImg != default) { var contentBounds = new RectangleF( mainBounds.X, mainBounds.Y + mainBounds.Height * 0.22f, // should be 20% but it looks a little high mainBounds.Width, mainBounds.Height * .6f // 60% ); // Content - Text if (icon.Text != null) { Font font = new Font(ResourceImages.Singleton.Fonts.Families[0], contentBounds.Height, GraphicsUnit.Pixel); StringFormat center = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; graphics.DrawString(icon.Text, font, Brushes.Black, contentBounds, center); } // Content - Images if (icon.ContentImg != default) { if (icon.ContentImg2 != default) { const float scale = .75f; float w = contentBounds.Width * scale, h = contentBounds.Height * scale; var cb1 = new RectangleF(contentBounds.X, contentBounds.Y, w, h); var cb2 = new RectangleF(contentBounds.X + contentBounds.Width * (1f - scale), contentBounds.Y + contentBounds.Height * (1f - scale), w, h); graphics.DrawImageFitBoth(imageDrawer.GetImage(icon.ContentImg), cb1); graphics.DrawImageFitBoth(imageDrawer.GetImage(icon.ContentImg2), cb2); } else { graphics.DrawImageFitBoth(imageDrawer.GetImage(icon.ContentImg), contentBounds); } } } // -- Super -- if (icon.Super != null) { float dim = bounds.Width * .4f; // drawing this at the bottom instead of the top because presence is covering top var superRect = new RectangleF(bounds.X, bounds.Bottom - dim, dim, dim); DrawTheIcon(icon.Super, superRect); } // -- Sub - (additional action) -- if (icon.Sub != null) { // put the subRect in the bottom right corner float subDim = bounds.Width * .5f; var subRect = new RectangleF(bounds.Right - subDim, bounds.Bottom - subDim, subDim, subDim); DrawTheIcon(icon.Sub, subRect); } // -- Big Sub -- if (icon.BigSub != null) { // put the subRect in the bottom right corner float subDim = bounds.Width; var subRect = new RectangleF(bounds.Right - subDim / 2, bounds.Bottom - subDim * 3 / 4, subDim, subDim); DrawTheIcon(icon.BigSub, subRect); } }