protected override void Initialize()
        {
            base.Initialize();
            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            Instance = this;

            var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));

            VsWorkspace = componentModel.GetService <VisualStudioWorkspace>();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != menuCommandService)
            {
                new Menus.Cleanup.ActionCustomCodeCleanup(menuCommandService).SetupCommands();
            }

            // Hook up event handlers
            events    = App.DTE.Events;
            docEvents = events.DocumentEvents;
            solEvents = events.SolutionEvents;
            docEvents.DocumentSaved += DocumentEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };
        }
        public SolutionWatcher()
        {
            if (Common.Instance.Solution != null)
            {
                Common.Instance.Solution.AdviseSolutionEvents(this, out mSolutionCookie);
            }

            mFileHistory.MaxHistory = Common.Instance.Settings.MaxFileHistory;

            mWindowEvents = Common.Instance.DTE2.Events.WindowEvents;
            mWindowEvents.WindowActivated += OnWindowActivated;
            mWindowEvents.WindowCreated += OnWindowCreated;

            mDocumentEvents = Common.Instance.DTE2.Events.DocumentEvents;
            mDocumentEvents.DocumentOpening += OnDocumentOpening;
            mDocumentEvents.DocumentOpened += OnDocumentOpened;
            mDocumentEvents.DocumentSaved += OnDocumentSaved;

            mSolutionItemsEvents = Common.Instance.DTE2.Events.SolutionItemsEvents;
            mSolutionItemsEvents.ItemAdded += OnItemAdded;
            mSolutionItemsEvents.ItemRemoved += OnItemRemoved;
            mSolutionItemsEvents.ItemRenamed += OnItemRenamed;

            RefreshOpenHistory();

            OnFilesChanged += RefreshSymbolDatabase;
        }
Beispiel #3
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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            EnvDTE80.DTE2 dte2 = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;

            Microsoft.Assumes.Present(dte2);

            _events = dte2.Events.SolutionEvents;
            _events.AfterClosing += delegate { DirectivesCache.Clear(); };

            _dte = await GetServiceAsync(typeof(SDTE)) as EnvDTE.DTE;

            Microsoft.Assumes.Present(_dte);
            _dteEvents      = _dte.Events;
            _documentEvents = _dteEvents.DocumentEvents;
            _documentEvents.DocumentSaved += OnDocumentSaved;

            IVsSolution solution = await GetServiceAsync(typeof(IVsSolution)) as IVsSolution;

            _projects = GetProjects(solution);

            await ParseVueTemplate.InitializeAsync(this);
        }
Beispiel #4
0
        public SolutionWatcher()
        {
            if (Common.Instance.Solution != null)
            {
                Common.Instance.Solution.AdviseSolutionEvents(this, out mSolutionCookie);
            }

            mFileHistory.MaxHistory = Common.Instance.Settings.MaxFileHistory;

            mWindowEvents = Common.Instance.DTE2.Events.WindowEvents;
            mWindowEvents.WindowActivated += OnWindowActivated;
            mWindowEvents.WindowCreated   += OnWindowCreated;

            mDocumentEvents = Common.Instance.DTE2.Events.DocumentEvents;
            mDocumentEvents.DocumentOpening += OnDocumentOpening;
            mDocumentEvents.DocumentOpened  += OnDocumentOpened;
            mDocumentEvents.DocumentSaved   += OnDocumentSaved;

            mSolutionItemsEvents              = Common.Instance.DTE2.Events.SolutionItemsEvents;
            mSolutionItemsEvents.ItemAdded   += OnItemAdded;
            mSolutionItemsEvents.ItemRemoved += OnItemRemoved;
            mSolutionItemsEvents.ItemRenamed += OnItemRenamed;

            RefreshOpenHistory();

            OnFilesChanged += RefreshSymbolDatabase;
        }
Beispiel #5
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await base.InitializeAsync(cancellationToken, progress);

            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            Instance = this;

            var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel));

            VsWorkspace = componentModel.GetService <VisualStudioWorkspace>();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != menuCommandService)
            {
                new ActionCustomCodeCleanup(menuCommandService).SetupCommands();
            }

            // Hook up event handlers
            events    = App.DTE.Events;
            docEvents = events.DocumentEvents;
            solEvents = events.SolutionEvents;
            docEvents.DocumentSaved += DocumentEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };
        }
