private static void updateinfo(string info)
 {
     //updating the text of the info button in all working modes
     lock (infobutton)
     {
         while (infobutton.Count > 0)
         {
             infobutton[0].Delete();
             infobutton.RemoveAt(0);
         }
         InventorButton button = new InventorButton(
             info, "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Info",
             null, null,
             CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode);
         button.SetBehavior(true, true, true);
         infobutton.Add(AddinGlobal.assemblyRibbonPanel.CommandControls.AddButton(button.ButtonDef, button.DisplayBigIcon, button.DisplayText, "", button.InsertBeforeTarget));
         infobutton.Add(AddinGlobal.partRibbonPanel.CommandControls.AddButton(button.ButtonDef, button.DisplayBigIcon, button.DisplayText, "", button.InsertBeforeTarget));
         infobutton.Add(AddinGlobal.drawingRibbonPanel.CommandControls.AddButton(button.ButtonDef, button.DisplayBigIcon, button.DisplayText, "", button.InsertBeforeTarget));
     }
 }
 public void CopyBehaviorFrom(InventorButton button)
 {
     this.DisplayBigIcon     = button.DisplayBigIcon;
     this.DisplayText        = button.DisplayText;
     this.InsertBeforeTarget = this.InsertBeforeTarget;
 }
예제 #3
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.
        }