Beispiel #1
0
        public AboutBox()
        {
            InitializeComponent();

            foreach (Assembly s in AppDomain.CurrentDomain.GetAssemblies())
            {
                string[] lvsi = new string[3];
                lvsi[0] = s.GetName().Name;
                lvsi[1] = s.GetName().FullName;
                lvsi[2] = s.GetName().Version.ToString();
                ListViewItem lvi = new ListViewItem(lvsi, 0);
                this.ListOfAssemblies.Items.Add(lvi);
            }

            AssemblyCopyrightAttribute   objCopyright   = AssemblyCopyrightAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)) as AssemblyCopyrightAttribute;
            AssemblyDescriptionAttribute objDescription = AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute)) as AssemblyDescriptionAttribute;
            AssemblyCompanyAttribute     objCompany     = AssemblyCompanyAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute)) as AssemblyCompanyAttribute;
            AssemblyTrademarkAttribute   objTrademark   = AssemblyTrademarkAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTrademarkAttribute)) as AssemblyTrademarkAttribute;
            AssemblyProductAttribute     objProduct     = AssemblyProductAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute)) as AssemblyProductAttribute;
            AssemblyTitleAttribute       objTitle       = AssemblyTitleAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute)) as AssemblyTitleAttribute;
            GuidAttribute         objGuid         = GuidAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(GuidAttribute)) as GuidAttribute;
            DebuggableAttribute   objDebuggable   = DebuggableAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(DebuggableAttribute)) as DebuggableAttribute;
            CLSCompliantAttribute objCLSCompliant = CLSCompliantAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(), typeof(CLSCompliantAttribute)) as CLSCompliantAttribute;

            AppName.Text        = objProduct.Product;
            BigTitle.Text       = objTitle.Title;
            ProdVer.Text        = QuestDesignerMain.Version;
            AppDesc.Text        = objDescription.Description;
            CopyrightLabel.Text = objCopyright.Copyright;
            SerialNo.Text       = objGuid.Value;
            Company.Text        = objCompany.Company;
        }
        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);
            }
        }
Beispiel #3
0
        public string GetGUIDForThisClass()
        {
            //retrieve the GUID for this class
            GuidAttribute addInCLSID;

            addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(StandardAddInServer), typeof(GuidAttribute));
            return("{" + addInCLSID.Value + "}");
        }
Beispiel #4
0
        private string getGUID()
        {
            GuidAttribute addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(
                typeof(StandardAddInServer),
                typeof(GuidAttribute));

            return("{" + addInCLSID.Value + "}");
        }
Beispiel #5
0
        public void InitUI(AddInServer addIn, bool firstTime, Inventor.Application inventorApplication)
        {
            m_inventorApplication      = inventorApplication;
            Button.InventorApplication = m_inventorApplication;

            //load image icons for UI items
            Icon turnBlueIcon = new Icon(this.GetType(), "TurnBlue.ico");

            //retrieve the GUID for this class
            GuidAttribute addInCLSID;

            addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(AddInServer), typeof(GuidAttribute));
            string addInCLSIDString;

            addInCLSIDString = "{" + addInCLSID.Value + "}";

            m_TurnBlueButton = new TurnBlueButton(addIn,
                                                  "TurnBlue", "Autodesk:TurnBlueAddIn:TurnBlueCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                                                  addInCLSIDString, "Turns the part blue",
                                                  "TurnBlue", turnBlueIcon, turnBlueIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

            if (firstTime == true)
            {
                //access user interface manager
                UserInterfaceManager userInterfaceManager;
                userInterfaceManager = m_inventorApplication.UserInterfaceManager;

                InterfaceStyleEnum interfaceStyle;
                interfaceStyle = userInterfaceManager.InterfaceStyle;


                //get the ribbon associated with part document
                Inventor.Ribbons ribbons;
                ribbons = userInterfaceManager.Ribbons;

                Inventor.Ribbon partRibbon;
                partRibbon = ribbons["Part"];

                //get the tabs associated with part ribbon
                RibbonTabs ribbonTabs;
                ribbonTabs = partRibbon.RibbonTabs;

                RibbonTab partViewRibbonTab;
                partViewRibbonTab = ribbonTabs["id_TabView"];

                //create a new panel with the tab
                RibbonPanels ribbonPanels;
                ribbonPanels = partViewRibbonTab.RibbonPanels;

                RibbonPanel appearancePanel = ribbonPanels["id_PanelA_ViewAppearance"];

                CommandControls panelCtrls = appearancePanel.CommandControls;
                CommandControl  TurnBlueCmdBtnCmdCtrl;
                TurnBlueCmdBtnCmdCtrl = panelCtrls.AddButton(m_TurnBlueButton.ButtonDefinition, false, true, "", false);
            }
        }
