Esempio n. 1
0
        public void Unadvise()
        {
            Shell.ThreadHelper.ThrowIfNotOnUIThread();
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)Package.GetGlobalService(typeof(SVsRunningDocumentTable));

            rdt.UnadviseRunningDocTableEvents(_cookie);
        }
        internal void Unregister()
        {
            // Unregister this object from IVsUpdateSolutionEvents events
            if (m_updateSolutionEventsCookie != VSCOOKIE_NIL)
            {
                IVsSolutionBuildManager2 buildManager = Package.GetService <SVsSolutionBuildManager, IVsSolutionBuildManager2>();
                if (buildManager != null)
                {
                    buildManager.UnadviseUpdateSolutionEvents(m_updateSolutionEventsCookie);
                    m_updateSolutionEventsCookie = VSCOOKIE_NIL;
                }
            }

            // Unregister this object from IVsSolutionEvents events
            if (m_solutionEventsCookie != VSCOOKIE_NIL)
            {
                IVsSolution solution = Package.GetService <SVsSolution, IVsSolution>();
                if (solution != null)
                {
                    solution.UnadviseSolutionEvents(m_solutionEventsCookie);
                    m_solutionEventsCookie = VSCOOKIE_NIL;
                }
            }

            // Unregister this object from IVsRunningDocTableEvents events
            if (m_runningDocTableEventsCookie != VSCOOKIE_NIL)
            {
                IVsRunningDocumentTable runningDocTable = Package.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();
                if (runningDocTable != null)
                {
                    runningDocTable.UnadviseRunningDocTableEvents(m_runningDocTableEventsCookie);
                    m_runningDocTableEventsCookie = VSCOOKIE_NIL;
                }
            }
        }
        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);
            }
        }
Esempio n. 4
0
        protected override void Dispose(bool disposing)
        {
            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            try {
                solution.UnadviseSolutionEvents(solutionEventCookie);
            }
// ReSharper disable EmptyGeneralCatchClause
            catch {}
// ReSharper restore EmptyGeneralCatchClause
            base.Dispose(disposing);

            // Remove text manager event notifications.
            if (tmConnectionPoint != null)
            {
                tmConnectionPoint.Unadvise(tmConnectionCookie);
                tmConnectionPoint = null;
            }

            // Remove running document table (RDT) event notifications.
            // Ignore any errors that might occur since we're shutting down.
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            if (rdt != null)
            {
                try {
                    rdt.UnadviseRunningDocTableEvents(rdtEventCookie);
                } catch (Exception) {}
            }
        }
        protected override void Dispose(bool disposing)
        {
            // Remove solution event notifications.
            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            try
            {
                solution.UnadviseSolutionEvents(solutionEventCookie);
            }
            catch
            {
            }

            // Remove text manager event notifications.
            if (tmConnectionPoint != null)
            {
                tmConnectionPoint.Unadvise(tmConnectionCookie);
                tmConnectionPoint = null;
            }

            // Remove running document table (RDT) event notifications.
            // Ignore any errors that might occur since we're shutting down.
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            try
            {
                rdt.UnadviseRunningDocTableEvents(rdtEventCookie);
            }
            catch (Exception)
            {
            }

            // Forward call to the base class.
            base.Dispose(disposing);
        }
Esempio n. 6
0
 public void Dispose()
 {
     if (documentService != null && cookie != 0)
     {
         documentService.UnadviseRunningDocTableEvents(cookie);
     }
 }
Esempio n. 7
0
 private void UnadviseRunningDocumentTableEvents()
 {
     if (runningDocumentTable != null)
     {
         ErrorHandler.ThrowOnFailure(runningDocumentTable.UnadviseRunningDocTableEvents(runningDocumentTableCookie));
         runningDocumentTable = null;
     }
 }
Esempio n. 8
0
 public void Shutdown()
 {
     if (m_RDT != null)
     {
         m_RDT.UnadviseRunningDocTableEvents(m_rdtCookie);
         m_RDT = null;
     }
 }
 /// <summary>
 /// Unregister RunningDocumentTable events.
 /// </summary>
 public void UnregisterRunningDocumentTableEvents()
 {
     if (DocumentTable != null)
     {
         int hr = DocumentTable.UnadviseRunningDocTableEvents(DocumentTableItemId);
         ErrorHandler.Succeeded(hr);
     }
 }