Beispiel #6
0
        public void populateDefaultVSComObjects()
        {
            VisualStudio_2010.Package           = this;
            VisualStudio_2010.ErrorListProvider = new ErrorListProvider(this);
            VisualStudio_2010.IVsUIShell        = this.getService <IVsUIShell>();
            VisualStudio_2010.DTE2 = this.getService <EnvDTE.DTE, EnvDTE80.DTE2>();
            VisualStudio_2010.OleMenuCommandService = this.getService <OleMenuCommandService>();

            Events = VisualStudio_2010.DTE2.Events;

            BuildEvents         = Events.BuildEvents;
            CommandEvents       = Events.CommandEvents;
            DebuggerEvents      = Events.DebuggerEvents;
            DocumentEvents      = Events.DocumentEvents;
            DTEEvents           = Events.DTEEvents;
            FindEvents          = Events.FindEvents;
            MiscFilesEvents     = Events.MiscFilesEvents;
            OutputWindowEvents  = Events.OutputWindowEvents;
            SelectionEvents     = Events.SelectionEvents;
            SolutionEvents      = Events.SolutionEvents;
            SolutionItemsEvents = Events.SolutionItemsEvents;
            TaskListEvents      = Events.TaskListEvents;
            TextEditorEvents    = Events.TextEditorEvents;
            WindowEvents        = Events.WindowEvents;



            BuildEvents.OnBuildBegin += (scope, action) => VisualStudio_2010.On_BuildBegin.invoke();
            BuildEvents.OnBuildDone  += (scope, action) => VisualStudio_2010.On_BuildDone.invoke();

            BuildEvents.OnBuildProjConfigDone +=
                (Project, ProjectConfig, Platform, SolutionConfig, Success) =>
            {
                //@"On OnBuildProjConfigDone: project: {0} , ProjectConfig: {1} , Platform: {2},  SolutionConfig: {3} , Success: {4}".debug(Project,ProjectConfig, Platform, SolutionConfig,Success);
                if (Success)
                {
                    VisualStudio_2010.On_ProjectBuild_OK.invoke(Project);
                }
                else
                {
                    VisualStudio_2010.On_ProjectBuild_Failed.invoke(Project);
                }
            };

            SolutionEvents.Opened += () => VisualStudio_2010.On_SolutionOpened.invoke();

            DocumentEvents.DocumentOpened  += (document) => VisualStudio_2010.on_DocumentOpened.invoke(document);
            DocumentEvents.DocumentClosing += (document) => VisualStudio_2010.on_DocumentClosing.invoke(document);
            DocumentEvents.DocumentSaved   += (document) => VisualStudio_2010.on_DocumentSaved.invoke(document);
            DocumentEvents.DocumentOpening += (documentPath, readOnly) => VisualStudio_2010.on_DocumentOpening.invoke(documentPath, readOnly);
            TextEditorEvents.LineChanged   += (startPoint, endPoint, hInt) => VisualStudio_2010.on_LineChanged.invoke(startPoint, endPoint);

            WindowEvents.WindowActivated += (windowGotFocus, windowLostFocus) => {
                if (windowGotFocus.Document.notNull())
                {
                    VisualStudio_2010.on_ActiveDocumentChange.invoke(windowGotFocus.Document);
                }
            };
        }
        private void ConnectEvents()
        {
            var events = (EnvDTE80.Events2)Dte.Events;

            _documentEvents = events.DocumentEvents;
            _documentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
            _documentEvents.DocumentSaved  += DocumentEvents_DocumentSaved;
        }
Beispiel #8
0
        private void AsmViewerControl_Loaded(object sender, RoutedEventArgs e)
        {
            // Configure save event
            dteEvents           = serviceProvider.GetDTE().Events;
            dteDocEvents        = dteEvents.DocumentEvents;
            dteTextEditorEvents = dteEvents.TextEditorEvents;
            dteSelectionEvents  = dteEvents.SelectionEvents;

            dteDocEvents.DocumentSaved += DocumentEvents_DocumentSaved;
        }
