Пример #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 void Initialize()
        {
            base.Initialize();

            AppDomain.CurrentDomain.UnhandledException += (sender, e) => Helpers.LogException(e.ExceptionObject as Exception);

            solutionService = (IVsSolution)GetService(typeof(SVsSolution));
            solutionService.AdviseSolutionEvents(this, out var cookie);

            var tpdService = (IVsTrackProjectDocuments2)GetService(typeof(SVsTrackProjectDocuments));

            tpdService.AdviseTrackProjectDocumentsEvents(this, out var tpdCookie);

            UiShell = (IVsUIShell)GetService(typeof(SVsUIShell));

            InitializeOptionsStorage();

            runningDocumentTable = GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            runningDocumentTable.AdviseRunningDocTableEvents(this, out var rdtCookie);

            shellOpenDocument = GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            InitializeMenu();
            InitializeCommands();

            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            var editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();
            var textManager = (IVsTextManager)GetService(typeof(SVsTextManager));

            BookmarksManager.InitializeAfterPackageInitialization(editorAdaptersFactoryService, textManager);
        }
        static VLDocumentViewsManager()
        {
            IVsRunningDocumentTable IVsRunningDocumentTable = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));

            DTE = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(EnvDTE.DTE));
            if (IVsRunningDocumentTable == null || DTE == null)
            {
                throw new InvalidOperationException("Cannot consume VLDocumentViewsManager services.");
            }

            lockedDocuments        = new HashSet <string>();
            lockedDocumentsWaiting = new HashSet <string>();
            invisibleWindows       = new Dictionary <string, object>();

            uint evCookie;
            // register file open and close events
            RDTEvents rdtEvents = new RDTEvents();

            rdtEvents.FileOpened += new Action <string>(RdtEvents_FileOpened);
            rdtEvents.FileClosed += new Action <string>(RdtEvents_FileClosed);
            rdtEvents.FileClosed += new Action <string>(NotifyFileClosed);

            int hr = IVsRunningDocumentTable.AdviseRunningDocTableEvents(rdtEvents, out evCookie);

            Marshal.ThrowExceptionForHR(hr);
        }
Пример #3
0
        public DocumentEventHandlers(IVsRunningDocumentTable vsrdt)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            this.rdt = vsrdt;

            rdt.AdviseRunningDocTableEvents(this, out uint _);
        }
Пример #4
0
        public VisualStudioEditorDocumentManager(
            ProjectSnapshotManagerDispatcher projectSnapshotManagerDispatcher,
            JoinableTaskContext joinableTaskContext,
            FileChangeTrackerFactory fileChangeTrackerFactory,
            IVsRunningDocumentTable runningDocumentTable,
            IVsEditorAdaptersFactoryService editorAdaptersFactory)
            : base(projectSnapshotManagerDispatcher, joinableTaskContext, fileChangeTrackerFactory)
        {
            if (runningDocumentTable is null)
            {
                throw new ArgumentNullException(nameof(runningDocumentTable));
            }

            if (editorAdaptersFactory is null)
            {
                throw new ArgumentNullException(nameof(editorAdaptersFactory));
            }

            if (fileChangeTrackerFactory is null)
            {
                throw new ArgumentNullException(nameof(fileChangeTrackerFactory));
            }

            _runningDocumentTable  = (IVsRunningDocumentTable4)runningDocumentTable;
            _editorAdaptersFactory = editorAdaptersFactory;

            var hr = runningDocumentTable.AdviseRunningDocTableEvents(new RunningDocumentTableEventSink(this), out _);

            Marshal.ThrowExceptionForHR(hr);

            _documentsByCookie = new Dictionary <uint, List <DocumentKey> >();
            _cookiesByDocument = new Dictionary <DocumentKey, uint>();
        }