Esempio n. 10
0
        protected override void Dispose(bool disposing)
        {
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)ServiceProvider.GetGlobalServiceAsync(typeof(SVsRunningDocumentTable));

            rdt.UnadviseRunningDocTableEvents(rdtCookie);

            base.Dispose(disposing);
        }
 void IDisposable.Dispose()
 {
     if (runningDocumentTableCookie != 0)
     {
         runningDocumentTable.UnadviseRunningDocTableEvents(runningDocumentTableCookie);
         runningDocumentTableCookie = 0;
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Unsubscribe from the running document table events
 /// </summary>
 private void UnsubscribeFromEvents()
 {
     if (DocumentTable != null)
     {
         int result = DocumentTable.UnadviseRunningDocTableEvents(DocumentTableItemId);
         ErrorHandler.Succeeded(result);
     }
 }
Esempio n. 13
0
 private void DisposeRunningDocTableEvents()
 {
     if (rdt != null && rdtEventsCookie != 0)
     {
         rdt.UnadviseRunningDocTableEvents(rdtEventsCookie);
         rdtEventsCookie = 0;
     }
     rdt = null;
 }
 void IDisposable.Dispose()
 {
     if (_runningDocumentTableCookie == 0)
     {
         return;
     }
     _runningDocumentTable.UnadviseRunningDocTableEvents(_runningDocumentTableCookie);
     _runningDocumentTableCookie = 0;
 }
Esempio n. 15
0
 public void Dispose()
 {
     if (rdt != null)
     {
         rdt.UnadviseRunningDocTableEvents(cookie);
         rdt = null;
         GC.SuppressFinalize(this);
     }
 }
Esempio n. 16
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));
                }
            }
        }
Esempio n. 17
0
        void IDisposable.Dispose()
        {
            if (runningDocumentTableCookie != 0)
            {
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
                runningDocumentTable.UnadviseRunningDocTableEvents(runningDocumentTableCookie);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
                runningDocumentTableCookie = 0;
            }
        }
 public void Dispose()
 {
     if (0 == runningDocTableCookie || this.rdt == null)
     {
         return;
     }
     // Do not throw in case of error.
     rdt.UnadviseRunningDocTableEvents(runningDocTableCookie);
     runningDocTableCookie = 0;
 }
        protected override void Dispose(bool disposing)
        {
            // Release the RDT cookie.
            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)
                                          Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsRunningDocumentTable));

            rdt.UnadviseRunningDocTableEvents(rdtCookie);

            base.Dispose(disposing);
        }
        void IDisposable.Dispose()
        {
            if ((int)_runningDocumentTableCookie == 0)
            {
                return;
            }

            ThreadHelper.JoinableTaskFactory.Run(async delegate {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                _runningDocumentTable.UnadviseRunningDocTableEvents(_runningDocumentTableCookie);
                _runningDocumentTableCookie = 0U;
            });
        }
Esempio n. 21
0
        public async Task DisposeAsync()
        {
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(this.DisposalToken);

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)(await GetServiceAsync(typeof(SVsRunningDocumentTable)));

            rdt.UnadviseRunningDocTableEvents(_rdtCookie);

            if (_outputPane != null)
            {
                _outputPane?.Hide();
                IVsOutputWindow output = (IVsOutputWindow)GetService(typeof(SVsOutputWindow));
                output.DeletePane(ref _paneGuid);
            }
        }
Esempio n. 22
0
 public void Shutdown()
 {
     table.UnadviseRunningDocTableEvents(m_rdtCookie);
     foreach (var activeView in new HashSet <IVsTextView>(_cookieList.Keys))
     {
         try
         {
             DeactivateCursorLogger(activeView);
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex.Message);
         }
     }
 }
Esempio n. 23
0
        private void UnregisterRDTEvents()
        {
            if (0 == _runningDocTableCookie)
            {
                return;
            }
            IVsRunningDocumentTable rdt = GetPackageService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;

            if (null != rdt)
            {
                // Do not throw in case of error.
                rdt.UnadviseRunningDocTableEvents(_runningDocTableCookie);
            }
            _runningDocTableCookie = 0;
        }
Esempio n. 24
0
        public void StopListening()
        {
            if (_cookie != VSConstants.VSCOOKIE_NIL && _projectDocTracker != null)
            {
                int hr = _projectDocTracker.UnadviseTrackProjectDocumentsEvents(_cookie);
                ErrorHandler.Succeeded(hr); // do nothing if this fails

                _cookie = VSConstants.VSCOOKIE_NIL;
            }
            if (_documentTable != null)
            {
                int hr = _documentTable.UnadviseRunningDocTableEvents(_documentTableItemId);
                ErrorHandler.Succeeded(hr);
            }
        }
Esempio n. 25
0
        protected override void Dispose(bool disposing)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            if (disposed)
            {
                return;
            }

            disposed = true;

            if (rdt != null)
            {
                rdt.UnadviseRunningDocTableEvents(cookie);
                rdt = null;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Appelée lors du déchargement de la stratégie
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        public override void OnUnloading(object sender, EventArgs eventArgs)
        {
            base.OnUnloading(sender, eventArgs);

            IVsRunningDocumentTable rdtEvents = GetService <IVsRunningDocumentTable>(typeof(SVsRunningDocumentTable));

            if (rdtEvents != null && _rdtEventsCookie != 0)
            {
                try
                {
                    rdtEvents.UnadviseRunningDocTableEvents(_rdtEventsCookie);
                }
                catch
                {
                }
                _configFolders.Clear();
            }
        }
        void IDisposable.Dispose()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                if (Directory.Exists(s_baseTempPath))
                {
                    Directory.Delete(s_baseTempPath, recursive: true);
                }
            }
            catch
            {
            }

            if (_runningDocumentTableCookie != 0)
            {
                _runningDocumentTable?.UnadviseRunningDocTableEvents(_runningDocumentTableCookie);
                _runningDocumentTableCookie = 0;
            }
        }
