public Bitmap GetIcon(ToolComponent component) { Assembly asm = component.LoadAssembly(); Type type = asm.GetType(component.FullName); Bitmap b = null; if (type != null) { object[] attributes = type.GetCustomAttributes(false); foreach (object attr in attributes) { if (attr is ToolboxBitmapAttribute) { ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr; b = new Bitmap(toolboxBitmapAttribute.GetImage(type)); b.MakeTransparent(); break; } } } if (b == null) { try { Stream imageStream = asm.GetManifestResourceStream(component.FullName + ".bmp"); if (imageStream != null) { b = new Bitmap(Image.FromStream(imageStream)); b.MakeTransparent(); } } catch (Exception e) { ICSharpCode.Core.LoggingService.Warn("ComponentLibraryLoader.GetIcon: " + e.Message); } } // TODO: Maybe default icon needed ??!?! return(b); }
public Bitmap GetIcon(ToolComponent component) { Assembly asm = component.LoadAssembly(); Type type = asm.GetType(component.FullName); Bitmap b = null; if (type != null) { object[] attributes = type.GetCustomAttributes(false); foreach (object attr in attributes) { if (attr is ToolboxBitmapAttribute) { ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr; b = new Bitmap(toolboxBitmapAttribute.GetImage(type)); b.MakeTransparent(); break; } } } if (b == null) { try { Stream imageStream = asm.GetManifestResourceStream(component.FullName + ".bmp"); if (imageStream != null) { b = new Bitmap(Image.FromStream(imageStream)); b.MakeTransparent(); } } catch (Exception e) { ICSharpCode.Core.LoggingService.Warn("ComponentLibraryLoader.GetIcon: " + e.Message); } } // TODO: Maybe default icon needed ??!?! return b; }