Пример #5
0
        internal VsVimHost(
            IVsAdapter adapter,
            ITextBufferFactoryService textBufferFactoryService,
            ITextEditorFactoryService textEditorFactoryService,
            ITextDocumentFactoryService textDocumentFactoryService,
            ITextBufferUndoManagerProvider undoManagerProvider,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IEditorOperationsFactoryService editorOperationsFactoryService,
            ISmartIndentationService smartIndentationService,
            ITextManager textManager,
            ISharedServiceFactory sharedServiceFactory,
            IVimApplicationSettings vimApplicationSettings,
            IExtensionAdapterBroker extensionAdapterBroker,
            SVsServiceProvider serviceProvider,
            ITelemetryProvider telemetryProvider)
            : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService)
        {
            _vsAdapter = adapter;
            _editorAdaptersFactoryService = editorAdaptersFactoryService;
            _dte                     = (_DTE)serviceProvider.GetService(typeof(_DTE));
            _vsExtensibility         = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility));
            _textManager             = textManager;
            _sharedService           = sharedServiceFactory.Create();
            _vsMonitorSelection      = serviceProvider.GetService <SVsShellMonitorSelection, IVsMonitorSelection>();
            _vimApplicationSettings  = vimApplicationSettings;
            _smartIndentationService = smartIndentationService;
            _extensionAdapterBroker  = extensionAdapterBroker;
            _runningDocumentTable    = serviceProvider.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();

            _vsMonitorSelection.AdviseSelectionEvents(this, out uint selectionCookie);
            _runningDocumentTable.AdviseRunningDocTableEvents(this, out uint runningDocumentTableCookie);

            InitTelemetry(telemetryProvider.GetOrCreate(vimApplicationSettings, _dte), vimApplicationSettings);
        }
Пример #6
0
        protected override void Initialize()
        {
            base.Initialize();

            //绑定textView事件
            IVsMonitorSelection monitorSelection = (IVsMonitorSelection)GetService(typeof(SVsShellMonitorSelection));

            ErrorHandler.ThrowOnFailure(monitorSelection.AdviseSelectionEvents(textViewEvent, out selectionEventCookie));

            //绑定RunningDocTable事件
            IVsRunningDocumentTable DocTables = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            DocTables.AdviseRunningDocTableEvents(docTableEvent, out runningDocEventCookie);

            // And we can query for the text manager service as we're surely running in
            // interactive mode. So this is the right time to register for text manager events.
            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
            tmConnectionPoint.Advise(TextManagerEventSink, out tmConnectionCookie);

            //todo:通过win32形式检测键盘输入
            hookVs.InitHook();
        }
Пример #7
0
        void Hook(bool enable)
        {
            if (enable == _hooked)
            {
                return;
            }

            IVsRunningDocumentTable rdt = RunningDocumentTable;

            if (rdt == null)
            {
                return;
            }

            if (enable)
            {
                if (VSErr.Succeeded(rdt.AdviseRunningDocTableEvents(this, out _cookie)))
                {
                    _hooked = true;
                }
            }
            else
            {
                _docMap.Clear();
                _cookieMap.Clear();

                _hooked = false;
                rdt.UnadviseRunningDocTableEvents(_cookie);
            }
        }
        public DocumentWatcher(HandlerSet handlerSet, IServiceProvider serviceProvider)
        {
            hs = handlerSet;
            dt = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(SVsRunningDocumentTable));

            dt.AdviseRunningDocTableEvents(this, out rdtCookie);
        }
