Пример #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);
        }
        /// <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);
        }
 /// <summary>
 /// Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 /// <param name="commandService">Menu command service to add menu-command.</param>
 public static void Initialize(Package package, OleMenuCommandService commandService)
 {
     Instance = new MainPanelCommand(package, commandService);
 }
Пример #4
0
 /// <summary>
 /// Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 public static void Initialize(Package package)
 {
     Instance = new MainPanelCommand(package);
 }