Пример #1
0
        private void UserInterfaceEvents_OnResetRibbonInterface(NameValueMap context)
        {
            //TODO: Fix this
            try
            {
                //get the ribbon associated with part document
                Inventor.Ribbons ribbons        = userInterfaceManager.Ribbons;
                Inventor.Ribbon  assemblyRibbon = ribbons["Assembly"];

                //get the tabls associated with part ribbon
                RibbonTabs ribbonTabs        = assemblyRibbon.RibbonTabs;
                RibbonTab  assemblyRibbonTab = ribbonTabs["id_Assembly"];

                //create a new panel with the tab
                RibbonPanels ribbonPanels = assemblyRibbonTab.RibbonPanels;
                assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName,
                                                       ribbonPanelInternalName,
                                                       "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}",
                                                       "",
                                                       false);

                CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls;
                CommandControl  copyUtilCmdBtnCmdCtrl    = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #2
0
        private void CreateRibbon()
        {
            try
            {
                Inventor.UserInterfaceManager userInterFaceMgr = mInventorApp.UserInterfaceManager;
                userInterFaceMgr.UserInterfaceEvents.OnEnvironmentChange += new UserInterfaceEventsSink_OnEnvironmentChangeEventHandler(OnEnvironmentChange);

                //retrieve the GUID for this class
                GuidAttribute addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(RubiksCube.RubiksAddInServer), typeof(GuidAttribute));
                string        clientId   = "{" + addInCLSID.Value + "}";

                Icon         appLarge     = Resources.Rubiks_Cube_32;
                object       applargeIcon = AxHostConverter.ImageToPictureDisp(appLarge.ToBitmap());
                Icon         appStand     = Resources.Rubiks_Cube_16;
                object       appStandIcon = AxHostConverter.ImageToPictureDisp(appStand.ToBitmap());
                Environments envs         = userInterFaceMgr.Environments;
                mEnvironment = envs.Add(Resources.IDC_ENV_DISPLAY_NAME, Resources.IDC_ENV_INTERNAL_NAME, null, appStandIcon, applargeIcon);
                mEnvironment.AdditionalVisibleRibbonTabs = new string[] { Resources.IDC_ENV_INTERNAL_NAME };

                mObjCollection = mInventorApp.TransientObjects.CreateObjectCollection();

                //get the ribbon associated with part document
                Inventor.Ribbons ribbons = userInterFaceMgr.Ribbons;
                mPartRibbon = ribbons[Resources.IDC_ENV_PART];

                //get the tabs associated with part ribbon
                Inventor.RibbonTabs rubikRibbonTabs = mPartRibbon.RibbonTabs;
                mRubiksPartTab = rubikRibbonTabs.Add(Resources.IDC_TAB_DISPLAY_NAME, Resources.IDC_TAB_INTERNAL_NAME, "F0911DF2-478B-49EC-808D-D7C1F5271B6D", Resources.IDC_TARGET_TAB_NAME, true, true);

                //Adding solve Panel.
                RibbonPanel             solvePanel   = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_SOLVE_DISPLAY_NAME, Resources.IDC_SOLVE_INTERNAL_NAME, "60A50C33-F7EE-4B74-BCB0-C5CE03C1B3E6");
                Inventor.CommandControl solveControl = solvePanel.CommandControls.AddButton(mSolve, true, true);

                //Adding randomize Panel.
                RibbonPanel             scramblePanel   = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_SCRAMBLE_DISPLAY_NAME, Resources.IDC_SCRAMBLE_INTERNAL_NAME, "D20674CE-A855-4403-850B-FDE59C4A167B");
                Inventor.CommandControl scrambleControl = scramblePanel.CommandControls.AddButton(mScramble, true, true);

                //Adding randomize Panel.
                RibbonPanel playPanel = mRubiksPartTab.RibbonPanels.Add(Resources.IDC_PLAY_DISPLAY_NAME, Resources.IDC_PLAY_INTERNAL_NAME, "343D703C-1194-4715-BF54-3BE4E3B9FF64");
                //Inventor.CommandControl playControl = playPanel.CommandControls.AddButton(mPlay, true, true, "", false);

                mObjCollection.Add(mPlay);
                mObjCollection.Add(mNext);
                CommandControl partCmdCtrl = playPanel.CommandControls.AddSplitButtonMRU(mObjCollection, true);

                mEnvironment.DefaultRibbonTab = Resources.IDC_TAB_INTERNAL_NAME;
                userInterFaceMgr.ParallelEnvironments.Add(mEnvironment);
                mEnvCtrlDef = mInventorApp.CommandManager.ControlDefinitions[Resources.IDC_ENV_INTERNAL_NAME];
                mEnvCtrlDef.ProgressiveToolTip.ExpandedDescription = Resources.IDC_APPLICATION_BTN_TOOLTIP_EXPANDED;
                mEnvCtrlDef.ProgressiveToolTip.Description         = Resources.IDC_APPLICATION_BTN_TOOLTIP_DESCRIPTION;
                mEnvCtrlDef.ProgressiveToolTip.Title = Resources.IDC_APPLICATION_BTN_TITLE;

                AddToDisabledList();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.Message);
            }
        }