Beispiel #9
0
        private void ConnectEvents()
        {
            var events = (EnvDTE80.Events2)Dte.Events;

            _solutionEvents               = events.SolutionEvents;
            _solutionEvents.Opened       += SolutionEvents_Opened;
            _solutionEvents.AfterClosing += SolutionEvents_AfterClosing;

            _documentEvents = events.DocumentEvents;
            _documentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
            _documentEvents.DocumentSaved  += DocumentEvents_DocumentSaved;
        }
Beispiel #10
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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            Log.Initialize();
            ProbeEnvironment.Initialize();
            TempManager.Init(TempDir);
            Snippets.SnippetDeploy.DeploySnippets();
            CodeModel.SignatureDocumentor.Initialize();

            ThreadHelper.ThrowIfNotOnUIThread();

            // Proffer the service.	http://msdn.microsoft.com/en-us/library/bb166498.aspx
            var langService = new ProbeLanguageService(this);

            langService.SetSite(this);
            (this as IServiceContainer).AddService(typeof(ProbeLanguageService), langService, true);

            // Register a timer to call our language service during idle periods.
            var mgr = GetService(typeof(SOleComponentManager)) as IOleComponentManager;

            if (_componentId == 0 && mgr != null)
            {
                OLECRINFO[] crinfo = new OLECRINFO[1];
                crinfo[0].cbSize            = (uint)Marshal.SizeOf(typeof(OLECRINFO));
                crinfo[0].grfcrf            = (uint)_OLECRF.olecrfNeedIdleTime | (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
                crinfo[0].grfcadvf          = (uint)_OLECADVF.olecadvfModal | (uint)_OLECADVF.olecadvfRedrawOff | (uint)_OLECADVF.olecadvfWarningsOff;
                crinfo[0].uIdleTimeInterval = 1000;
                int hr = mgr.FRegisterComponent(this, crinfo, out _componentId);
            }

            _errorTaskProvider = new ErrorTagging.ErrorTaskProvider(this);
            TaskListService.RegisterTaskProvider(_errorTaskProvider, out _errorTaskProviderCookie);

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (mcs != null)
            {
                Commands.InitCommands(mcs);
            }

            _functionScanner = new FunctionFileScanning.FFScanner();

            // Need to keep a reference to Events and DocumentEvents in order for DocumentSaved to be triggered.
            _dteEvents = Shell.DTE.Events;

            _dteDocumentEvents = _dteEvents.DocumentEvents;
            _dteDocumentEvents.DocumentSaved += DocumentEvents_DocumentSaved;

            Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;
        }
            protected override bool TryInitialize()
            {
                ThreadHelper.ThrowIfNotOnUIThread();
                var dte = AcuminatorVSPackage.Instance.GetService <EnvDTE.DTE>();

                //Store reference to DTE SolutionEvents and WindowEvents to prevent them from being GC-ed
                if (dte?.Events != null)
                {
                    _solutionEvents   = dte.Events.SolutionEvents;
                    _windowEvents     = dte.Events.WindowEvents;
                    _documentEvents   = dte.Events.DocumentEvents;
                    _visibilityEvents = (dte.Events as EnvDTE80.Events2)?.WindowVisibilityEvents;
                }
                else
                {
                    return(false);
                }

                return(_solutionEvents != null && _windowEvents != null && _documentEvents != null && _visibilityEvents != null);
            }
Beispiel #12
0
        private void SubscripeToEvents()
        {
            var events = MasterObjekt.Events;

            buildEvents    = events.BuildEvents;
            commandEvents  = events.CommandEvents;
            documentEvents = events.DocumentEvents;
            solutionEvents = events.SolutionEvents;

            buildEvents.OnBuildBegin      += new EnvDTE._dispBuildEvents_OnBuildBeginEventHandler(BuildEvents_OnBuildBegin);
            buildEvents.OnBuildDone       += new EnvDTE._dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
            commandEvents.AfterExecute    += new EnvDTE._dispCommandEvents_AfterExecuteEventHandler(CommandEvents_AfterExecute);
            documentEvents.DocumentSaved  += new EnvDTE._dispDocumentEvents_DocumentSavedEventHandler(DocumentEvents_DocumentSaved);
            solutionEvents.Opened         += new EnvDTE._dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
            solutionEvents.ProjectAdded   += new EnvDTE._dispSolutionEvents_ProjectAddedEventHandler(SolutionEvents_ProjectAdded);
            solutionEvents.ProjectRemoved += new EnvDTE._dispSolutionEvents_ProjectRemovedEventHandler(SolutionEvents_ProjectRemoved);
            solutionEvents.ProjectRenamed += new EnvDTE._dispSolutionEvents_ProjectRenamedEventHandler(SolutionEvents_ProjectRenamed);
            solutionEvents.Renamed        += new EnvDTE._dispSolutionEvents_RenamedEventHandler(SolutionEvents_Renamed);
            solutionEvents.AfterClosing   += new EnvDTE._dispSolutionEvents_AfterClosingEventHandler(SolutionEvents_AfterClosing);
        }