Beispiel #6
0
        public void ConfigureButtons()
        {
            GuidAttribute addInCLSID;

            addInCLSID = (GuidAttribute)GuidAttribute.GetCustomAttribute(typeof(AddInServer), typeof(GuidAttribute));
            string addInCLSIDString;

            addInCLSIDString = "{" + addInCLSID.Value + "}";

            Icon materialInfoIcon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("AMEEMaterials.AMEE.AMEE.ico"));

            m_materialInfoButton = new MaterialInfoButton(
                "Material Info", "AMEEMaterials:MaterialInfoCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                addInCLSIDString, "View material information",
                "Material Info", materialInfoIcon, materialInfoIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);
        }
Beispiel #7
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                //the Activate 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

                //initialize AddIn members
                m_inventorApplication = addInSiteObject.Application;
                InvAddIn.Button.InventorApplication = m_inventorApplication;

                //initialize event delegates
                m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

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

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

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

                //load image icons for UI items
                IPictureDisp createMasterMIcon = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());
                IPictureDisp createMasterMICON = AxHostConverter.ImageToPictureDisp(Resources.CreateMasterM.ToBitmap());

                IPictureDisp helpIcon = AxHostConverter.ImageToPictureDisp(Resources.icon1.ToBitmap());
                IPictureDisp helpICON = AxHostConverter.ImageToPictureDisp(Resources.icon1.ToBitmap());

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

                //create buttons
                ButtON = new BenjaminButton(
                    "MasterModel", "MasterModel:StandardAddInServer:BenjaminBUTTON", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Create a Master Model File",
                    "keep the model simple", createMasterMIcon, createMasterMICON, ButtonDisplayEnum.kDisplayTextInLearningMode, false);
                //ButtON.HeySherlock = (PartDocument) m_inventorApplication.ActiveDocument;
                Help = new BenjaminButton(
                    "How to", "Help:StandardAddInServer:BenjaminBUTTON", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Help Creating a Master Model File",
                    "keep the model simple", helpIcon, helpICON, ButtonDisplayEnum.kDisplayTextInLearningMode, true);
                //create the command category
                CommandCategory MasterMCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTON", addInCLSIDString);

                MasterMCmdCategory.Add(ButtON.ButtonDefinition);
                MasterMCmdCategory.Add(Help.ButtonDefinition);

                if (firstTime == true)
                {
                    //access user interface manager
                    UserInterfaceManager userInterfaceManager;
                    userInterfaceManager = m_inventorApplication.UserInterfaceManager;

                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    //create the UI for classic interface
                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        //create toolbar
                        CommandBar MasterCommander;
                        MasterCommander = userInterfaceManager.CommandBars.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTONToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString);

                        //add buttons to toolbar
                        MasterCommander.Controls.AddButton(ButtON.ButtonDefinition, 0);
                        MasterCommander.Controls.AddButton(Help.ButtonDefinition, 0);

                        //Get the 2d sketch environment base object
                        Inventor.Environment partToolEnvironment;
                        partToolEnvironment = userInterfaceManager.Environments["PMxPartSkEnvironment"];

                        //make this command bar accessible in the panel menu for the Tool environment.
                        partToolEnvironment.PanelBar.CommandBarList.Add(MasterCommander);
                    }
                    //create the UI for ribbon interface
                    else
                    {
                        //get the ribbon associated with part document
                        Inventor.Ribbons ribbons;
                        ribbons = userInterfaceManager.Ribbons;

                        Inventor.Ribbon partRibbon;
                        partRibbon = ribbons["Part"];

                        //get the tabs associated with part ribbon
                        RibbonTabs ribbonTabs;
                        ribbonTabs = partRibbon.RibbonTabs;

                        //get the Tool tab
                        RibbonTab partToolRibbonTab;
                        partToolRibbonTab = ribbonTabs["id_TabTools"];

                        //create a new panel with the tab
                        RibbonPanels ribbonPanels;
                        ribbonPanels = partToolRibbonTab.RibbonPanels;

                        partToolMasterRibbonPanel = ribbonPanels.Add("Master Model", "MasterModel:StandardAddInServer:BenjaminBUTTONRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);

                        //add controls to the MasterModel panel
                        CommandControls partToolMasterRibbonPanelCtrls;
                        partToolMasterRibbonPanelCtrls = partToolMasterRibbonPanel.CommandControls;

                        //add the buttons to the ribbon panel
                        CommandControl MasterMoRiPaCtrl;
                        MasterMoRiPaCtrl = partToolMasterRibbonPanelCtrls.AddButton(ButtON.ButtonDefinition, false, true, "", false);
                        MasterMoRiPaCtrl = partToolMasterRibbonPanelCtrls.AddButton(Help.ButtonDefinition, false, true, "", false);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Beispiel #8
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());
            }
        }
