Exemple #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 void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE)application;
            _addInInstance     = (AddIn)addInInst;

            // determine the installation directory
            System.Uri uri = new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().EscapedCodeBase);
            installationDir  = Path.GetDirectoryName(System.Uri.UnescapeDataString(uri.AbsolutePath));
            installationDir += "\\";

            // General startup code
            if ((ext_ConnectMode.ext_cm_AfterStartup == connectMode) ||
                (ext_ConnectMode.ext_cm_Startup == connectMode) ||
                (ext_ConnectMode.ext_cm_CommandLine == connectMode))
            {
                QtVersionManager vm    = QtVersionManager.The();
                string           error = null;
                if (vm.HasInvalidVersions(out error))
                {
                    Messages.DisplayErrorMessage(error);
                }
                eventHandler = new AddInEventHandler(_applicationObject);
                extLoader    = new ExtLoader();
                if (ext_ConnectMode.ext_cm_CommandLine != connectMode)
                {
                    try
                    {
                        initializer = new AddinInit(_applicationObject);
                        initializer.removeCommands();
                        initializer.registerCommands();
                        UpdateDefaultEditors(true);
                    }
                    catch (System.Exception e)
                    {
                        MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
                    }
                }
                else
                {
                    commandLine = true;
                }
            }
        }
Exemple #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, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE)application;
            _addInInstance = (AddIn)addInInst;

            // determine the installation directory
            System.Uri uri = new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().EscapedCodeBase);
            installationDir = Path.GetDirectoryName(System.Uri.UnescapeDataString(uri.AbsolutePath));
            installationDir += "\\";

            // General startup code
            if ((ext_ConnectMode.ext_cm_AfterStartup == connectMode) ||
                (ext_ConnectMode.ext_cm_Startup == connectMode) ||
                (ext_ConnectMode.ext_cm_CommandLine == connectMode))
            {
                QtVersionManager vm = QtVersionManager.The();
                string error = null;
                if (vm.HasInvalidVersions(out error))
                    Messages.DisplayErrorMessage(error);
                eventHandler = new AddInEventHandler(_applicationObject);
                extLoader = new ExtLoader();
                if (ext_ConnectMode.ext_cm_CommandLine != connectMode)
                {
                    try
                    {
                        initializer = new AddinInit(_applicationObject);
                        initializer.removeCommands();
                        initializer.registerCommands();
                        UpdateDefaultEditors(true);
                    }
                    catch (System.Exception e)
                    {
                        MessageBox.Show(e.Message + "\r\n\r\nStacktrace:\r\n" + e.StackTrace);
                    }
                }
                else
                    commandLine = true;
            }
        }