internal WindowEvents() { ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell7 svc = VS.GetRequiredService <SVsUIShell, IVsUIShell7>(); svc.AdviseWindowFrameEvents(this); }
protected override async Task InitializeAsync(CancellationToken token, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(token, progress); Debug.WriteLine("InitializeAsync"); await JoinableTaskFactory.SwitchToMainThreadAsync(); page = GetDialogPage(typeof(SettingsPage)) as SettingsPage; page.NameChanged += NameChanged; monitor = new TabMonitor(page.GetNames()); uiShell7 = await GetServiceAsync(typeof(SVsUIShell)) as IVsUIShell7; Assumes.Present(uiShell7); wfeCookie = uiShell7.AdviseWindowFrameEvents(monitor); var dte = await GetServiceAsync(typeof(DTE)) as DTE2; Assumes.Present(dte); dteEvents = dte.Events.DTEEvents; dteEvents.ModeChanged += DteEvents_ModeChanged; Debug.WriteLine("InitializeAsync !"); }
private static void ReadviseWindowFrameEvents(IVsUIShell7 vsUIShell, DTE dte) { ThreadHelper.ThrowIfNotOnUIThread(); if (Cookie is uint cookie) { // Ensure that we only have one event sink installed for the app domain if initialize is called // multiple times while testing. vsUIShell.UnadviseWindowFrameEvents(cookie); } Cookie = vsUIShell.AdviseWindowFrameEvents(new StartPageExtender(dte, (IVsUIShell)vsUIShell)); }
private void Show() { IVsTextView view; IVsWindowFrame vsWindowFrame; try { IVsUIHierarchy hier; uint itemid; VsShellUtilities.OpenDocument(RPackage.Current, _fileName, VSConstants.LOGVIEWID.Code_guid, out hier, out itemid, out vsWindowFrame, out view); } catch (Exception ex) { _services.ShowErrorMessage(Resources.Error_ExceptionAccessingPath.FormatInvariant(_fileName, ex.Message)); _tcs.TrySetResult(string.Empty); return; } _editorFrame = vsWindowFrame; if (view == null || _editorFrame == null) { _tcs.TrySetResult(string.Empty); return; } if (_tcs.Task.IsCompleted) { Close(); return; } IVsTextLines vsTextLines; view.GetBuffer(out vsTextLines); _textBuffer = _adapterService.GetDataBuffer(vsTextLines); _uiShell = _services.GetService <IVsUIShell7>(typeof(SVsUIShell)); _cookie = _uiShell.AdviseWindowFrameEvents(this); }
public void Advise() { Shell.ThreadHelper.ThrowIfNotOnUIThread(); IVsUIShell7 uiShell = (IVsUIShell7)Package.GetGlobalService(typeof(SVsUIShell)); _cookie = uiShell.AdviseWindowFrameEvents(this); }