예제 #1
0
        internal WindowEvents()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsUIShell7 svc = VS.GetRequiredService <SVsUIShell, IVsUIShell7>();

            svc.AdviseWindowFrameEvents(this);
        }
예제 #2
0
        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 Func <Type, object> ServiceTypeChecker(IVsUIShell7 uiShell, IVsSolution solution)
        {
            return(t =>
            {
                if (typeof(SVsUIShell).Equals(t))
                {
                    return uiShell;
                }

                if (typeof(SVsSolution).Equals(t))
                {
                    return solution;
                }

                Assert.True(false, $"Type {t} is not expected");
                return null;
            });
        }
예제 #5
0
            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 static void Initialize(IVsUIShell7 vsUIShell, DTE dte)
 {
     ReadviseWindowFrameEvents(vsUIShell, dte);
 }
 public void Unadvise()
 {
     Shell.ThreadHelper.ThrowIfNotOnUIThread();
     IVsUIShell7 uiShell = (IVsUIShell7)Package.GetGlobalService(typeof(SVsUIShell));
     uiShell.UnadviseWindowFrameEvents(_cookie);
 }