Exemplo n.º 1
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await InitComponentsAsync();

            OleMenuCommandService commandService = await base.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            MainPanelCommand.Initialize(this, commandService);
            await base.InitializeAsync(cancellationToken, progress);

            // Switch to main thread for dealing with type IVsSolution.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solution = base.GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solution != null)
            {
                _solutionEventsHandler = new SolutionEventsHandler();
                _solution.AdviseSolutionEvents(_solutionEventsHandler, out _solutionEventsCookie);
            }
            // To trigger upon loading a solution
            object      objLoadMgr = this; //the class that implements IVsSolutionManager
            IVsSolution pSolution  = GetService(typeof(SVsSolution)) as IVsSolution;

            object existingLoadManager = null;

            pSolution.GetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, out existingLoadManager);
            pSolution.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, objLoadMgr);
        }
Exemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            if (_solutionEventsCookie != 0)
            {
                _solution.UnadviseSolutionEvents(_solutionEventsCookie);
                _solutionEventsCookie = 0;
            }
            _solutionEventsHandler = null;

            base.Dispose(disposing);
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            InitComponents();
            MainPanelCommand.Initialize(this);
            base.Initialize();
            _solution = base.GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solution != null)
            {
                _solutionEventsHandler = new SolutionEventsHandler();
                _solution.AdviseSolutionEvents(_solutionEventsHandler, out _solutionEventsCookie);
            }
            // To trigger upon loading a solution
            object      objLoadMgr = this; //the class that implements IVsSolutionManager
            IVsSolution pSolution  = GetService(typeof(SVsSolution)) as IVsSolution;

            object existingLoadManager = null;

            pSolution.GetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, out existingLoadManager);
            pSolution.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, objLoadMgr);
        }