Пример #3
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                SetupDynamoPaths();
                inventorApplication = addInSiteObject.Application;
                PersistenceManager.InventorApplication = inventorApplication;
                userInterfaceManager = inventorApplication.UserInterfaceManager;

                //initialize event delegates
                userInterfaceEvents = inventorApplication.UserInterfaceManager.UserInterfaceEvents;

                UserInterfaceEventsSink_OnResetCommandBarsEventDelegate = new UserInterfaceEventsSink_OnResetCommandBarsEventHandler(UserInterfaceEvents_OnResetCommandBars);
                userInterfaceEvents.OnResetCommandBars += UserInterfaceEventsSink_OnResetCommandBarsEventDelegate;

                UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate = new UserInterfaceEventsSink_OnResetEnvironmentsEventHandler(UserInterfaceEvents_OnResetEnvironments);
                userInterfaceEvents.OnResetEnvironments += UserInterfaceEventsSink_OnResetEnvironmentsEventDelegate;

                UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate = new UserInterfaceEventsSink_OnResetRibbonInterfaceEventHandler(UserInterfaceEvents_OnResetRibbonInterface);
                userInterfaceEvents.OnResetRibbonInterface += UserInterfaceEventsSink_OnResetRibbonInterfaceEventDelegate;

                appEvents = inventorApplication.ApplicationEvents;
                appEvents.OnActivateDocument   += appEvents_OnActivateDocument;
                appEvents.OnDeactivateDocument += appEvents_OnDeactivateDocument;

                Icon dynamoIcon = Resources.logo_square_32x32;

                //retrieve the GUID for this class
                GuidAttribute addInCLSID;
                addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(this.GetType(), typeof(GuidAttribute));
                string addInCLSIDString;
                addInCLSIDString = "{" + addInCLSID.Value + "}";

                dynamoAddinButton = new DynamoInventorAddinButton(
                    buttonDisplayName, buttonInternalName, CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Initialize Dynamo.",
                    "Dynamo is a visual programming environment for Inventor.", dynamoIcon, dynamoIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

                CommandCategory assemblyUtilitiesCategory = inventorApplication.CommandManager.CommandCategories.Add(commandCategoryDisplayName, commandCategoryInternalName, addInCLSID);
                assemblyUtilitiesCategory.Add(dynamoAddinButton.ButtonDefinition);

                if (firstTime == true)
                {
                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        CommandBar assemblyUtilityCommandBar;

                        assemblyUtilityCommandBar = userInterfaceManager.CommandBars.Add(commandBarDisplayName,
                                                                                         commandBarInternalName,
                                                                                         CommandBarTypeEnum.kRegularCommandBar,
                                                                                         addInCLSID);
                    }

                    else
                    {
                        Inventor.Ribbons ribbons           = userInterfaceManager.Ribbons;
                        Inventor.Ribbon  assemblyRibbon    = ribbons["Assembly"];
                        RibbonTabs       ribbonTabs        = assemblyRibbon.RibbonTabs;
                        RibbonTab        assemblyRibbonTab = ribbonTabs["id_AddInsTab"];
                        RibbonPanels     ribbonPanels      = assemblyRibbonTab.RibbonPanels;
                        assemblyRibbonPanel = ribbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls assemblyRibbonPanelCtrls = assemblyRibbonPanel.CommandControls;
                        CommandControl  assemblyCmdBtnCmdCtrl    = assemblyRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);

                        Inventor.Ribbon partRibbon       = ribbons["Part"];
                        RibbonTabs      partRibbonTabs   = partRibbon.RibbonTabs;
                        RibbonTab       modelRibbonTab   = partRibbonTabs["id_AddInsTab"];
                        RibbonPanels    partRibbonPanels = modelRibbonTab.RibbonPanels;
                        partRibbonPanel = partRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls partRibbonPanelCtrls = partRibbonPanel.CommandControls;
                        CommandControl  partCmdBtnCmdCtrl    = partRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);

                        Inventor.Ribbon drawingRibbon       = ribbons["Drawing"];
                        RibbonTabs      drawingRibbonTabs   = drawingRibbon.RibbonTabs;
                        RibbonTab       drawingRibbonTab    = drawingRibbonTabs["id_AddInsTab"];
                        RibbonPanels    drawingRibbonPanels = drawingRibbonTab.RibbonPanels;
                        drawingRibbonPanel = drawingRibbonPanels.Add(ribbonPanelDisplayName, ribbonPanelInternalName, "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);
                        CommandControls drawingRibbonPanelCtrls = drawingRibbonPanel.CommandControls;
                        CommandControl  drawingCmdBtnCmdCtrl    = drawingRibbonPanelCtrls.AddButton(dynamoAddinButton.ButtonDefinition, true, true, "", false);
                    }
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Пример #4
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            // This method is called by Inventor when it loads the addin.
            // The AddInSiteObject provides access to the Inventor Application object.
            // The FirstTime flag indicates if the addin is loaded for the first time.
            AddinGlobal.InventorApp = addInSiteObject.Application;

            // Initialize AddIn members.
            m_inventorApplication = addInSiteObject.Application;
            try
            {
                AddinGlobal.GetAddinClassId(this.GetType());
                Icon icon1 = Properties.Resources.button_turn_on;
                Icon icon2 = Properties.Resources.log_door;
                Icon icon3 = Properties.Resources.chat_31;
                Icon icon4 = Properties.Resources.off_on_power_energy_1_;
                Icon icon5 = null;

                //Icon icon1 = new Icon(this.GetType(), "InventorAddIn1.Properties.AddSlotOption.ico"); //Change it if necessary but make sure it's embedded.
                //Button1
                InventorButton button1 = new InventorButton(
                    "Session erstellen", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Erstellen Sie eine neue Session",
                    icon1, icon1,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button1.SetBehavior(true, true, true);
                button1.Execute = ButtonAction.Button1_Execute;
                //Button2
                InventorButton button2 = new InventorButton(
                    "Beitreten", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Eine Session beitreten",
                    icon2, icon2,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button2.SetBehavior(true, true, true);
                button2.Execute = ButtonAction.Button2_Execute;
                //Button3
                InventorButton button3 = new InventorButton(
                    "Messages", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "See your Messages",
                    icon3, icon3,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button3.SetBehavior(true, true, true);
                button3.Execute = ButtonAction.Button3_Execute;
                //Button4
                InventorButton button4 = new InventorButton(
                    "Beenden", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Beenden Sie die Session",
                    icon4, icon4,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button4.SetBehavior(true, true, true);
                button4.Execute = ButtonAction.Button4_Execute;
                //Button5
                InventorButton button5 = new InventorButton(
                    "Username: \n Meeting-ID: ", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Info",
                    icon5, icon5,
                    CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
                button5.SetBehavior(true, true, true);
                button5.Execute          = ButtonAction.Button5_Execute;
                ButtonAction.InventorApp = m_inventorApplication;

                if (firstTime == true)
                {
                    UserInterfaceManager uiMan = AddinGlobal.InventorApp.UserInterfaceManager;
                    if (uiMan.InterfaceStyle == InterfaceStyleEnum.kRibbonInterface) //kClassicInterface support can be added if necessary.
                    {
                        /*Inventor.Ribbon ribbon = uiMan.Ribbons["Assem"];//["Part"];
                         * RibbonTab tab = ribbon.RibbonTabs["id_TabTools"]; //Change it if necessary.*/

                        //Assembly
                        Inventor.Ribbons ribbon         = uiMan.Ribbons;
                        Inventor.Ribbon  assemblyRibbon = ribbon["Assembly"];
                        RibbonTabs       ribbonTabs     = assemblyRibbon.RibbonTabs;
                        RibbonTab        tab            = ribbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId       = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.assemblyRibbonPanel = tab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.assemblyRibbonPanel);
                        CommandControls cmdCtrls = AddinGlobal.assemblyRibbonPanel.CommandControls;
                        cmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        cmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        cmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        cmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        //Part
                        Inventor.Ribbon partRibbon     = ribbon["Part"];
                        RibbonTabs      partRibbonTabs = partRibbon.RibbonTabs;
                        RibbonTab       modelRibbonTab = partRibbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId   = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.partRibbonPanel = modelRibbonTab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.partRibbonPanel);

                        CommandControls pcmdCtrls = AddinGlobal.partRibbonPanel.CommandControls;
                        pcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        pcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        //Drawing
                        Inventor.Ribbon drawingRibbon     = ribbon["Drawing"];
                        RibbonTabs      drawingRibbonTabs = drawingRibbon.RibbonTabs;
                        RibbonTab       drawingRibbonTab  = drawingRibbonTabs["id_AddInsTab"];
                        //CommandBarList ContextMenuList/ CommandBar DefaultMenuBar
                        AddinGlobal.RibbonPanelId      = "{d04e0c45-dec6-4881-bd3f-a7a81b99f307}";
                        AddinGlobal.drawingRibbonPanel = drawingRibbonTab.RibbonPanels.Add(
                            "AddOutButtons",
                            "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(),
                            AddinGlobal.RibbonPanelId, String.Empty, true);
                        AddinGlobal.RibbonPanels.Add(AddinGlobal.drawingRibbonPanel);


                        CommandControls dcmdCtrls = AddinGlobal.drawingRibbonPanel.CommandControls;
                        dcmdCtrls.AddButton(button1.ButtonDef, button1.DisplayBigIcon, button1.DisplayText, "", button1.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button2.ButtonDef, button2.DisplayBigIcon, button2.DisplayText, "", button2.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button3.ButtonDef, button3.DisplayBigIcon, button3.DisplayText, "", button3.InsertBeforeTarget);
                        dcmdCtrls.AddButton(button4.ButtonDef, button4.DisplayBigIcon, button4.DisplayText, "", button4.InsertBeforeTarget);

                        /* Get the 2d sketch environment base object
                         * Inventor.Environment partSketchEnvironment;
                         * partSketchEnvironment = userInterfaceManager.Environments["PMxPartSketchEnvironment"];
                         *
                         * //make this command bar accessible in the panel menu for the 2d sketch environment.
                         * partSketchEnvironment.PanelBar.CommandBarList.Add(slotCommandBar);*/
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            // TODO: Add ApplicationAddInServer.Activate implementation.
            // e.g. event initialization, command creation etc.
        }