Пример #9
0
        protected override void Initialize()
        {
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)
                                          this.GetService(typeof(SVsRunningDocumentTable));

            rdt.AdviseRunningDocTableEvents(this, out rdtCookie);
        }
 private void InitializeRunningDocumentTable()
 {
     if (RunningDocumentTable != null)
     {
         RunningDocumentTable.AdviseRunningDocTableEvents(this, out runningDocumentTableCookie);
     }
 }
        internal void Register()
        {
            // Register this object to listen for IVsUpdateSolutionEvents
            IVsSolutionBuildManager2 buildManager = Package.GetService <SVsSolutionBuildManager, IVsSolutionBuildManager2>();

            if (buildManager == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            buildManager.AdviseUpdateSolutionEvents(this, out m_updateSolutionEventsCookie);

            // Register this object to listen for IVsSolutionEvents
            IVsSolution solution = Package.GetService <SVsSolution, IVsSolution>();

            if (solution == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            solution.AdviseSolutionEvents(this, out m_solutionEventsCookie);

            // Register this object to listen for IVsRunningDocTableEvents
            _runningDocTable = Package.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();
            if (_runningDocTable == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            _runningDocTable.AdviseRunningDocTableEvents(this, out m_runningDocTableEventsCookie);
        }
Пример #12
0
        public void Advise()
        {
            Shell.ThreadHelper.ThrowIfNotOnUIThread();
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));

            rdt.AdviseRunningDocTableEvents(this, out _cookie);
        }
Пример #13
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()
        {
            ToolStripManager.Renderer = new VisualStudioLikeToolStripRenderer();

            // Add the Text Marker Service to the service container. The container will care
            // about all the rest (proffer the service, revoke it, and so on).
            CloneMarkerTypeProvider markerTypeProvider = new CloneMarkerTypeProvider();

            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            base.Initialize();

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

            if (null != mcs)
            {
                // Create the commands for the tool windows.
                CommandID   cloneExplorerCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneExplorer);
                MenuCommand cloneExplorerMenuItem  = new MenuCommand(ShowCloneExplorer, cloneExplorerCommandID);
                mcs.AddCommand(cloneExplorerMenuItem);

                CommandID   cloneIntersectionsCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneIntersections);
                MenuCommand cloneIntersectionsMenuItem  = new MenuCommand(ShowCloneIntersections, cloneIntersectionsCommandID);
                mcs.AddCommand(cloneIntersectionsMenuItem);

                CommandID   cloneResultsCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneResults);
                MenuCommand cloneResultsMenuItem  = new MenuCommand(ShowCloneResults, cloneResultsCommandID);
                mcs.AddCommand(cloneResultsMenuItem);
            }

            // Advise event sinks. We need to know when a solution is opened and closed
            // (SolutionEventSink), when a document is opened and closed (TextManagerEventSink),
            // and when a document is saved (RunningDocTableEventSink).
            //
            // However unfortunately we can't advise the text manager event sink here due to a very
            // strange constellation: On Windows XP running "devenv /setup" usually works fine but
            // sometimes destruction of the text manager service crashes VS. The solution is to defer
            // event sink registration to the point in time when the first solution is loaded. This works
            // as solutions are only loaded in interactive mode and we don't have any work to do as long
            // as there is no active solution.
            SolutionEventSink        solutionEventSink        = new SolutionEventSink();
            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();

            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out _solutionEventCookie));

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out _rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();

            // Ensure settings are initialized correctly.
            InitializeUserSettings();
        }
        internal RunningDocumentTableEvents()
        {
            rdt = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));

            uint cookie;
            rdt.AdviseRunningDocTableEvents(this, out cookie);
            sinkCookie = cookie;
        }
Пример #15
0
        private uint rdtEventsCookie; // = 0

        private void InitializeRunningDocTableEvents()
        {
            rdt = Common.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            if (rdt != null)
            {
                rdt.AdviseRunningDocTableEvents(this, out rdtEventsCookie);
            }
        }
Пример #16
0
 public void StartSendingSaveEvents()
 {
     if (!_subscribed)
     {
         Marshal.ThrowExceptionForHR(_runningDocumentTable.AdviseRunningDocTableEvents(this, out var runningDocumentTableEventCookie));
         _subscribed = true;
     }
 }
Пример #17
0
 public VsDocumentEvents()
 {
     documentService = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if (documentService != null)
     {
         documentService.AdviseRunningDocTableEvents(this, out cookie);
     }
 }
        private async Task InitializeRunningDocumentTableAsync()
        {
            Debug.WriteLine("InitializeRunningDocumentTableAsync started.");
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _runningDocumentTable?.AdviseRunningDocTableEvents(this, out _runningDocumentTableCookie);
            Debug.WriteLine("InitializeRunningDocumentTableAsync finished.");
        }
Пример #19
0
 private void AdviseRunningDocumentTableEvents()
 {
     runningDocumentTable = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if (runningDocumentTable != null)
     {
         ErrorHandler.ThrowOnFailure(runningDocumentTable.AdviseRunningDocTableEvents(this, out runningDocumentTableCookie));
     }
 }
Пример #20
0
 private void AdviseRunningDocumentTableEvents()
 {
     runningDocumentTable = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if (runningDocumentTable != null)
     {
         ErrorHandler.ThrowOnFailure(runningDocumentTable.AdviseRunningDocTableEvents(this, out runningDocumentTableCookie));
     }
 }