Beispiel #13
0
        private void ConnectEvents()
        {
            var events = (EnvDTE80.Events2)Dte.Events;

            _solutionEvents               = events.SolutionEvents;
            _solutionEvents.Opened       += Solution_Opened;
            _solutionEvents.AfterClosing += Solution_AfterClosing;

            _solutionEvents.ProjectAdded   += Solution_ContentChanged;
            _solutionEvents.ProjectRemoved += Solution_ContentChanged;
            _solutionEvents.ProjectRenamed += (item, newName) => Solution_ContentChanged(item);

            _projectItemsEvents              = events.ProjectItemsEvents;
            _projectItemsEvents.ItemAdded   += Solution_ContentChanged;
            _projectItemsEvents.ItemRemoved += Solution_ContentChanged;
            _projectItemsEvents.ItemRenamed += (item, newName) => Solution_ContentChanged(item);

            _solutionItemsEvents              = events.SolutionItemsEvents;
            _solutionItemsEvents.ItemAdded   += Solution_ContentChanged;
            _solutionItemsEvents.ItemRemoved += Solution_ContentChanged;
            _solutionItemsEvents.ItemRenamed += (item, newName) => Solution_ContentChanged(item);

            _miscFilesEvents              = events.MiscFilesEvents;
            _miscFilesEvents.ItemAdded   += Solution_ContentChanged;
            _miscFilesEvents.ItemRemoved += Solution_ContentChanged;
            _miscFilesEvents.ItemRenamed += (item, newName) => Solution_ContentChanged(item);

            _projectsEvents              = events.ProjectsEvents;
            _projectsEvents.ItemAdded   += Solution_ContentChanged;
            _projectsEvents.ItemRemoved += Solution_ContentChanged;
            _projectsEvents.ItemRenamed += (item, newName) => Solution_ContentChanged(item);

            _documentEvents = events.DocumentEvents;
            _documentEvents.DocumentOpened += DocumentEvents_DocumentOpened;
            _documentEvents.DocumentSaved  += DocumentEvents_DocumentSaved;

            if (Dte.Solution != null)
            {
                Solution_Opened();
            }
        }
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            await base.InitializeAsync(cancellationToken, progress);

            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);


            Instance = this;

            var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel));

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            var cmdidWebFileToggleId = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, 0x101);
            var cmdidAttacherId      = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidAttacher);

            var otherMenu = menuCommandService.FindCommand(cmdidWebFileToggleId);

            if (otherMenu != null)
            {
            }

            if (null != menuCommandService)
            {
                var menuCommand = new OleMenuCommand(CallAttacher, cmdidAttacherId);
                menuCommand.BeforeQueryStatus += MenuCommand_BeforeQueryStatus;
                menuCommandService.AddCommand(menuCommand);
            }

            SetCommandBindings();

            // Hook up event handlers
            events    = App.DTE.Events;
            docEvents = events.DocumentEvents;
            solEvents = events.SolutionEvents;
            docEvents.DocumentSaved += DocumentEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };
        }
Beispiel #15
0
        protected override void Initialize()
        {
            base.Initialize();
            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            Instance = this;

            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != menuCommandService)
            {
                // var mainMenu = new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet, (int)PkgCmdIDList.CmdidMainMenu);
                // var founded = menuCommandService.FindCommand(mainMenu);
                // if (founded == null)
                // {
                //    var menuCommand2 = new OleMenuCommand(null, mainMenu);
                //    menuCommandService.AddCommand(menuCommand2);
                //    menuCommand2.BeforeQueryStatus += MenuCommand2_BeforeQueryStatus;
                // }
                // Set up menu items

                new Menus.Typescript(menuCommandService).SetupCommands();
                new Menus.RunBatchFiles(menuCommandService).SetupCommands();

                new Menus.OpenRelatedFileF7(menuCommandService).SetupCommands();
            }

            // Hook up event handlers
            events    = App.DTE.Events;
            docEvents = events.DocumentEvents;
            solEvents = events.SolutionEvents;
            docEvents.DocumentSaved += DocumentEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };
        }
