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 = Properties.Resources.moderator; //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; //Button1 InventorButton button5 = new InventorButton( "Moderator", "InventorAddinServer.Button_" + Guid.NewGuid().ToString(), "Button 1 description", "Moderatorrechte greifen", icon5, icon5, CommandTypesEnum.kShapeEditCmdType, ButtonDisplayEnum.kDisplayTextInLearningMode); button5.SetBehavior(true, true, true); button5.Execute = ButtonAction.Button5_Execute; 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.RibbonPanel = tab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); CommandControls cmdCtrls = AddinGlobal.RibbonPanel.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); cmdCtrls.AddButton(button5.ButtonDef, button5.DisplayBigIcon, button5.DisplayText, "", button5.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.RibbonPanel = modelRibbonTab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); CommandControls pcmdCtrls = AddinGlobal.RibbonPanel.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); pcmdCtrls.AddButton(button5.ButtonDef, button5.DisplayBigIcon, button5.DisplayText, "", button5.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.RibbonPanel = drawingRibbonTab.RibbonPanels.Add( "AddOutButtons", "AddOutButtons.RibbonPanel_" + Guid.NewGuid().ToString(), AddinGlobal.RibbonPanelId, String.Empty, true); CommandControls dcmdCtrls = AddinGlobal.RibbonPanel.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); dcmdCtrls.AddButton(button5.ButtonDef, button5.DisplayBigIcon, button5.DisplayText, "", button5.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. }
/// <summary> /// Registers a unique CommandInfo object</summary> /// <param name="info">CommandInfo object to register</param> protected override void RegisterCommandInfo(CommandInfo info) { m_commandsSorted = false; Image image = GetProperlySizedImage(info.ImageName); string uniqueId = GetCommandPath(info); // Create the WinForms controls to be associated with the registered MenuInfo var controls = new CommandControls( new ToolStripMenuItem(info.DisplayedMenuText, image), new ToolStripButton(info.MenuText, image) ); m_commandControls.Add(info, controls); // Associate the registered MenuInfo with this CommandService. Only can be registered once. info.CommandService = this; info.ShortcutsChanged += commandInfo_ShortcutsChanged; info.VisibilityChanged += commandInfo_VisibilityChanged; base.RegisterCommandInfo(info); ToolStripMenuItem menuItem = controls.MenuItem; menuItem.Name = uniqueId; menuItem.Tag = info.CommandTag; menuItem.MouseEnter += menuItem_MouseEnter; menuItem.MouseLeave += menuItem_MouseLeave; menuItem.MouseMove += menuItem_MouseMove; menuItem.Click += item_Click; ToolStripButton button = controls.Button; button.AutoSize = true; button.ImageScaling = ToolStripItemImageScaling.None; button.Name = uniqueId; button.DisplayStyle = (image != null) ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.Text; button.Tag = info.CommandTag; string toolTipText = info.Description; if (!string.IsNullOrEmpty(info.HelpUrl)) toolTipText += Environment.NewLine + "Press F1 for more info".Localize(); button.ToolTipText = toolTipText; button.Click += item_Click; }
public override List <Control> Render(frmCommandEditor editor) { base.Render(editor); var baseURLControlSet = CommandControls.CreateDefaultInputGroupFor("v_BaseURL", this, editor); RenderedControls.AddRange(baseURLControlSet); var apiEndPointControlSet = CommandControls.CreateDefaultInputGroupFor("v_APIEndPoint", this, editor); RenderedControls.AddRange(apiEndPointControlSet); var apiMethodLabel = CommandControls.CreateDefaultLabelFor("v_APIMethodType", this); var apiMethodDropdown = (ComboBox)CommandControls.CreateDropdownFor("v_APIMethodType", this); RenderedControls.AddRange(CommandControls.CreateDefaultDropdownGroupFor("v_RequestFormat", this, editor)); foreach (Method method in (Method[])Enum.GetValues(typeof(Method))) { apiMethodDropdown.Items.Add(method.ToString()); } RenderedControls.Add(apiMethodLabel); RenderedControls.Add(apiMethodDropdown); RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_RESTParameters", this)); RESTParametersGridViewHelper = new DataGridView(); RESTParametersGridViewHelper.Width = 500; RESTParametersGridViewHelper.Height = 140; RESTParametersGridViewHelper.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; RESTParametersGridViewHelper.AutoGenerateColumns = false; var selectColumn = new DataGridViewComboBoxColumn(); selectColumn.HeaderText = "Type"; selectColumn.DataPropertyName = "Parameter Type"; selectColumn.DataSource = new string[] { "HEADER", "PARAMETER", "JSON BODY", "FILE" }; RESTParametersGridViewHelper.Columns.Add(selectColumn); var paramNameColumn = new DataGridViewTextBoxColumn(); paramNameColumn.HeaderText = "Name"; paramNameColumn.DataPropertyName = "Parameter Name"; RESTParametersGridViewHelper.Columns.Add(paramNameColumn); var paramValueColumn = new DataGridViewTextBoxColumn(); paramValueColumn.HeaderText = "Value"; paramValueColumn.DataPropertyName = "Parameter Value"; RESTParametersGridViewHelper.Columns.Add(paramValueColumn); RESTParametersGridViewHelper.DataBindings.Add("DataSource", this, "v_RESTParameters", false, DataSourceUpdateMode.OnPropertyChanged); RenderedControls.Add(RESTParametersGridViewHelper); RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_AdvancedParameters", this)); //advanced parameters AdvancedRESTParametersGridViewHelper = new DataGridView(); AdvancedRESTParametersGridViewHelper.Width = 500; AdvancedRESTParametersGridViewHelper.Height = 140; AdvancedRESTParametersGridViewHelper.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; AdvancedRESTParametersGridViewHelper.AutoGenerateColumns = false; var advParamNameColumn = new DataGridViewTextBoxColumn(); advParamNameColumn.HeaderText = "Name"; advParamNameColumn.DataPropertyName = "Parameter Name"; AdvancedRESTParametersGridViewHelper.Columns.Add(advParamNameColumn); var advParamValueColumns = new DataGridViewTextBoxColumn(); advParamValueColumns.HeaderText = "Value"; advParamValueColumns.DataPropertyName = "Parameter Value"; AdvancedRESTParametersGridViewHelper.Columns.Add(advParamValueColumns); var advParamContentType = new DataGridViewTextBoxColumn(); advParamContentType.HeaderText = "Content Type"; advParamContentType.DataPropertyName = "Content Type"; AdvancedRESTParametersGridViewHelper.Columns.Add(advParamContentType); var advParamType = new DataGridViewComboBoxColumn(); advParamType.HeaderText = "Parameter Type"; advParamType.DataPropertyName = "Parameter Type"; advParamType.DataSource = new string[] { "Cookie", "GetOrPost", "HttpHeader", "QueryString", "RequestBody", "URLSegment", "QueryStringWithoutEncode" }; AdvancedRESTParametersGridViewHelper.Columns.Add(advParamType); AdvancedRESTParametersGridViewHelper.DataBindings.Add("DataSource", this, "v_AdvancedParameters", false, DataSourceUpdateMode.OnPropertyChanged); RenderedControls.Add(AdvancedRESTParametersGridViewHelper); RenderedControls.Add(CommandControls.CreateDefaultLabelFor("v_userVariableName", this)); var VariableNameControl = CommandControls.CreateStandardComboboxFor("v_userVariableName", this).AddVariableNames(editor); RenderedControls.AddRange(CommandControls.CreateUIHelpersFor("v_userVariableName", this, new Control[] { VariableNameControl }, editor)); RenderedControls.Add(VariableNameControl); return(RenderedControls); }