Пример #21
0
 /// <summary>
 /// Register RunningDocumentTable events.
 /// </summary>
 public void RegisterRunningDocumentTableEvents()
 {
     DocumentTable = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
     if (DocumentTable != null)
     {
         int hr = DocumentTable.AdviseRunningDocTableEvents(this, out DocumentTableItemId);
         ErrorHandler.ThrowOnFailure(hr);
     }
 }
Пример #22
0
        public bool Register(EnvDTE.DTE dte)
        {
            table = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
            // Listen to show/hide events of docs to register activate/deactivate cursor listeners.
            table.AdviseRunningDocTableEvents(this, out m_rdtCookie);
            // In turn, cursor events will register a IVsTextViewEvents indexed by the IVsTextView.

            return(true);
        }
Пример #23
0
 /// <summary>
 /// Subscribe to the running document table events
 /// </summary>
 private void SubscribeToEvents()
 {
     DocumentTable = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if (DocumentTable != null)
     {
         int result = DocumentTable.AdviseRunningDocTableEvents(this, out DocumentTableItemId);
         ErrorHandler.ThrowOnFailure(result);
     }
 }
Пример #24
0
        private void InitializeRunningDocumentTable()
        {
            if (RunningDocumentTable != null)
            {
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
                RunningDocumentTable.AdviseRunningDocTableEvents(this, out runningDocumentTableCookie);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
            }
        }
Пример #25
0
        private void OnWorkspaceInitialized(object sender, PythonWorkspaceContextEventArgs e)
        {
            var workspace = e.Workspace;

            _infoBarCheckTriggered = false;

            _packageInstallInfoBar            = new PackageInstallWorkspaceInfoBar(_serviceProvider, workspace);
            _condaEnvCreateInfoBar            = new CondaEnvCreateWorkspaceInfoBar(_serviceProvider, workspace);
            _virtualEnvCreateInfoBar          = new VirtualEnvCreateWorkspaceInfoBar(_serviceProvider, workspace);
            _testFrameworkInfoBar             = new TestFrameworkWorkspaceInfoBar(_serviceProvider, workspace);
            _pythonVersionNotSupportedInfoBar = new PythonNotSupportedInfoBar(_serviceProvider, InfoBarContexts.Workspace, () => workspace.CurrentFactory);

            workspace.AddActionOnClose(_packageInstallInfoBar, (obj => ((PythonInfoBar)obj).Dispose()));
            workspace.AddActionOnClose(_condaEnvCreateInfoBar, (obj => ((PythonInfoBar)obj).Dispose()));
            workspace.AddActionOnClose(_virtualEnvCreateInfoBar, (obj => ((PythonInfoBar)obj).Dispose()));
            workspace.AddActionOnClose(_testFrameworkInfoBar, (obj => ((PythonInfoBar)obj).Dispose()));
            workspace.AddActionOnClose(
                _pythonVersionNotSupportedInfoBar,
                obj => { ((PythonInfoBar)obj).Dispose(); workspace.ActiveInterpreterChanged -= TriggerPythonNotSupportedInforBar; }
                );
            workspace.AddActionOnClose(
                _untrustedWorkspaceInfoBar,
                obj => { ((PythonInfoBar)obj).Dispose(); workspace.IsTrustedQueried -= TriggerUntrustedWorkspaceInfoBar; }
                );

            workspace.ActiveInterpreterChanged += TriggerPythonNotSupportedInforBar;

            // When we see a Python file opened in the workspace, we trigger info bar checks.
            // Python files may have already been opened by the time this runs, so we'll check
            // the already loaded files first. If there are no Python file that trigger info bar
            // checks, then we'll register to be notified when files are opened.
            if (ErrorHandler.Succeeded(_docTable.GetRunningDocumentsEnum(out var pEnumRdt)))
            {
                if (ErrorHandler.Succeeded(pEnumRdt.Reset()))
                {
                    uint[] cookie = new uint[1];
                    while (VSConstants.S_OK == pEnumRdt.Next(1, cookie, out _))
                    {
                        var docFilePath = GetDocumentFilePath(cookie[0]);
                        if (IsWorkspacePythonFile(docFilePath))
                        {
                            TriggerInfoBar();
                            break;
                        }
                    }
                }
            }

            if (!_infoBarCheckTriggered)
            {
                if (ErrorHandler.Succeeded(_docTable.AdviseRunningDocTableEvents(this, out uint eventCookie)))
                {
                    workspace.AddActionOnClose(_docTable, obj => _docTable.UnadviseRunningDocTableEvents(eventCookie));
                }
            }
        }
