Ejemplo n.º 1
0
        /// <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 virtual void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            this._application = new LateBindingObject(application);

            // read Office version info
            int version;

            using (new UILanguageHelper())
            {
                int.TryParse(_application.GetString("Version"),
                             NumberStyles.Float,
                             CultureInfo.InvariantCulture,
                             out version);
                _officeVersion = (OfficeVersion)version;
            }

            Application.EnableVisualStyles();

            this.SetUICulture();

            this.DialogBoxTitle = _addinLib.GetString("OdfConverterTitle");

            LateBindingObject addInInstance = new LateBindingObject(addInInst);

            addInInstance.Set("Object", (object)this);

            if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
            {
                OnStartupComplete(ref custom);
            }
        }
Ejemplo n.º 2
0
        /// <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)
        {
            _MindManager  = (Mindjet.MindManager.Interop.Application)application;
            addInInstance = addInInst;

            AddCommands();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers a command and places it onto the context menu for the editor
        /// window.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "MarkCodeForExtraction";
            m_strName        = AMResources.GetLocalizedString("CodeMarkerName");
            m_strItemText    = AMResources.GetLocalizedString("CodeMarkerItemText");

            string description = AMResources.GetLocalizedString("CodeMarkerDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, description,
                                                   true, 12, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the top-level context menu for the editor
                // code window, if possible.
                officeCommandBars            = m_applicationObject.CommandBars;
                officeCommandBar             = (CommandBar)officeCommandBars["Code Window"];
                officeCommandControl         = command.AddControl((object)officeCommandBar, 1);
                officeCommandControl.Caption = m_strItemText;

                string amFacultyMenuItem = AMResources.GetLocalizedString("AMFacultyMenuItem");
                // Also attempt to add it to the Tools menu as well, for accessibility.
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amFacultyMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amFacultyMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }

                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = AMResources.GetLocalizedString("CodeMarkerToolsMenuItemText");
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
        /// <summary>
        /// Called when the AddIn is loaded. This method allows each of the commands to
        /// store member variables with the objects passed in and ensure that the menu
        /// items and commands have been properly added to the object model.
        /// </summary>
        /// <param name="application"> Root object in the application </param>
        /// <param name="connectMode"> 'Mode' in which the environment is starting up the addin </param>
        /// <param name="addIn"> Object representing this AddIn in the Object Model</param>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            try
            {
                m_applicationObject = (EnvDTE._DTE)application;
                m_addInInstance     = (EnvDTE.AddIn)addIn;

                m_strCommandName = "AMDeleteCourse";
                m_strName        = AMResources.GetLocalizedString("AMDeleteCourseName");
                m_strItemText    = AMResources.GetLocalizedString("AMDeleteCourseItemText");

                string            description          = AMResources.GetLocalizedString("AMDeleteCourseDescription");
                EnvDTE.Commands   commands             = null;
                EnvDTE.Command    command              = null;
                _CommandBars      officeCommandBars    = null;
                CommandBar        officeCommandBar     = null;
                CommandBarControl officeCommandControl = null;
                CommandBar        officeAcademic       = null;

                object [] contextGuids;
                contextGuids = new object[] { };

                commands = m_applicationObject.Commands;
                try
                {
                    command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, description,
                                                       false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                    // Add the new command to the tools menu
                    officeCommandBars = m_applicationObject.CommandBars;
                    string amFacultyMenuItem = AMResources.GetLocalizedString("AMFacultyMenuItem");
                    try
                    {
                        officeAcademic = (CommandBar)officeCommandBars[amFacultyMenuItem];
                    }
                    catch
                    {
                    }
                    if (officeAcademic == null)
                    {
                        officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                        officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amFacultyMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                    }
                    officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                    officeCommandControl.Caption = m_strItemText;
                }
                catch
                {
                    // Falling into this simply means that the command was already registered.
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception e = " + e.Message);
            }
        }
Ejemplo n.º 5
0
        /// <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);
            }
        }