Beispiel #9
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                //the Activate 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

                //initialize AddIn members
                m_inventorApplication      = addInSiteObject.Application;
                Button.InventorApplication = m_inventorApplication;

                //initialize event delegates
                m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

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

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

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

                //load image icons for UI items
                Icon addSlotOptionIcon   = new Icon(this.GetType(), "AddSlotOption.ico");
                Icon drawSlotIcon        = new Icon(this.GetType(), "DrawSlot.ico");
                Icon toggleSlotStateIcon = new Icon(this.GetType(), "ToggleSlotState.ico");

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

                //create the comboboxes
                m_slotWidthComboBoxDefinition  = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Slot Width", "Autodesk:SimpleAddIn:SlotWidthCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Slot width", "Slot width", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode);
                m_slotHeightComboBoxDefinition = m_inventorApplication.CommandManager.ControlDefinitions.AddComboBoxDefinition("Slot Height", "Autodesk:SimpleAddIn:SlotHeightCboBox", CommandTypesEnum.kShapeEditCmdType, 100, addInCLSIDString, "Slot height", "Slot height", Type.Missing, Type.Missing, ButtonDisplayEnum.kDisplayTextInLearningMode);

                //add some initial items to the comboboxes
                m_slotWidthComboBoxDefinition.AddItem("1 cm", 0);
                m_slotWidthComboBoxDefinition.AddItem("2 cm", 0);
                m_slotWidthComboBoxDefinition.AddItem("3 cm", 0);
                m_slotWidthComboBoxDefinition.AddItem("4 cm", 0);
                m_slotWidthComboBoxDefinition.AddItem("5 cm", 0);
                m_slotWidthComboBoxDefinition.ListIndex       = 1;
                m_slotWidthComboBoxDefinition.ToolTipText     = m_slotWidthComboBoxDefinition.Text;
                m_slotWidthComboBoxDefinition.DescriptionText = "Slot width: " + m_slotWidthComboBoxDefinition.Text;

                SlotWidthComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotWidthComboBox_OnSelect);
                m_slotWidthComboBoxDefinition.OnSelect += SlotWidthComboBox_OnSelectEventDelegate;

                m_slotHeightComboBoxDefinition.AddItem("1 cm", 0);
                m_slotHeightComboBoxDefinition.AddItem("2 cm", 0);
                m_slotHeightComboBoxDefinition.AddItem("3 cm", 0);
                m_slotHeightComboBoxDefinition.AddItem("4 cm", 0);
                m_slotHeightComboBoxDefinition.AddItem("5 cm", 0);
                m_slotHeightComboBoxDefinition.ListIndex       = 1;
                m_slotHeightComboBoxDefinition.ToolTipText     = m_slotHeightComboBoxDefinition.Text;
                m_slotHeightComboBoxDefinition.DescriptionText = "Slot height: " + m_slotHeightComboBoxDefinition.Text;

                SlotHeightComboBox_OnSelectEventDelegate = new ComboBoxDefinitionSink_OnSelectEventHandler(SlotHeightComboBox_OnSelect);
                m_slotHeightComboBoxDefinition.OnSelect += SlotHeightComboBox_OnSelectEventDelegate;

                //create buttons
                m_addSlotOptionButton = new AddSlotOptionButton(
                    "Add Slot width/height", "Autodesk:SimpleAddIn:AddSlotOptionCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Adds option for slot width/height",
                    "Add slot option", addSlotOptionIcon, addSlotOptionIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

                m_drawSlotButton = new DrawSlotButton(
                    "Draw Slot", "Autodesk:SimpleAddIn:DrawSlotCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Create slot sketch graphics",
                    "Draw Slot", drawSlotIcon, drawSlotIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

                m_toggleSlotStateButton = new ToggleSlotStateButton(
                    "Toggle Slot State", "Autodesk:SimpleAddIn:ToggleSlotStateCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Enables/Disables state of slot command",
                    "Toggle Slot State", toggleSlotStateIcon, toggleSlotStateIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);

                //create the command category
                CommandCategory slotCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Slot", "Autodesk:SimpleAddIn:SlotCmdCat", addInCLSIDString);

                slotCmdCategory.Add(m_slotWidthComboBoxDefinition);
                slotCmdCategory.Add(m_slotHeightComboBoxDefinition);
                slotCmdCategory.Add(m_addSlotOptionButton.ButtonDefinition);
                slotCmdCategory.Add(m_drawSlotButton.ButtonDefinition);
                slotCmdCategory.Add(m_toggleSlotStateButton.ButtonDefinition);

                if (firstTime == true)
                {
                    //access user interface manager
                    UserInterfaceManager userInterfaceManager;
                    userInterfaceManager = m_inventorApplication.UserInterfaceManager;

                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    //create the UI for classic interface
                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        //create toolbar
                        CommandBar slotCommandBar;
                        slotCommandBar = userInterfaceManager.CommandBars.Add("Slot", "Autodesk:SimpleAddIn:SlotToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString);

                        //add comboboxes to toolbar
                        slotCommandBar.Controls.AddComboBox(m_slotWidthComboBoxDefinition, 0);
                        slotCommandBar.Controls.AddComboBox(m_slotHeightComboBoxDefinition, 0);

                        //add buttons to toolbar
                        slotCommandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);
                        slotCommandBar.Controls.AddButton(m_drawSlotButton.ButtonDefinition, 0);
                        slotCommandBar.Controls.AddButton(m_toggleSlotStateButton.ButtonDefinition, 0);

                        //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);
                    }
                    //create the UI for ribbon interface
                    else
                    {
                        //get the ribbon associated with part document
                        Inventor.Ribbons ribbons;
                        ribbons = userInterfaceManager.Ribbons;

                        Inventor.Ribbon partRibbon;
                        partRibbon = ribbons["Part"];

                        //get the tabls associated with part ribbon
                        RibbonTabs ribbonTabs;
                        ribbonTabs = partRibbon.RibbonTabs;

                        RibbonTab partSketchRibbonTab;
                        partSketchRibbonTab = ribbonTabs["id_TabSketch"];

                        //create a new panel with the tab
                        RibbonPanels ribbonPanels;
                        ribbonPanels = partSketchRibbonTab.RibbonPanels;

                        m_partSketchSlotRibbonPanel = ribbonPanels.Add("Slot", "Autodesk:SimpleAddIn:SlotRibbonPanel", "{DB59D9A7-EE4C-434A-BB5A-F93E8866E872}", "", false);

                        //add controls to the slot panel
                        CommandControls partSketchSlotRibbonPanelCtrls;
                        partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls;

                        //add the combo boxes to the ribbon panel
                        CommandControl slotWidthCmdCboBoxCmdCtrl;
                        slotWidthCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotWidthComboBoxDefinition, "", false);

                        CommandControl slotHeightCmdCboBoxCmdCtrl;
                        slotHeightCmdCboBoxCmdCtrl = partSketchSlotRibbonPanelCtrls.AddComboBox(m_slotHeightComboBoxDefinition, "", false);

                        //add the buttons to the ribbon panel
                        CommandControl drawSlotCmdBtnCmdCtrl;
                        drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_drawSlotButton.ButtonDefinition, false, true, "", false);


                        CommandControl slotOptionCmdBtnCmdCtrl;
                        slotOptionCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false);

                        CommandControl toggleSlotStateCmdBtnCmdCtrl;
                        toggleSlotStateCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_toggleSlotStateButton.ButtonDefinition, false, true, "", false);
                    }
                }

                MessageBox.Show("To access the commands of the sample addin, activate a 2d sketch of a part \n document and select the \"AddInSlot\" toolbar within the panel menu");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Beispiel #10