Esempio n. 28
0
        public void Shutdown()
        {
            table.UnadviseRunningDocTableEvents(m_rdtCookie);
            foreach (var activeView in new HashSet <IVsTextView>(_cookieList.Keys))
            {
                try
                {
                    DeactivateCursorLogger(activeView);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                }
            }
            m_findEvents.FindDone -= new EnvDTE._dispFindEvents_FindDoneEventHandler(m_findEvents_FindDone);
            m_findEvents           = null;

            if (m_findWindow1 != null)
            {
                var item = m_findWindow1.VisualElement as Control;
                if (item != null)
                {
                    item.MouseDoubleClick -= viz_MouseDoubleClickFind1;
                }
                m_findWindow1 = null;
            }

            if (m_findWindow2 != null)
            {
                var item = m_findWindow2.VisualElement as Control;
                if (item != null)
                {
                    item.MouseDoubleClick -= viz_MouseDoubleClickFind2;
                }
                m_findWindow2 = null;
            }
        }
        public void Dispose()
        {
            if (!_disposed)
            {
                // shared cleanup logic
                if (_rdt != null)
                {
                    _rdt.UnadviseRunningDocTableEvents(_rdtEventsCookie);
                    _rdt             = null;
                    _rdtEventsCookie = 0;
                }

                if (_sel != null)
                {
                    _sel.UnadviseSelectionEvents(_selEventsCookie);
                    _selEventsCookie = 0;
                    _sel             = null;
                }

                _package.FileNameChanged -= OnAfterFileNameChanged;

                _disposed = true;
            }
        }
Esempio n. 30
0
        async Task DoInitializeAsync()
        {
            CloseableTabItem tabItemTabProc = GetTabItem();
            var strxaml =
                $@"<Grid
xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
xmlns:l=""clr-namespace:{this.GetType().Namespace};assembly={
    System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location)}"" 
        >
        <Grid.RowDefinitions>
            <RowDefinition Height=""auto""/>
            <RowDefinition Height=""*""/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row=""0"" HorizontalAlignment=""Left"" Height=""75"" VerticalAlignment=""Top"" Orientation=""Horizontal"">
            <CheckBox Margin=""15,0,0,10"" Content=""Output To Debug OutputPane""  IsChecked=""{{Binding UseOutputPane}}""  
                ToolTip=""Output to Debug OutputPane 'PerfGraphVSIX'""/>
        <TextBox xml:space=""preserve"" >
IVsMonitorSelection until this tab is closed.
Output to Debug OutputPane or LogStatus
</TextBox>
        </StackPanel>
        <Grid Name=""gridUser"" Grid.Row = ""1""></Grid>
    </Grid>
";
            var strReader  = new System.IO.StringReader(strxaml);
            var xamlreader = XmlReader.Create(strReader);
            var grid       = (Grid)(XamlReader.Load(xamlreader));

            tabItemTabProc.Content = grid;

            grid.DataContext = this;
            var gridUser = (Grid)grid.FindName("gridUser");

            _OutputPane = await GetOutputPaneAsync();

            _OutputPane.Clear();
            uint cookieSelectionEvents = 0;
            uint cookieRdt             = 0;
            await ThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                LogMessage("Here in MySimpleSample " + DateTime.Now.ToString("MM/dd/yy hh:mm:ss"));
                await TaskScheduler.Default; // switch to background thread
                LogMessage("Logger message from MySimpleSample");

                var SolutionService = await _asyncServiceProvider.GetServiceAsync(typeof(SVsSolution)) as IVsSolution;
                LogMessage($"{nameof(SolutionService)} {SolutionService}");

                var oleMenuCommandService = await _asyncServiceProvider.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
                LogMessage($"{nameof(oleMenuCommandService)} = {oleMenuCommandService}");

                var VsShellMonitorSelection = await _asyncServiceProvider.GetServiceAsync(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
                LogMessage($"{nameof(VsShellMonitorSelection)} = {VsShellMonitorSelection}");
                VsShellMonitorSelection.AdviseSelectionEvents(this, out cookieSelectionEvents);

                IVsRunningDocumentTable vsRunningDocumentTable = await _asyncServiceProvider.GetServiceAsync(typeof(IVsRunningDocumentTable)) as IVsRunningDocumentTable;
                //vsRunningDocumentTable.AdviseRunningDocTableEvents(this, out cookieRdt);
                void UnSubscribe()
                {
                    VsShellMonitorSelection.UnadviseSelectionEvents(cookieSelectionEvents);
                    vsRunningDocumentTable.UnadviseRunningDocTableEvents(cookieRdt);
                }
                tabItemTabProc.TabItemClosed += async(o, e) =>
                {
                    UnSubscribe();
                    await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                    _perfGraphToolWindowControl.TabControl.SelectedIndex = 0;
                };
            });
        }