Ejemplo n.º 6
0
 public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
 {
     if (application is Excel.Application)
     {
         _excelapp                   = (Excel.Application)application;
         _addInInstance              = addInInst;
         _commandList                = new Dictionary <Excel.Workbook, WorkbookInstance>();
         _excelapp.WorkbookActivate += new Excel.AppEvents_WorkbookActivateEventHandler(OnWorkbookActivate);
         OnWorkbookActivate(_excelapp.ActiveWorkbook);
     }
 }
 public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
 {
     try
     {
         _outlookApplication = new Outlook.Application(null, application);
         NetOffice.OutlookSecurity.Suppress.Enabled = true;
     }
     catch (Exception ex)
     {
         string message = string.Format("An error occured.{0}{0}{1}", Environment.NewLine, ex.Message);
         MessageBox.Show(message, "OPENERP-OnConnection", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Registers a command and places it on the Tools menu.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "AMStudentGotoHomePage";
            m_strName        = AMResources.GetLocalizedString("AMStudentGotoHomePageName");
            m_strItemText    = AMResources.GetLocalizedString("AMStudentGotoHomePageItemText");
            m_strHomePageUrl = "vs:/default.htm?tab=" + AMResources.GetLocalizedString("AMStudentGotoHomePagePageName");

            string strDescription = AMResources.GetLocalizedString("GotoHomePageDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, strDescription,
                                                   false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the tools menu
                officeCommandBars = m_applicationObject.CommandBars;
                string amStudentMenuItem = AMResources.GetLocalizedString("AMStudentMenuItem");
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amStudentMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amStudentMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }
                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = m_strItemText;
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        ///		Called during Outlook startup.
        /// </summary>
        /// <remarks>
        ///		Should not be called from code.
        /// </remarks>
        /// <param name="application">The Outlook application.</param>
        /// <param name="connectMode">The startup type.</param>
        /// <param name="addInInst">This addin.</param>
        /// <param name="custom">Any custom arguments passed to Outlook.</param>
        public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            addInInstance = addInInst;
            System.Runtime.InteropServices.RegistrationServices reg = new System.Runtime.InteropServices.RegistrationServices();
            string progid = reg.GetProgIdForType(this.GetType());

            manager = new OutlookUIManager((RlOutlook.Application)application, this, progid);
            manager.OutlookClosed += new OutlookEventHandler(OnOutlookClosed);

            if (connectMode != Extensibility.ext_ConnectMode.ext_cm_Startup)
            {
                OnStartupComplete(ref custom);
            }
        }
Ejemplo n.º 10
0
        /// <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)
        {
            // Store the Excel host application. Exit if host was not Excel.
            m_xlApp = application as Excel.Application;
            if (m_xlApp == null)
            {
                return;
            }

            // If an addInInst object given of the type COMAddin then it was loaded as COM add-in.
            // If addInInst is the same object as myself, then I'm loaded as Automation add-in.
            if (addInInst != this)
            {
                // Attach myself to the add-in object.
                // In that way I can call functions of this object from VBA using the add-in collection.
                Office.COMAddIn cai = addInInst as Office.COMAddIn;
                cai.Object = this;

                // Now install menu item and add event handler.
                m_menuItem        = AddInUtils.AddMenuItem(m_xlApp, cai, m_menuName, m_menuItemCaption, m_menuItemKey);
                m_menuItem.Click += new Office._CommandBarButtonEvents_ClickEventHandler(MyMenuHandler);
            }
        }
 private tskPane myControl;     //My UserControl
 public void OnConnection(object Application, Extensibility.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
 {
     WordApp = Application as Microsoft.Office.Interop.Word.Application;
     WordApp.DocumentOpen += new Word.ApplicationEvents4_DocumentOpenEventHandler(WordApp_DocumentOpen);
 }
Ejemplo n.º 12
0
 // / <summary>
 // / Implements the OnConnection method of the IDTExtensibility2 interface.
 // / Receives notification that the Add-in is being loaded.
 // / </summary>
 // / <param name="application">Root object of the host application.</param>
 // / <param name="connectMode">Describes how the Add-in is being loaded.</param>
 // / <param name="addInInst">Object representing this Add-in.</param>
 // / <param name="custom">Array of parameters that are host application specific.</param>
 void Extensibility.IDTExtensibility2.OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref Array custom)
 {
     // Store reference to the Excel host application (m_xlApp will become null if not loaded by Excel).
     m_xlApp = application as Excel.Application;
 }