0
        public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
        {
            try
            {
                //the Activate 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

                //initialize AddIn members
                m_inventorApplication      = addInSiteObject.Application;
                Button.InventorApplication = m_inventorApplication;

                //initialize event delegates
                m_userInterfaceEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;

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

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

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

                //load image icons for UI items
                //PROBLEM: i CAN NOT ADD ANOTHER ICON EXCEPT FOR SYSTEM... HOW TO DO THIS?
                //  Icon anisotropyIcon = new Icon(this.GetType(), "\\AddSlotOption.ico");
                Icon addSlotOptionIcon = new Icon(SystemIcons.Exclamation, 32, 32);


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



                //create button
                m_addSlotOptionButton = new AddSlotOptionButton(
                    "Add pattern", "Autodesk:Mugen:AddAnisotropyOptionCmdBtn", CommandTypesEnum.kShapeEditCmdType,
                    addInCLSIDString, "Creates an anisotropic pattern on a given surface",
                    "Add Anisotropic Pattern", addSlotOptionIcon, addSlotOptionIcon, ButtonDisplayEnum.kDisplayTextInLearningMode);


                //create the command category
                CommandCategory slotCmdCategory = m_inventorApplication.CommandManager.CommandCategories.Add("Anisotropy", "Autodesk:Mugen:AnisotropyCmdCat", addInCLSIDString);

                slotCmdCategory.Add(m_addSlotOptionButton.ButtonDefinition);


                if (firstTime == true)
                {
                    //access user interface manager
                    UserInterfaceManager userInterfaceManager;
                    userInterfaceManager = m_inventorApplication.UserInterfaceManager;

                    InterfaceStyleEnum interfaceStyle;
                    interfaceStyle = userInterfaceManager.InterfaceStyle;

                    //create the UI for classic interface
                    if (interfaceStyle == InterfaceStyleEnum.kClassicInterface)
                    {
                        //create toolbar
                        CommandBar slotCommandBar;
                        slotCommandBar = userInterfaceManager.CommandBars.Add("Anisotropy", "Autodesk:Mugen:AnistropyToolbar", CommandBarTypeEnum.kRegularCommandBar, addInCLSIDString);

                        //add buttons to toolbar
                        slotCommandBar.Controls.AddButton(m_addSlotOptionButton.ButtonDefinition, 0);


                        //Get the 2d sketch environment base object
                        Inventor.Environment partSketchEnvironment;
                        partSketchEnvironment = userInterfaceManager.Environments["PMxPartEnvironment"];

                        //make this command bar accessible in the panel menu for the 2d sketch environment.
                        partSketchEnvironment.PanelBar.CommandBarList.Add(slotCommandBar);
                    }
                    //create the UI for ribbon interface
                    else
                    {
                        //get the ribbon associated with part document
                        Inventor.Ribbons ribbons;
                        ribbons = userInterfaceManager.Ribbons;

                        Inventor.Ribbon partRibbon;
                        partRibbon = ribbons["Part"];

                        //get the tabls associated with part ribbon
                        RibbonTabs ribbonTabs;
                        ribbonTabs = partRibbon.RibbonTabs;

                        RibbonTab partSketchRibbonTab;
                        partSketchRibbonTab = ribbonTabs["id_TabTools"];

                        //create a new panel with the tab
                        RibbonPanels ribbonPanels;
                        ribbonPanels = partSketchRibbonTab.RibbonPanels;

                        m_partSketchSlotRibbonPanel = ribbonPanels.Add("Anysotropy", "Autodesk:Mugen:AnysotropyRibbonPanel", "{cc527b4d-c28d-40fb-a46a-4978db960594}", "", false);

                        //add controls to the slot panel
                        CommandControls partSketchSlotRibbonPanelCtrls;
                        partSketchSlotRibbonPanelCtrls = m_partSketchSlotRibbonPanel.CommandControls;

                        //add the buttons to the ribbon panel
                        CommandControl drawSlotCmdBtnCmdCtrl;
                        drawSlotCmdBtnCmdCtrl = partSketchSlotRibbonPanelCtrls.AddButton(m_addSlotOptionButton.ButtonDefinition, false, true, "", false);
                    }
                }

                MessageBox.Show("This is a Carnegie Mellon University :: CERLAB test of \nAnisotropic Geometric Features Pattern Generation \nfor Industrial Design on Higly Curved Surfaces \nUsing Riemannian Metric Tensor fields \n\nAuthor: Diego Andrade \n\n2014");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Beispiel #11
0
        public static void GetAddinClassId(Type t)
        {
            GuidAttribute guidAtt = (GuidAttribute)GuidAttribute.GetCustomAttribute(t, typeof(GuidAttribute));

            mClassId = "{" + guidAtt.Value + "}";
        }
Beispiel #12
0
        public static void Get_addInClassId(Type t)
        {
            GuidAttribute gAttr = (GuidAttribute)GuidAttribute.GetCustomAttribute(t, typeof(GuidAttribute));

            ClientId = "{" + gAttr.Value + "}";
        }