private Dictionary <WorkspaceTypes_e, TabCommandGroupInfo[]> GroupTabCommandsByWorkspace(List <SwCommandGroup> groups) { var tabCommands = new Dictionary <WorkspaceTypes_e, List <TabCommandGroupInfo> >(); var cmdIds = m_Commands.Values.ToDictionary(x => x.Spec, x => x.CommandId); foreach (var group in groups) { if (group.Spec.Commands != null) { foreach (var cmd in group.Spec.Commands) { if (cmd.HasRibbon) { var cmdId = cmdIds[cmd]; var textType = ConvertTextDisplay(cmd.RibbonTextStyle); foreach (var worspaceType in new WorkspaceTypes_e[] { WorkspaceTypes_e.Part, WorkspaceTypes_e.Assembly, WorkspaceTypes_e.Drawing }) { if (cmd.SupportedWorkspace.HasFlag(worspaceType)) { if (!tabCommands.TryGetValue(worspaceType, out List <TabCommandGroupInfo> tabCmdGrps)) { tabCmdGrps = new List <TabCommandGroupInfo>(); tabCommands.Add(worspaceType, tabCmdGrps); } var tabCmdGrp = tabCmdGrps.FirstOrDefault(g => g.Group == group); if (tabCmdGrp == null) { tabCmdGrp = new TabCommandGroupInfo(group); tabCmdGrps.Add(tabCmdGrp); } tabCmdGrp.Commands.Add(new TabCommandInfo(cmdId, cmd.RibbonTextStyle)); } } } } } } return(tabCommands.ToDictionary(x => x.Key, x => x.Value.ToArray())); }
private bool IsCommandTabBoxMatchingGroup(ICommandTabBox cmdTabBox, TabCommandGroupInfo groupInfo) { object existingCmds; object existingTextStyles; cmdTabBox.GetCommands(out existingCmds, out existingTextStyles); if (existingCmds != null && existingTextStyles != null) { var cmdIds = groupInfo.Commands.Select(c => c.CommandId).ToArray(); if (((int[])existingCmds).SequenceEqual(cmdIds)) { var txtTypes = groupInfo.Commands.Select(c => (int)ConvertTextDisplay(c.TextStyle)).ToArray(); if (((int[])existingTextStyles).SequenceEqual(txtTypes)) { return(true); } } } return(false); }