Beispiel #16
0
        protected override async Task InitializeAsync
        (
            CancellationToken Token,
            IProgress <ServiceProgressData> Progress
        )
        {
            await base.InitializeAsync(Token, Progress);

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(Token);

            #region Events
            #region RunningDocumentTable

            var Table = new RunningDocumentTable(this);
            Table.Advise(new RunningDocTableEvents());

            #endregion
            #region EnvDTE.Events

            var DTE = await Utils.GetDTEAsync();

            Events = DTE.Events;

            DocumentEvents = Events.DocumentEvents;
            DocumentEvents.DocumentClosing += Document =>
            {
                _ = Task.Run(async() =>
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    if (Document.Language != "C/C++")
                    {
                        return;
                    }

                    await TaskScheduler.Default;
                    await File.Structure.Events.OnBeforeDocumentCloseAsync();
                }, Token);
            };

            WindowEvents = Events.WindowEvents;
            WindowEvents.WindowActivated += (GotFocus, LostFocus) =>
            {
                if (GotFocus == LastWindowThatGotFocus)
                {
                    return;
                }
                _ = Task.Run(async() =>
                {
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    if (GotFocus.Document == null)
                    {
                        return;
                    }
                    if (GotFocus.Document.Language != "C/C++")
                    {
                        return;
                    }

                    await TaskScheduler.Default;
                    LastWindowThatGotFocus = GotFocus;
                    await File.Structure.Events.OnAfterWindowActivateAsync();
                }, Token);
            };

            #endregion

            await WindowCommand.InitializeAsync(this);

            #endregion
        }
 public void AddEvents()
 {
     _events = (EnvDTE80.Events2)dte.Events;
     _events.SolutionItemsEvents.ItemAdded += new EnvDTE._dispProjectItemsEvents_ItemAddedEventHandler(_events_ItemAdded);
     _docEvents = (EnvDTE.DocumentEvents)_events.get_DocumentEvents(null);
     _docEvents.DocumentSaved += new EnvDTE._dispDocumentEvents_DocumentSavedEventHandler(_docEvents_DocumentSaved);
     _slnEvents = (EnvDTE.SolutionEvents)_events.SolutionEvents;
     _slnEvents.Opened += new EnvDTE._dispSolutionEvents_OpenedEventHandler(_slnEvents_SolutionOpened);
     _slnEvents.ProjectAdded += new EnvDTE._dispSolutionEvents_ProjectAddedEventHandler(_slnEvents_ProjectAdded);
     _slnEvents.ProjectRemoved += new EnvDTE._dispSolutionEvents_ProjectRemovedEventHandler(_slnEvents_ProjectRemoved);
     _slnEvents.BeforeClosing += new EnvDTE._dispSolutionEvents_BeforeClosingEventHandler(_slnEvents_BeforeClosing);
 }
        protected override void Initialize()
        {
            base.Initialize();
            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            Instance = this;

            var componentModel = (IComponentModel)this.GetService(typeof(SComponentModel));

            VsWorkspace = componentModel.GetService <VisualStudioWorkspace>();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != menuCommandService)
            {
                menuCommandService.AddCommand(new MenuCommand(CallAttacher,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidAttacher)));

                menuCommandService.AddCommand(new MenuCommand(CallWebFileToggle,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidWebFileToggle)));

                menuCommandService.AddCommand(new MenuCommand(CallFixtureFileToggle,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidFixtureFileToggle)));

                menuCommandService.AddCommand(new MenuCommand(CallFileFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidFileFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallMemberFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidMemberFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallCssFinder,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidCSSFinder)));

                menuCommandService.AddCommand(new MenuCommand(CallGotoNextFoundItem,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidGotoNextFoundItem)));

                menuCommandService.AddCommand(new MenuCommand(CallGotoPreviousFoundItem,
                                                              new CommandID(GuidList.GuidGeeksProductivityToolsCmdSet,
                                                                            (int)PkgCmdIDList.CmdidGotoPreviousFoundItem)));

                // Set up menu items
                new Menus.OpenInMSharp.OpenInMSharpCodeWindow(menuCommandService).SetupCommands();
                new Menus.OpenInMSharp.OpenInMSharpSolutionExplorer(menuCommandService).SetupCommands();

                new Menus.Typescript(menuCommandService).SetupCommands();
                new Menus.RunBatchFiles(menuCommandService).SetupCommands();

                new Menus.Cleanup.ActionCustomCodeCleanup(menuCommandService).SetupCommands();
            }

            SetCommandBindings();

            // Hook up event handlers
            events    = App.DTE.Events;
            docEvents = events.DocumentEvents;
            solEvents = events.SolutionEvents;
            docEvents.DocumentSaved += DocumentEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };
        }
        private void SubscripeToEvents()
        {
            var events = GetDTE2().Events;
            buildEvents = events.BuildEvents;
            commandEvents = events.CommandEvents;
            documentEvents = events.DocumentEvents;
            solutionEvents = events.SolutionEvents;

            buildEvents.OnBuildDone += new EnvDTE._dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);
            commandEvents.AfterExecute += new EnvDTE._dispCommandEvents_AfterExecuteEventHandler(CommandEvents_AfterExecute);
            documentEvents.DocumentSaved += new EnvDTE._dispDocumentEvents_DocumentSavedEventHandler(DocumentEvents_DocumentSaved);
            solutionEvents.Opened += new EnvDTE._dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);
            solutionEvents.ProjectAdded += new EnvDTE._dispSolutionEvents_ProjectAddedEventHandler(SolutionEvents_ProjectAdded);
            solutionEvents.ProjectRemoved += new EnvDTE._dispSolutionEvents_ProjectRemovedEventHandler(SolutionEvents_ProjectRemoved);
            solutionEvents.ProjectRenamed += new EnvDTE._dispSolutionEvents_ProjectRenamedEventHandler(SolutionEvents_ProjectRenamed);
            solutionEvents.Renamed += new EnvDTE._dispSolutionEvents_RenamedEventHandler(SolutionEvents_Renamed);
            solutionEvents.AfterClosing += new EnvDTE._dispSolutionEvents_AfterClosingEventHandler(SolutionEvents_AfterClosing);
        }
