private void CreateIcons(CommandGroup cmdGroup, CommandGroupSpec cmdBar, IconsConverter iconsConv) { var mainIcon = cmdBar.Icon; if (mainIcon == null) { mainIcon = Defaults.Icon; } Image[] iconList = null; if (cmdBar.Commands != null) { iconList = cmdBar.Commands.Select(c => IconsConverter.FromXImage(c.Icon ?? Defaults.Icon)).ToArray(); } //NOTE: if commands are not used, main icon will fail if toolbar commands image list is not specified, so it is required to specify it explicitly if (CompatibilityUtils.SupportsHighResIcons(m_App.Sw, CompatibilityUtils.HighResIconsScope_e.CommandManager)) { var iconsList = iconsConv.ConvertIcon(new CommandGroupHighResIcon(IconsConverter.FromXImage(mainIcon))); cmdGroup.MainIconList = iconsList; if (iconList != null && iconList.Any()) { cmdGroup.IconList = iconsConv.ConvertIconsGroup( iconList.Select(i => new CommandGroupHighResIcon(i)).ToArray()); } else { cmdGroup.IconList = iconsList; } } else { var mainIconPath = iconsConv.ConvertIcon(new CommandGroupIcon(IconsConverter.FromXImage(mainIcon))); var smallIcon = mainIconPath[0]; var largeIcon = mainIconPath[1]; cmdGroup.SmallMainIcon = smallIcon; cmdGroup.LargeMainIcon = largeIcon; if (iconList != null && iconList.Any()) { var iconListPath = iconsConv.ConvertIconsGroup(iconList.Select(i => new CommandGroupIcon(i)).ToArray()); var smallIconList = iconListPath[0]; var largeIconList = iconListPath[1]; cmdGroup.SmallIconList = smallIconList; cmdGroup.LargeIconList = largeIconList; } else { cmdGroup.SmallIconList = smallIcon; cmdGroup.LargeIconList = largeIcon; } } }
protected IFeature InsertComFeatureBase(string[] paramNames, int[] paramTypes, string[] paramValues, int[] dimTypes, double[] dimValues, object[] selection, object[] editBodies) { if (!typeof(SwMacroFeatureDefinition).IsAssignableFrom(DefinitionType)) { throw new InvalidCastException($"{DefinitionType.FullName} must inherit {typeof(SwMacroFeatureDefinition).FullName}"); } var options = CustomFeatureOptions_e.Default; var provider = ""; DefinitionType.TryGetAttribute <CustomFeatureOptionsAttribute>(a => { options = a.Flags; provider = a.Provider; }); var baseName = MacroFeatureInfo.GetBaseName(DefinitionType); var progId = MacroFeatureInfo.GetProgId(DefinitionType); if (string.IsNullOrEmpty(progId)) { throw new NullReferenceException("Prog id for macro feature cannot be extracted"); } var icons = MacroFeatureIconInfo.GetIcons(DefinitionType, CompatibilityUtils.SupportsHighResIcons(SwMacroFeatureDefinition.Application.Application, CompatibilityUtils.HighResIconsScope_e.MacroFeature)); using (var selSet = new SelectionGroup(m_FeatMgr.Document.ISelectionManager)) { if (selection != null && selection.Any()) { var selRes = selSet.AddRange(selection); Debug.Assert(selRes); } var feat = m_FeatMgr.InsertMacroFeature3(baseName, progId, null, paramNames, paramTypes, paramValues, dimTypes, dimValues, editBodies, icons, (int)options) as IFeature; return(feat); } }