Пример #26
0
        public SaveListener(IVsRunningDocumentTable rdt)
        {
            if (rdt == null)
            {
                throw new ArgumentNullException("rdt");
            }

            _rdt = rdt;
            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(this, out _pdwCookie));
        }
        public SaveListener(IVsRunningDocumentTable rdt)
        {
            if (rdt == null)
            {
                throw new ArgumentNullException("rdt");
            }

            _rdt = rdt;
            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(this, out _pdwCookie));
        }
 public XSharpDocumentWatcher(IServiceProvider provider)
 {
     this.provider = provider;
     knownCookies  = new List <uint>();
     rdt           = provider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if (null != rdt)
     {
         // Do not throw here in case of error, simply skip the registration.
         rdt.AdviseRunningDocTableEvents(this, out runningDocTableCookie);
     }
 }
        /// <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()
        {
//            Trace.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
//            base.Initialize();
//
//            // Add our command handlers for menu (commands must exist in the .vsct file)
//            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
//            if ( null != mcs )
//            {
//                // Create the command for the menu item.
//                CommandID menuCommandID = new CommandID(GuidList.guidJiraEditorLinksCmdSet, (int)PkgCmdIDList.cmdidMyCommand);
//                MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
//                mcs.AddCommand( menuItem );
//            }



            JiraLinkMarkerTypeProvider markerTypeProvider = new JiraLinkMarkerTypeProvider();

            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            base.Initialize();

            // Now it's time to initialize our copies of the marker IDs. We need them to be
            // able to create marker instances.
            JiraLinkMarkerTypeProvider.InitializeMarkerIds(this);

            // Advise event sinks. We need to know when a solution is opened and closed
            // (SolutionEventSink), when a document is opened and closed (TextManagerEventSink),
            // and when a document is saved (RunningDocTableEventSink).
            SolutionEventSink        solutionEventSink        = new SolutionEventSink();
            TextManagerEventSink     textManagerEventSink     = new TextManagerEventSink();
            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();

            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out solutionEventCookie));

            IConnectionPointContainer textManager = (IConnectionPointContainer)GetService(typeof(SVsTextManager));
            Guid interfaceGuid = typeof(IVsTextManagerEvents).GUID;

            textManager.FindConnectionPoint(ref interfaceGuid, out tmConnectionPoint);
            tmConnectionPoint.Advise(textManagerEventSink, out tmConnectionCookie);

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();
        }
