Ejemplo n.º 1
0
        private static void Evaluate(EnvDTE.Window WindowReference, Action <System.Windows.Forms.WebBrowser> OnEvaluate)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            //Note: Window of EnvDTE.Constants.vsWindowKindWebBrowser type contains an IWebBrowser2 object
            using (System.Threading.ManualResetEvent evt = new System.Threading.ManualResetEvent(false))
            {
                System.Threading.Thread STAThread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart((o) =>
                {
                    try
                    {
                        using (VisualStudioWebBrowser Browser = new VisualStudioWebBrowser(o))
                        {
                            try
                            {
                                OnEvaluate.Invoke(Browser);
                            }
                            catch { }
                        }
                    }
                    catch { }
                    evt.Set();
                }));
                STAThread.SetApartmentState(System.Threading.ApartmentState.STA);
                STAThread.Start(WindowReference.Object);
                evt.WaitOne();
            }
        }
Ejemplo n.º 2
0
        public static Uri GetWebBrowserWindowUrl(EnvDTE.Window WindowReference)
        {
            Uri BrowserUrl = new Uri("", UriKind.RelativeOrAbsolute);

            VisualStudioWebBrowser.Evaluate(WindowReference, new Action <System.Windows.Forms.WebBrowser>((wb) =>
            {
                BrowserUrl = wb.Url;
            }));
            return(BrowserUrl);
        }
Ejemplo n.º 3
0
        private EnvDTE.Window GetWindow(DTE2 dte2, string url)
        {
            var enumerator = dte2.Windows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var window = enumerator.Current as EnvDTE.Window;
                if (window.ObjectKind.Equals(EnvDTE.Constants.vsWindowKindWebBrowser))
                {
                    var url2 = VisualStudioWebBrowser.GetWebBrowserWindowUrl(window).ToString();
                    //AsmDudeToolsStatic.Output_INFO("Documentation " + window.Caption + " is open. url=" + url2.ToString());
                    if (url2.Equals(url, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(window);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        private async Task <EnvDTE.Window> GetWindowAsync(DTE2 dte2, string url)
        {
            if (!ThreadHelper.CheckAccess())
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
            }

            System.Collections.IEnumerator enumerator = dte2.Windows.GetEnumerator();
            while (enumerator.MoveNext())
            {
                EnvDTE.Window window = enumerator.Current as EnvDTE.Window;
                if (window.ObjectKind.Equals(EnvDTE.Constants.vsWindowKindWebBrowser))
                {
                    string url2 = VisualStudioWebBrowser.GetWebBrowserWindowUrl(window).ToString();
                    //AsmDudeToolsStatic.Output_INFO("Documentation " + window.Caption + " is open. url=" + url2.ToString());
                    if (url2.Equals(url, StringComparison.InvariantCultureIgnoreCase))
                    {
                        return(window);
                    }
                }
            }
            return(null);
        }