private void CreateIcons(CommandGroup cmdGroup, Type cmdGroupType, Enum[] cmds, IconsConverter iconsConv) { IIcon mainIcon = null; if (!cmdGroupType.TryGetAttribute <IconAttribute>(a => mainIcon = a.Icon)) { //TODO: add default icon mainIcon = new MasterIcon() { Icon = new System.Drawing.Bitmap(12, 12) }; } var iconList = cmds.Select(c => { IIcon cmdIcon = null; if (!c.TryGetAttribute <IconAttribute>(a => cmdIcon = a.Icon)) { //TODO: add default icon cmdIcon = new MasterIcon() { Icon = new System.Drawing.Bitmap(12, 12) }; } return(cmdIcon); }).ToArray(); if (m_App.SupportsHighResIcons()) { var iconsList = iconsConv.ConvertIcon(mainIcon, true); cmdGroup.MainIconList = iconsList; cmdGroup.IconList = iconsConv.ConvertIconsGroup(iconList, true); } else { var mainIconPath = iconsConv.ConvertIcon(mainIcon, false); var smallIcon = mainIconPath[0]; var largeIcon = mainIconPath[1]; cmdGroup.SmallMainIcon = smallIcon; cmdGroup.LargeMainIcon = largeIcon; var iconListPath = iconsConv.ConvertIconsGroup(iconList, true); var smallIconList = iconListPath[0]; var largeIconList = iconListPath[1]; cmdGroup.SmallIconList = smallIconList; cmdGroup.LargeIconList = largeIconList; } }
private void TryCreateIcons() { var iconsConverter = new IconsConverter( MacroFeatureIconInfo.GetLocation(this.GetType()), false); MacroFeatureIcon regIcon = null; MacroFeatureIcon highIcon = null; MacroFeatureIcon suppIcon = null; this.GetType().TryGetAttribute <FeatureIconAttribute>(a => { regIcon = a.Regular; highIcon = a.Highlighted; suppIcon = a.Suppressed; }); if (regIcon == null) { Image icon = null; this.GetType().TryGetAttribute <Common.Attributes.IconAttribute>(a => { icon = a.Icon; }); if (icon == null) { icon = Resources.default_icon; } regIcon = new MasterIcon(MacroFeatureIconInfo.RegularName) { Icon = icon }; } if (highIcon == null) { highIcon = regIcon.Clone(MacroFeatureIconInfo.HighlightedName); } if (suppIcon == null) { suppIcon = regIcon.Clone(MacroFeatureIconInfo.SuppressedName); } //Creation of icons may fail if user doesn't have write permissions or icon is locked try { iconsConverter.ConvertIcon(regIcon, true); iconsConverter.ConvertIcon(suppIcon, true); iconsConverter.ConvertIcon(highIcon, true); iconsConverter.ConvertIcon(regIcon, false); iconsConverter.ConvertIcon(suppIcon, false); iconsConverter.ConvertIcon(highIcon, false); } catch (Exception ex) { Logger.Log(ex); } }