private void SetupUI()
        {
            int errors = 0;
            // gather up the icons
            string folder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(this.GetType()).Location);
            // create command group
            ICommandGroup commandGroup = _cmdMgr.CreateCommandGroup2(_mainCmdGrpId, "Custom Addin", "My custom add-in", "", -1, true, ref errors);

            // set the icon lists
            commandGroup.IconList     = new string[] { System.IO.Path.Combine(folder, "Icons", "icons.bmp") };
            commandGroup.MainIconList = new string[] { System.IO.Path.Combine(folder, "Icons", "icons.bmp") };

            // add the commands to the command group
            // this is just an example for demo purposes***
            List <int> commandItems = new List <int>();

            for (int i = 0; i < 10; i++)
            {
                // you wouldn't add your commands like this.
                // you would obviously create them one at a time
                // for example, in this demo, we're adding 10 commands, but they all call the same method ExucuteAction... that would be a dumb addin
                commandItems.Add(commandGroup.AddCommandItem2("Action " + i, -1, "Action " + i, "Action " + i, i, "ExecuteAction", "CanExecuteAction", _menuItemId1 + i, (int)swCommandItemType_e.swMenuItem | (int)swCommandItemType_e.swToolbarItem));
            }

            // activate command group
            commandGroup.HasToolbar = true;
            commandGroup.HasMenu    = true;
            commandGroup.Activate();

            // create the command tab
            foreach (int docType in new int[] { (int)swDocumentTypes_e.swDocASSEMBLY, (int)swDocumentTypes_e.swDocPART, (int)swDocumentTypes_e.swDocDRAWING })
            {
                ICommandTab commandTab = _cmdMgr.GetCommandTab(docType, "Custom Addin");

                if (commandTab != null)
                {
                    // recreate the command tab
                    _cmdMgr.RemoveCommandTab((CommandTab)commandTab);
                    commandTab = null;
                }

                // add the command tab
                commandTab = _cmdMgr.AddCommandTab(docType, "Custom Addin");
                // create a command box
                ICommandTabBox commandTabBox = commandTab.AddCommandTabBox();
                // add commands to command tab
                List <int> cmds      = new List <int>();
                List <int> textTypes = new List <int>();
                foreach (var cmdItem in commandItems)
                {
                    cmds.Add(commandGroup.CommandID[cmdItem]);
                    textTypes.Add((int)swCommandTabButtonTextDisplay_e.swCommandTabButton_TextBelow);
                }
                bool result = commandTabBox.AddCommands(cmds.ToArray(), textTypes.ToArray());

                commandTab.AddSeparator((CommandTabBox)commandTabBox, cmds.First());
            }
        }
Example #2
0
        private void ClearCommandTabBox(ICommandTabBox cmdBox)
        {
            object existingCmds;
            object existingTextStyles;

            cmdBox.GetCommands(out existingCmds, out existingTextStyles);

            if (existingCmds != null)
            {
                cmdBox.RemoveCommands(existingCmds as int[]);
            }
        }
        private void ClearCommandTabBox(ICommandTabBox cmdBox)
        {
            m_Logger.Log($"Clearing Command Tab Box", XCad.Base.Enums.LoggerMessageSeverity_e.Debug);

            object existingCmds;
            object existingTextStyles;

            cmdBox.GetCommands(out existingCmds, out existingTextStyles);

            if (existingCmds != null)
            {
                cmdBox.RemoveCommands(existingCmds as int[]);
            }
        }
Example #4
0
        private bool IsCommandTabBoxChanged(ICommandTabBox cmdBox, int[] cmdIds, int[] txtTypes)
        {
            object existingCmds;
            object existingTextStyles;

            cmdBox.GetCommands(out existingCmds, out existingTextStyles);

            if (existingCmds != null && existingTextStyles != null)
            {
                return(!(existingCmds as int[]).SequenceEqual(cmdIds) ||
                       !(existingTextStyles as int[]).SequenceEqual(txtTypes));
            }

            return(true);
        }
Example #5
0
        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);
        }
Example #6
0
 public ICommandTabBoxObject(ICommandTabBox ICommandTabBoxinstance)
 {
     ICommandTabBoxInstance = ICommandTabBoxinstance;
 }