Пример #30
0
 private void InitializePackage()
 {
     rdt.AdviseRunningDocTableEvents(new RunningDocTableEvents(this), out rdtCookie);
     if (GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
     {
         // Create the command for the menu item.
         CommandID menuCommandID = new CommandID(
             GuidList.guidRemoveTrailingWhitespacesCmdSet, (int)PkgCmdIDList.cmdIdRemoveTrailingWhitespaces);
         OleMenuCommand menuItem = new OleMenuCommand(OnRemoveTrailingWhitespacesPressed, menuCommandID);
         menuItem.BeforeQueryStatus += OnBeforeQueryStatus;
         mcs.AddCommand(menuItem);
     }
 }
Пример #31
0
 public void StartListening()
 {
     if (_projectDocTracker != null)
     {
         int hr = _projectDocTracker.AdviseTrackProjectDocumentsEvents(this, out _cookie);
         ErrorHandler.ThrowOnFailure(hr); // do nothing if this fails
     }
     if (_documentTable != null)
     {
         int hr = _documentTable.AdviseRunningDocTableEvents(this, out _documentTableItemId);
         ErrorHandler.ThrowOnFailure(hr);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionFilesChangeManager"/> class.
 /// </summary>
 /// <param name="serviceProvider">The service provider.</param>
 /// <param name="patterns">The patterns.</param>
 public SolutionFilesChangeManager(IServiceProvider serviceProvider, params string[] patterns)
 {
     Guard.ArgumentNotNull(serviceProvider, "serviceProvider");
     Guard.ArgumentNotNull(patterns, "patterns");
     Rules = new List<ObserveRule>();
     foreach (var pattern in patterns)
     {
         Rules.Add(new ObserveRule(pattern));
     }
     _serviceProvider = serviceProvider;
     _runningDocumentTableService = serviceProvider.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     _runningDocumentTableService.AdviseRunningDocTableEvents(this, out _rdtCookie);
 }
Пример #33
0
        private void RegisterForRDTEvents()
        {
            if (0 != _runningDocTableCookie)
            {
                return;
            }
            IVsRunningDocumentTable rdt = GetPackageService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (null != rdt)
            {
                // Do not throw here in case of error, simply skip the registration.
                rdt.AdviseRunningDocTableEvents(this, out _runningDocTableCookie);
            }
        }
Пример #34
0
        public bool Register(EnvDTE.DTE dte, string repoPath, string solutionPath)
        {
            // Register events for running document table.
            m_RDT = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
            m_RDT.AdviseRunningDocTableEvents(this, out m_rdtCookie);

            provider = new GitProviderLibGit2Sharp();
            provider.ContextRepository     = repoPath;
            provider.SolutionBaseDirectory = solutionPath;
            provider.Open(repoPath);

            // I: test if this table is from multiple instances routed here...
            return(true);
        }
Пример #35
0
        internal void AdviseEvents()
        {

            vsRDT = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
            // 1. subscribe to internal file events - events initiated from within VS
            ErrorHandler.ThrowOnFailure(vsRDT.AdviseRunningDocTableEvents(this, out rdtCookie));

            // 2. subscribe to external file events
            foreach (string fileName in codeFiles)
                    AddWatcher(fileName);
            vsTPD = (IVsTrackProjectDocuments2)Package.GetGlobalService(typeof(SVsTrackProjectDocuments));
            ErrorHandler.ThrowOnFailure(vsTPD.AdviseTrackProjectDocumentsEvents(this, out tpdCookie));

        }
Пример #36
0
        protected override void Initialize()
        {
            base.Initialize();

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

            _adapterFactory       = component.GetService <IVsEditorAdaptersFactoryService>();
            _editorFactoryService = component.GetService <RazorEditorFactoryService>();

            _textManager = (IVsTextManager)GetService(typeof(SVsTextManager));
            _rdt         = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            var hr = _rdt.AdviseRunningDocTableEvents(new RdtEvents(this), out uint _cookie);

            ErrorHandler.ThrowOnFailure(hr);
        }
Пример #37
0
        protected DocumentFrameMgr(IXmlDesignerPackage package)
        {
            _package = package;
            _editingContextMgr = new EditingContextManager(package);

            _package.FileNameChanged += OnAfterFileNameChanged;

            IServiceProvider sp = _package;
            _rdt = sp.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
            if (_rdt != null)
            {
                NativeMethods.ThrowOnFailure(_rdt.AdviseRunningDocTableEvents(this, out _rdtEventsCookie));
            }

            _sel = sp.GetService(typeof(IVsMonitorSelection)) as IVsMonitorSelection;
            if (_sel != null)
            {
                _sel.AdviseSelectionEvents(this, out _selEventsCookie);
            }
        }
Пример #38
0
 /// <summary>
 /// Register RunningDocumentTable events.
 /// </summary>
 public void RegisterRunningDocumentTableEvents() {
     DocumentTable = (IVsRunningDocumentTable) Package.GetGlobalService(typeof(SVsRunningDocumentTable));
     if(DocumentTable != null) {
         int hr = DocumentTable.AdviseRunningDocTableEvents(this, out DocumentTableItemId);
         ErrorHandler.ThrowOnFailure(hr);
     }
 }
Пример #39
0
 /// <summary>
 /// Subscribe to the running document table events
 /// </summary>
 private void SubscribeToEvents() {
     DocumentTable = Package.GetGlobalService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
     if(DocumentTable != null) {
         int result = DocumentTable.AdviseRunningDocTableEvents(this, out DocumentTableItemId);
         ErrorHandler.ThrowOnFailure(result);
     }
 }
Пример #40
0
        public bool Register(EnvDTE.DTE dte, GanjiContext context)
        {
            table = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
            // Listen to show/hide events of docs to register activate/deactivate cursor listeners.
            table.AdviseRunningDocTableEvents(this, out m_rdtCookie);
            // In turn, cursor events will register a IVsTextViewEvents indexed by the IVsTextView.

            provider = new GitProviderLibGit2Sharp();
            provider.ContextRepository = context.RepositoryPath;
            provider.SolutionBaseDirectory = context.SolutionPath;
            provider.Open(context.RepositoryPath);

            // Mixing in Find events with click events.
            m_dte = dte;
            m_findEvents = dte.Events.FindEvents;
            m_findEvents.FindDone += new EnvDTE._dispFindEvents_FindDoneEventHandler(m_findEvents_FindDone);

            return true;
        }
Пример #41
0
        private uint rdtEventsCookie; // = 0

        private void InitializeRunningDocTableEvents()
        {
            rdt = Common.GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            if (rdt != null)
            {
                rdt.AdviseRunningDocTableEvents(this, out rdtEventsCookie);
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overriden Package Implementation
        /// <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()
        {
            Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                // Create the command for the menu item.
                var menuCommandID = new CommandID(GuidList.guidVSPackageCmdSet,
                                                  (int) PkgCmdIDList.EPiServerLanguageExtensionOptions);
                var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            _docTable = (IVsRunningDocumentTable) GetService(typeof (SVsRunningDocumentTable));
            _docTable.AdviseRunningDocTableEvents(this, out _docTableCookie);

            // Your package is also a service container
            // The DTE object contains most of the goodies you'll want to play with
            _dte = ((IServiceContainer) this).GetService(typeof (SDTE)) as DTE;

            _solutionEvents = _dte.Events.SolutionEvents;
            _solutionEvents.Opened += SolutionOpened;

            SolutionOpened(); // we have to trigger this manually since in VS2012 Opened event is not triggered when the solution is opened at the same time as Visual Studio is launched (for example by double clicking the solution file in explorer)
        }
 public RunningDocTableEventsListener(IVsRunningDocumentTable rdt)
 {
     this.rdt = rdt;
     rdt.AdviseRunningDocTableEvents(this, out cookie);
 }
Пример #44
0
        public bool Register(EnvDTE.DTE dte, GanjiContext context)
        {
            // Register events for running document table.
            m_RDT = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));
            m_RDT.AdviseRunningDocTableEvents(this, out m_rdtCookie);

            provider = new GitProviderLibGit2Sharp();
            provider.ContextRepository = context.RepositoryPath;
            provider.SolutionBaseDirectory = context.SolutionPath;
            provider.Open(context.RepositoryPath);

            // I: test if this table is from multiple instances routed here...
            return true;
        }
 public RunningDocumentTableEventSink(IVsRunningDocumentTable runningDocumentTable, IMessageBus messageBus)
 {
     _runningDocumentTable = runningDocumentTable;
     _messageBus = messageBus;
     _runningDocumentTable.AdviseRunningDocTableEvents(this, out _cookie);
 }
Пример #46
0
 public RdtManager(IServiceProvider provider)
 {
     rdt = provider.GetService(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
     rdt.AdviseRunningDocTableEvents(this, out cookie);
     var dte = provider.GetService(typeof(DTE)) as DTE;
 }
        internal void Register()
        {
            // Register this object to listen for IVsUpdateSolutionEvents
            IVsSolutionBuildManager2 buildManager = Package.GetService<SVsSolutionBuildManager, IVsSolutionBuildManager2>();
            if (buildManager == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            buildManager.AdviseUpdateSolutionEvents(this, out m_updateSolutionEventsCookie);

            // Register this object to listen for IVsSolutionEvents
            IVsSolution solution = Package.GetService<SVsSolution, IVsSolution>();
            if (solution == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            solution.AdviseSolutionEvents(this, out m_solutionEventsCookie);

            // Register this object to listen for IVsRunningDocTableEvents
            _runningDocTable = Package.GetService<SVsRunningDocumentTable, IVsRunningDocumentTable>();
            if (_runningDocTable == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            _runningDocTable.AdviseRunningDocTableEvents(this, out m_runningDocTableEventsCookie);
        }