Beispiel #20
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, false))
                await tidyLogWriter.WriteLineAsync("Initialization has begun...");


            await base.InitializeAsync(cancellationToken, progress);

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
                await tidyLogWriter.WriteLineAsync("Base has initialized");


            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
                await tidyLogWriter.WriteLineAsync("Switched to main thread");


            App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage);

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
                await tidyLogWriter.WriteLineAsync("App initialized");


            Instance = this;

            var componentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true);

            if (componentModel != null)
            {
                VsWorkspace = componentModel.GetService <VisualStudioWorkspace>();
            }

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
            {
                if (componentModel == null)
                {
                    await tidyLogWriter.WriteLineAsync("component Model is null");
                }
                else
                {
                    await tidyLogWriter.WriteLineAsync("component has value");
                }
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var menuCommandService = await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true) as OleMenuCommandService;

            if (null != menuCommandService)
            {
                new ActionCustomCodeCleanup(menuCommandService).SetupCommands();
            }

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
            {
                if (menuCommandService == null)
                {
                    await tidyLogWriter.WriteLineAsync("menu Command Service  is null");
                }
                else
                {
                    await tidyLogWriter.WriteLineAsync("menu Command Service has value");
                }
            }

            // Hook up event handlers
            events     = App.Dte.Events;
            buildEvent = events.BuildEvents;
            docEvents  = events.DocumentEvents;
            solEvents  = events.SolutionEvents;
            buildEvent.OnBuildBegin += BuildEvent_OnBuildBegin;
            docEvents.DocumentSaved += DocEvents_DocumentSaved;
            solEvents.Opened        += delegate { App.Initialize(GetDialogPage(typeof(OptionsPage)) as OptionsPage); };

            using (var tidyLogWriter = new StreamWriter(TidyProcesLogsPath, true))
                await tidyLogWriter.WriteLineAsync("Initialization has finished...");
        }