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; } } }
private object GetBodyResult(ISldWorks app, IEnumerable <IBody2> bodies, IMacroFeatureData featData, bool updateEntityIds) { if (bodies != null) { if (CompatibilityUtils.IsVersionNewerOrEqual(app, SwVersion_e.Sw2013, 5)) { featData.EnableMultiBodyConsume = true; } if (updateEntityIds) { if (featData == null) { throw new ArgumentNullException(nameof(featData)); } foreach (var body in bodies) { object faces; object edges; featData.GetEntitiesNeedUserId(body, out faces, out edges); if (faces is object[]) { int nextId = 0; foreach (Face2 face in faces as object[]) { featData.SetFaceUserId(face, nextId++, 0); } } if (edges is object[]) { int nextId = 0; foreach (Edge edge in edges as object[]) { featData.SetEdgeUserId(edge, nextId++, 0); } } } } if (bodies.Count() == 1) { return(bodies.First()); } else { return(bodies.ToArray()); } } else { throw new ArgumentNullException(nameof(bodies)); } }
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); } }
private object GetBodyResult(ISldWorks app, IModelDoc2 model, IEnumerable <IBody2> bodies, IMacroFeatureData featData, bool updateEntityIds) { if (bodies != null) { if (CompatibilityUtils.IsVersionNewerOrEqual(app, SwVersion_e.Sw2013, 5)) { featData.EnableMultiBodyConsume = true; } if (updateEntityIds) { if (featData == null) { throw new ArgumentNullException(nameof(featData)); } foreach (var body in bodies) { object faces; object edges; featData.GetEntitiesNeedUserId(body, out faces, out edges); if (faces is object[]) { var faceIds = (faces as object[]).ToDictionary(x => (Face2)x, x => new MacroFeatureEntityId()); AssignFaceIds(app, model, faceIds); foreach (var faceId in faceIds) { featData.SetFaceUserId(faceId.Key, faceId.Value.FirstId, faceId.Value.SecondId); } } if (edges is object[]) { var edgeIds = (edges as object[]).ToDictionary(x => (Edge)x, x => new MacroFeatureEntityId()); AssignEdgeIds(app, model, edgeIds); foreach (var edgeId in edgeIds) { featData.SetEdgeUserId(edgeId.Key, edgeId.Value.FirstId, edgeId.Value.SecondId); } } } } if (bodies.Count() == 1) { return(bodies.First()); } else { return(bodies.ToArray()); } } else { throw new ArgumentNullException(nameof(bodies)); } }
public void RepoConsistencyTest(string repoName) { var test = new CompatibilityUtils(output); test.RepoConsistencyTest("Intellias.CQRS.", repoName); }