Exemple #1
0
        /// <summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
        //public Connect()
        //{
        //}
        /// <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 = (DTE2)application;
            addInInstance     = (AddIn)addInInst;

            // Only execute the startup code if the connection mode is a startup mode
            //if( connectMode == ext_ConnectMode.ext_cm_UISetup ) {
            if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                //Initializing Context
                Context.ApplicationObject = applicationObject;
                Context.AddInInstance     = addInInstance;

                //Initializing EventSinks
                SolutionEventSink solutionEventSink = new SolutionEventSink();
                addinEventSink = new AddinEventSink();

                //Initializing Controller
                controller = new UIController();
                controller.Sinks.Add(solutionEventSink);
                controller.Sinks.Add(addinEventSink);
                controller.Init(solutionEventSink, addinEventSink);

                addinEventSink.OnStartup(applicationObject);

                if (Context.ApplicationObject.Solution.IsOpen)
                {
                    solutionEventSink.OnOpenSolution();
                }
            }
        }
        /// <summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
        //public Connect()
        //{
        //}
        /// <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 = (DTE2) application;
            addInInstance = (AddIn) addInInst;

            // Only execute the startup code if the connection mode is a startup mode
            //if( connectMode == ext_ConnectMode.ext_cm_UISetup ) {
            if (connectMode == ext_ConnectMode.ext_cm_AfterStartup) {
                //Initializing Context
                Context.ApplicationObject = applicationObject;
                Context.AddInInstance = addInInstance;

                //Initializing EventSinks
                SolutionEventSink solutionEventSink = new SolutionEventSink();
                addinEventSink = new AddinEventSink();

                //Initializing Controller
                controller = new UIController();
                controller.Sinks.Add(solutionEventSink);
                controller.Sinks.Add(addinEventSink);
                controller.Init(solutionEventSink, addinEventSink);

                addinEventSink.OnStartup(applicationObject);

                if (Context.ApplicationObject.Solution.IsOpen){
                    solutionEventSink.OnOpenSolution();
                }
            }
        }