/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { appOutlook = (Microsoft.Office.Interop.Outlook.Application)application; addInInstance = addInInst; syncMgr = new SyncManager(ref appOutlook); syncMgr.GetSettings(); // get a connection and update the project list information from the server if (syncMgr.GetConnection()) { syncMgr.GetProjects(false); } syncMgr.AddAllFolderEventHandlers(); // If we are not loaded upon startup, forward to OnStartupComplete() // and pass the incoming System.Array. if (connectMode != ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } // TODO: Call this dynamically based off the system settings. syncMgr.StartTimer(); } catch (System.Exception ex) { ErrorHandler.PublishError(ex, logger); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { m_Commands = new System.Collections.ArrayList(); m_Commands.Add(new StudentClient.GotoHomePage()); m_Commands.Add(new StudentClient.RemoveCourseCommand()); m_Commands.Add(new StudentClient.AddCourseCommand()); m_strProgID = "StudentClient.Connect"; m_applicationObject = (EnvDTE._DTE)application; m_addInInstance = (EnvDTE.AddIn)addInInst; // Rather than expose the IDispatch of this object (VS7AddIn), we want to expose // a clean interface from another object. m_applicationObject.AddIns.Item(m_strProgID).Object = new StudentClient.ClientTools(m_applicationObject); // Allow all of the components to perform any registration steps they feel necessary. foreach (IAddInCommand command in m_Commands) { try { command.OnConnection(m_applicationObject, connectMode, m_addInInstance); } catch (System.Exception /*e*/) { } } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { Debug.WriteLine("DemoAddin: OnConnection() method called"); applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; if (connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup) { object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; // When run, the Add-in wizard prepared the registry for the Add-in. // At a later time, the Add-in or its commands may become unavailable for reasons such as: // 1) You moved this project to a computer other than which is was originally created on. // 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. // 3) You add new commands or modify commands already defined. // You will need to re-register the Add-in by building the DemoAddinSetup project, // right-clicking the project in the Solution Explorer, and then choosing install. // Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in // the project directory, or run 'devenv /setup' from a command prompt. try { Command command = commands.AddNamedCommand(addInInstance, "DemoAddin", "DemoAddin", "Executes the command for DemoAddin", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); CommandBar commandBar = (CommandBar)commandBars["Tools"]; CommandBarControl commandBarControl = command.AddControl(commandBar, 1); } catch (System.Exception /*e*/) { } } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { m_Commands = new System.Collections.ArrayList(); m_Commands.Add(new CodeMarker()); m_Commands.Add(new GotoHomePage()); m_Commands.Add(new DeleteCourseCommand()); m_Commands.Add(new AddCourseCommand()); m_Commands.Add(new AddExistingCourseCommand()); m_strProgID = "FacultyClient.Connect"; m_applicationObject = (EnvDTE._DTE)application; m_addInInstance = (EnvDTE.AddIn)addInInst; // Instead of the default .Object property (which would be the IDispatch of this object), we need // to create an instance of an object that exposes the proper COM interfaces. m_applicationObject.AddIns.Item(m_strProgID).Object = new FacultyTools(m_applicationObject); // Allow all of the components to perform any registration steps they feel necessary. foreach (IAddInCommand command in m_Commands) { try { command.OnConnection(m_applicationObject, connectMode, m_addInInstance); } catch (System.Exception /*e*/) { } } }
/// <summary> /// 实现 IDTExtensibility2 接口的OnConnection 方法. /// 当外接程序被加载时,接收通知. /// </summary> /// <param term='application'> /// 宿主应用程序的根对象。 /// </param> /// <param term='connectMode'> /// 描述外接程序正在被加载的情况. /// </param> /// <param term='addInInst'> /// 表示此外接程序的对象. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { MessageBox.Show("CSOneNoteRibbonAddIn OnConnection"); applicationObject = application; addInInstance = addInInst; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { string strAppName = (string)application.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, application, null); if (strAppName == "Microsoft Word") { appThis = new WordApp(application); } else if (strAppName == "Microsoft Excel") { appThis = new ExcelApp(application); } else if (strAppName == "Microsoft Publisher") { appThis = new PubApp(application); } else if (strAppName == "Microsoft Access") { appThis = new AccessApp(application); } else { string strError = String.Format("The '{0}' application is not supported!", strAppName); System.Windows.Forms.MessageBox.Show(strError, OfficeApp.cstrCaption); throw new Exception(strError); } if (connectMode != ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { Singletons.Module = this; if (application is Microsoft.Office.Interop.Word.Application) { Integ = new WordIntegration(application as Microsoft.Office.Interop.Word.Application, addInInst); } else if (application is Microsoft.Office.Interop.Excel.Application) { Integ = new ExcelIntegration(application as Microsoft.Office.Interop.Excel.Application, addInInst); } else if (application is Microsoft.Office.Interop.PowerPoint.Application) { Integ = new PowerPointIntegration(application as Microsoft.Office.Interop.PowerPoint.Application, addInInst); } Integ.DocumentClosed += new DocumentEventHandler(Integ_DocumentClosed); Integ.DocumentOpened += new DocumentEventHandler(Integ_DocumentOpened); Integ.DocumentSaved += new DocumentEventHandler(Integ_DocumentSaved); if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } } catch (Exception e) { Utils.ShowError(e); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = application; addInInstance = addInInst; Application powerPointApp = (Application)application; RegisterEvents(powerPointApp); }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = application; addInInstance = addInInst; _excel = (Application)application; Macro.instance.excelApp = _excel; Macro.instance.workbooks = _excel.Workbooks; Macro.instance.worksheets = _excel.Worksheets; }
private SelectionForm selectionForm = null; //объект диалогового окна public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = application; addInInstance = addInInst; if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } }
public void OnConnection(object app, Extensibility.ext_ConnectMode mode, object addin, ref System.Array custom) { appobj_ = (_DTE)app; addin_ = (AddIn)addin; EnvDTE.Events events = appobj_.Events; events_ = (EnvDTE.WindowEvents)events.get_WindowEvents(); handler_ = new _dispWindowEvents_WindowActivatedEventHandler(this.OnWindowActivated); events_.WindowActivated += handler_; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { _OutlookApplication = (Microsoft.Office.Interop.Outlook.Application)application; InspectorWrapper.TheOutlookApplication = _OutlookApplication; _addInInstance = addInInst; if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = application; addInInstance = addInInst; if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); // when the add-in has loaded, call this in case the addin was loaded after ppt finished // starting up } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { System.Windows.Forms.MessageBox.Show("OnConnection method"); applicationObject = application; addInInstance = addInInst; _excel = (Application)application; Macro.instance.excelApp = _excel; Macro.instance.workbooks = _excel.Workbooks; Macro.instance.worksheets = _excel.Worksheets; startServer(); }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { MindManager.Application app = (MindManager.Application)application; //TODO: Connect the Add-in } catch (System.Exception e) { Mindjet.Utility.HandleError(e); } }
bool flag;//= false; /// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { if (((Word.Application)application).Caption == "GenWord") { flag = true; } else { flag = false; } applicationObject = (Word.Application)application; addInInstance = addInInst; }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { this.logger.WriteLine("OnConnection: Begin"); this.objOutlook = (Application)application; this.addInInstance = addInInst; if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { OnStartupComplete(ref custom); } this.logger.WriteLine("OnConnection: End"); }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = (Excel.Application)application; addInInstance = addInInst; //注册xll string path = GetAssemblyPath(); string xllPath = path + "UMSExcelAddin.xll"; //注册xll applicationObject.RegisterXLL(xllPath); //注册rtd4 RegistryKey rkTest = Registry.ClassesRoot.OpenSubKey("CLSID\\{449546C3-2F5A-434D-9AB7-12C9DE98EA6F}\\"); if (rkTest == null) { DllRegisterServer(); //Dll没有注册,在这里调用DllRegisterServer()吧 } //applicationObject.get_Range().Calculate(); Object oMissing = System.Reflection.Missing.Value; if (connectMode == ext_ConnectMode.ext_cm_Startup) { int a = string.Compare("11.0", applicationObject.Version); if (a >= 0) { ExcelVersion = 2003; CommandBar cmdBarSystem = applicationObject.CommandBars["Worksheet Menu Bar"]; CommandBarControl cmdControlAddin = cmdBarSystem.Controls.Add(MsoControlType.msoControlPopup, oMissing, "", 11, true); cmdControlAddin.Caption = "UMSExcel Addin"; CommandBarPopup cmdBarPopAddin = (CommandBarPopup)cmdControlAddin; CommandBar cmdBarAddin = cmdBarPopAddin.CommandBar; AddCommandBar(cmdBarAddin); //create a new bar CommandBar UMSBar = applicationObject.CommandBars.Add("UMSExcel Addin", MsoBarPosition.msoBarTop, false, true); UMSBar.Visible = true; //AddCommandBar(UMSBar); } else { ExcelVersion = 2007; } } }
public void OnConnection( object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { olkApp = (Outlook.Application)application; // Setup a mapping between each Inspector and its task pane. inspectorPanes = new Dictionary <Office.CustomTaskPane, Outlook.Inspector>(); // Sink the NewInspector events. inspectors = this.olkApp.Inspectors; inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler( inspectors_NewInspector); }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { DebugInfo.applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; try { if (!initialized) { InitTachyToolbar(); InitTachyToolWindows(); initialized = true; } } catch (System.Exception e) { MessageBox.Show(e.Message + "\r\n\r\n" + e.InnerException + "\r\n\r\n" + e.StackTrace); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { addInInstance = addInInst; MMUtils.AddinName = T_AddInName; MMUtils.Version = 18; MMUtils.MindManager = (Application)application; DocumentStorage.Init(); PLACES = new PlacesGroup(); PROJECTS = new ProjectsGroup(); MAPS = new MapsGroup(); ABOUT = new AboutGroup(); m_myTab = MMUtils.MindManager.Ribbon.Tabs.Add(0, MMUtils.GetString("main.name"), "www.sergioross.com/api/documentation/demos/ribbontab"); m_myTab.Visible = false; PLACES.Create(m_myTab); PROJECTS.Create(m_myTab); MAPS.Create(m_myTab); ABOUT.Create(m_myTab); }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; // Add code for How-To. // Initialize all the variables that contain the events we're looking for. // Get the events object that contains information about all of the // extensibility events. m_Events = ((DTE)(application)).Events; // Initialize a variable to track SolutionEvents m_SolutionEvents = m_Events.SolutionEvents; // Initialize a variable to track BuildEvents m_BuildEvents = m_Events.BuildEvents; m_BuildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(m_BuildEvents_OnBuildBegin); m_SolutionEvents.AfterClosing += new _dispSolutionEvents_AfterClosingEventHandler(m_SolutionEvents_AfterClosing); m_SolutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(m_SolutionEvents_Opened); m_SolutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(m_SolutionEvents_ProjectAdded); m_SolutionEvents.ProjectRemoved += new _dispSolutionEvents_ProjectRemovedEventHandler(m_SolutionEvents_ProjectRemoved); m_SolutionEvents.ProjectRenamed += new _dispSolutionEvents_ProjectRenamedEventHandler(m_SolutionEvents_ProjectRenamed); }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; try { AddCommand.ReplaceCommandInMenu( addInInstance, applicationObject, iconNumber, addInInstance.ProgID, "IconExplorerAddIn", "Icon Explorer: this is #" + iconNumber.ToString(), "Icon will change to Icon #" + Convert.ToString(iconNumber + 1) + "next time you click this command", "Tools" ); } catch (System.Exception e) { MessageBox.Show("Exception in OnConnection: " + e.Message); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { //MessageBox.Show("Starting Addin from " + AppDomain.CurrentDomain.BaseDirectory); // Get the initial Application object logger.Info("GContactsSync Connecting."); myApplicationObject = (Ol.Application)application; myAddInInstance = addInInst; if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup) { // MessageBox.Show("On Connection - Startup"); OnStartupComplete(ref custom); } logger.Info("GContactsSync connected succesfully."); } catch (System.Exception ex) { logger.Error(ex.Message); logger.Debug(ex.StackTrace.ToString()); MessageBox.Show("Error " + ex.Message); } }
public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { applicationObject = (DTE2)application; addInInstance = (EnvDTE.AddIn)addInInst; switch (connectMode) { case ext_ConnectMode.ext_cm_UISetup: // Initialize the UI of the add-in AddPermanentUI(); break; case ext_ConnectMode.ext_cm_Startup: // The add-in was marked to load on startup // Do nothing at this point because the IDE may not be fully initialized // Visual Studio will call OnStartupComplete when fully initialized break; case ext_ConnectMode.ext_cm_AfterStartup: // The add-in was loaded by hand after startup using the Add-In Manager // Initialize it in the same way that when is loaded on startup InitializeAddIn(); break; } } catch (System.Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); } }
public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref System.Array custom) { try { m_theApp = (PBObjLib.Application)Application; #region command bar //this code attaches the add-in to the add-in command bar bool bPropertyExist = false; bool bMakeCoolExist = false; bool bUOMExist = false; bool bAlarmExist = false; bool bReplaceExist = false; bool bSearchTag = false; bool bScript = false; //delete this code if you do not desire to have the add-in added //to the commandbar as a button //add the command bar if it is not there..... PBObjLib.PBCommandBar pbCommandBar = m_theApp.CommandBars.Item("Add-Ins"); if (pbCommandBar == null) { m_theApp.CommandBars.Add("Add-Ins", 1, false, false); pbCommandBar = m_theApp.CommandBars.Item("Add-Ins"); } if (pbCommandBar != null) { PBObjLib.PBCommandBarControls pbControls = (PBObjLib.PBCommandBarControls)pbCommandBar.Controls; System.Collections.IEnumerator enumerator = pbControls.GetEnumerator(); while (enumerator.MoveNext()) { PBObjLib.PBCommandBarControl cb = (PBObjLib.PBCommandBarControl)enumerator.Current; //cb.Delete(); string strCurrName = cb.Caption.ToString(); if (strCurrName == m_strAddInName) { bPropertyExist = true; } if (strCurrName == m_strAddInName2) { bMakeCoolExist = true; } if (strCurrName == m_strAddInName3) { bUOMExist = true; } if (strCurrName == m_strAddInName4) { bAlarmExist = true; } if (strCurrName == m_strAddInName5) { bReplaceExist = true; } if (strCurrName == m_strAddInName6) { bSearchTag = true; } if (strCurrName == m_strAddInName7) { bScript = true; } } if (!bPropertyExist) { m_pbControl = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControl.Caption = m_strAddInName; m_pbControl.ToolTipText = Res2.m_pbControlSettingsToolTipText; ((ECommandBarButtonEvents_Event)m_pbControl).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.AddInClicked); } else { m_pbControl = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName); } if (!bMakeCoolExist) { m_pbControlAlign = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlAlign.Caption = m_strAddInName2; ((ECommandBarButtonEvents_Event)m_pbControlAlign).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.FillGood); } else { m_pbControlAlign = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName2); } if (!bUOMExist) { m_pbControlUOM = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlUOM.Caption = m_strAddInName3; ((ECommandBarButtonEvents_Event)m_pbControlUOM).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.SetUOM); } else { m_pbControlUOM = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName3); } if (!bAlarmExist) { m_pbControlAlarm = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlAlarm.Caption = m_strAddInName4; ((ECommandBarButtonEvents_Event)m_pbControlAlarm).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ChangeAlarm); } else { m_pbControlAlarm = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName4); } if (!bReplaceExist) { m_pbControlReplace = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlReplace.Caption = m_strAddInName5; ((ECommandBarButtonEvents_Event)m_pbControlReplace).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ReplaceInValue); } else { m_pbControlReplace = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName5); } if (!bSearchTag) { m_pbControlSearch = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlSearch.Caption = m_strAddInName6; ((ECommandBarButtonEvents_Event)m_pbControlSearch).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.SearchValue); } else { m_pbControlSearch = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName6); } if (!bScript) { m_pbControlScript = (PBObjLib.PBCommandBarControl)pbControls.Add((Object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false); m_pbControlScript.Caption = m_strAddInName7; ((ECommandBarButtonEvents_Event)m_pbControlScript).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.ShowScriptForm); } else { m_pbControlScript = (PBObjLib.PBCommandBarControl)pbControls.Item(m_strAddInName7); } } #endregion } catch (Exception ex) { MessageBox.Show("Exception in OnConnection=" + ex.Message); } }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { appOb = (_DTE)application; addInst = (AddIn)addInInst; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { applicationObject = application; addInInstance = addInInst; }
/// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param term='application'> /// Root object of the host application. /// </param> /// <param term='connectMode'> /// Describes how the Add-in is being loaded. /// </param> /// <param term='addInInst'> /// Object representing this Add-in. /// </param> /// <seealso class='IDTExtensibility2' /> public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper(); string [] monoVersions = null; try { monoVersions = regHlpr.GetMonoVersions(); } catch (Exception exc) { // Mono may not be installed MessageBox.Show(exc.Message, "Prj2make Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; // Pull the cord and discontinue loading the add-in } applicationObject = (_DTE)application; addInInstance = (AddIn)addInInst; int selectedIndexForComboBox = 1; EnvDTE.Events events = applicationObject.Events; OutputWindow outputWindow = (OutputWindow)applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object; outputWindowPane = outputWindow.OutputWindowPanes.Add("Prj2Make Messages"); object [] contextGUIDS = new object[] { }; Commands commands = applicationObject.Commands; _CommandBars commandBars = applicationObject.CommandBars; CommandBar cmdBarMonoBarra; CommandBar commandBar = (CommandBar)commandBars["Tools"]; CommandBarPopup popMenu; // Prj2Make popupmenu CommandBarPopup popMenu2; // Explorer Current Project // Creates a more legible representation of the // command bar control collection contained in // the Tools command bar CommandBarControls commandBarControls; commandBarControls = commandBar.Controls; // Create Makefile Command command1 = null; // Generate MonoDevelop files Command command2 = null; // Import MonoDevelop Solutions Command command3 = null; // Run on Mono Command command5 = null; // vsprj2make Options Command command6 = null; // Generate a distribution unit Command command7 = null; // Explore current solution Command command8 = null; // Explore current Project Command command9 = null; // ------------- Add Pop-up menu ---------------- popMenu2 = (CommandBarPopup)commandBarControls.Add( MsoControlType.msoControlPopup, System.Reflection.Missing.Value, // Object ID System.Reflection.Missing.Value, // Object parameters 1, // Object before true); popMenu2.Caption = "&Windows Explore"; // ------------- Add Pop-up menu ---------------- popMenu = (CommandBarPopup)commandBarControls.Add( MsoControlType.msoControlPopup, System.Reflection.Missing.Value, // Object ID System.Reflection.Missing.Value, // Object parameters 1, // Object before true); popMenu.Caption = "Prj&2Make"; // Add the create makefile command -- command1 command1 = CreateNamedCommand( addInInstance, commands, "CreateMake", "Create &Makefile", "Generate Makefile", ref contextGUIDS ); if (command1 == null) { command1 = GetExistingNamedCommand(commands, "vsprj2make.Connect.CreateMake"); } try { command1.AddControl(popMenu.CommandBar, 1); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the generate a dist unit command -- command7 command7 = CreateNamedCommand( addInInstance, commands, "GenDistUnit", "Generate Distribution &Unit", "Generates a distribution unit (zip file)", ref contextGUIDS ); if (command7 == null) { command7 = GetExistingNamedCommand(commands, "vsprj2make.Connect.GenDistUnit"); } try { command7.AddControl(popMenu.CommandBar, 2); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the GenMDFiles command -- command2 command2 = CreateNamedCommand( addInInstance, commands, "GenMDFiles", "Create Mono&Develop Solution", "Generate MonoDevelop Solution", ref contextGUIDS ); if (command2 == null) { command2 = GetExistingNamedCommand(commands, "vsprj2make.Connect.GenMDFiles"); } try { command2.AddControl(popMenu.CommandBar, 3); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the PrjxToCsproj command -- command3 command3 = CreateNamedCommand( addInInstance, commands, "PrjxToCsproj", "&Import MonoDevelop Solution...", "Imports a MonoDevelop Solution", ref contextGUIDS ); if (command3 == null) { command3 = GetExistingNamedCommand(commands, "vsprj2make.Connect.PrjxToCsproj"); } try { command3.AddControl(popMenu.CommandBar, 4); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the Ron on Mono command -- command5 command5 = CreateNamedCommand( addInInstance, commands, "RunOnMono", "&Run on Mono", "Run solution on mono", ref contextGUIDS ); if (command5 == null) { command5 = GetExistingNamedCommand(commands, "vsprj2make.Connect.RunOnMono"); } try { command5.AddControl(popMenu.CommandBar, 5); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the Options command -- command6 command6 = CreateNamedCommand( addInInstance, commands, "Options", "&Options...", "Options for prj2make Add-in", ref contextGUIDS ); if (command6 == null) { command6 = GetExistingNamedCommand(commands, "vsprj2make.Connect.Options"); } try { command6.AddControl(popMenu.CommandBar, 6); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the ExploreCurrSln command -- command8 command8 = CreateNamedCommand( addInInstance, commands, "ExploreCurrSln", "Current &Solution", "Explore the current solution", ref contextGUIDS ); if (command8 == null) { command8 = GetExistingNamedCommand(commands, "vsprj2make.Connect.ExploreCurrSln"); } try { command8.AddControl(popMenu2.CommandBar, 1); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Add the ExploreCurrDoc command -- command9 command9 = CreateNamedCommand( addInInstance, commands, "ExploreCurrDoc", "Current &Document", "Explore the current Document", ref contextGUIDS ); if (command9 == null) { command9 = GetExistingNamedCommand(commands, "vsprj2make.Connect.ExploreCurrDoc"); } try { command9.AddControl(popMenu2.CommandBar, 2); } catch (System.Exception exc) { Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message)); } // Mono Toolbar CommandBar cmdBarBuild = (CommandBar)commandBars["Build"]; try { cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"]; } catch (Exception) { commands.AddCommandBar("MonoBarra", vsCommandBarType.vsCommandBarTypeToolbar, cmdBarBuild, 1 ); cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"]; cmdBarMonoBarra.Visible = true; } if (testInMonoCommandBarButton == null) { // Create the Ron on Mono Button testInMonoCommandBarButton = (CommandBarButton)cmdBarMonoBarra.Controls.Add( Microsoft.Office.Core.MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, false ); testInMonoCommandBarButton.Caption = "Run on &Mono"; testInMonoCommandBarButton.DescriptionText = "Run solution with the mono runtime"; testInMonoCommandBarButton.TooltipText = "Run on mono"; testInMonoCommandBarButton.ShortcutText = "Run on &Mono"; testInMonoCommandBarButton.Style = MsoButtonStyle.msoButtonCaption; testInMonoCommandBarButton.Click += new _CommandBarButtonEvents_ClickEventHandler(testInMonoCommandBarButton_Click); } if (versionComboBox == null) { // Create the combobox versionComboBox = (CommandBarComboBox)cmdBarMonoBarra.Controls.Add( Microsoft.Office.Core.MsoControlType.msoControlDropdown, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 2, false ); for (int i = 0; i < monoVersions.Length; i++) { versionComboBox.AddItem(monoVersions[i], i + 1); if (monoVersions[i].CompareTo(regHlpr.GetDefaultClr()) == 0) { selectedIndexForComboBox = i + 1; } } versionComboBox.Change += new _CommandBarComboBoxEvents_ChangeEventHandler(versionComboBox_Change); // Select the active index based on // the current mono version versionComboBox.ListIndex = selectedIndexForComboBox; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Implements the OnConnection method of the IDTExtensibility2 interface. /// Receives notification that the Add-in is being loaded. /// </summary> /// <param name="application">The application.</param> /// <param name="connectMode">The connect mode.</param> /// <param name="addInInst">The add in inst.</param> /// <param name="custom">The custom.</param> /// <seealso class="IDTExtensibility2"/> /// ------------------------------------------------------------------------------------ public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { try { CheckForUpdates(); m_dte = (DTE2)application; m_nantCommands = new CmdHandler(); m_nantCommands.DTE = m_dte; m_addInInstance = (AddIn)addInInst; EnvDTE.Events events = DTE.Events; OutputWindow outputWindow = (OutputWindow)DTE.Windows.Item(Constants.vsWindowKindOutput).Object; m_solutionEvents = (EnvDTE.SolutionEvents)events.SolutionEvents; // Get the commands of the Build group RegisterCommandHandler(882, // build solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(883, // rebuild solution new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildSolution)); RegisterCommandHandler(886, // build project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(887, // rebuild project new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(890, // Build Cancel new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildCancel)); RegisterCommandHandler(892, // build project (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); RegisterCommandHandler(893, // rebuild project (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); // 979-988 build project (from menu when no project item is selected) // 989-998 rebuild project (from menu when no project item is selected) for (int i = 979; i < 999; i++) { RegisterCommandHandler(i, new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnBuildProject)); } RegisterCommandHandler(295, // Debug Start new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(356, // Debug/Start new instance (from context menu) new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStart)); RegisterCommandHandler(368, // Debug Start without debugging new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStartWithoutDebugging)); // RegisterCommandHandler(248, // Debug Step into // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(357, // Debug Step into (from context menu) // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepInto)); // RegisterCommandHandler(249, // Debug Step over // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugStepOver)); // RegisterCommandHandler(251, // Debug Run to cursor // new _dispCommandEvents_BeforeExecuteEventHandler(m_nantCommands.OnDebugRunToCursor)); // TODO: need to handle 891 Batch build! m_buildEvents = (EnvDTE.BuildEvents)events.BuildEvents; m_solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(Opened); m_solutionEvents.ProjectAdded += new _dispSolutionEvents_ProjectAddedEventHandler(OnProjectAdded); m_buildEvents.OnBuildBegin += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin); // try to add the commands AddToolbar(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Got exception: " + e.Message); } }