Exemplo n.º 1
0
 public void OnNewWindow(NewWindowEventArgs e)
 {
     if (StartNewWindow != null)
     {
         StartNewWindow(this, e);
     }
 }
Exemplo n.º 2
0
        public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
        {
            var chromiumWebBrowser = (ExtChromiumBrowser)browserControl;

            chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
            {
                BrowserPopupWin win = new BrowserPopupWin();
                win.ShowInTaskbar   = false;
                win.Height          = 0;
                win.Width           = 0;
                win.Show();

                IntPtr handle = new WindowInteropHelper(win).Handle;
                windowInfo.SetAsChild(handle);

                _scheduler.Run(() =>
                {
                    WaitUtil.Wait(() => chromiumWebBrowser.PostData);

                    IRequest request = null;
                    if (chromiumWebBrowser.PostData != null)
                    {
                        request        = frame.CreateRequest();
                        request.Url    = targetUrl;
                        request.Method = "POST";

                        request.InitializePostData();
                        var element   = request.PostData.CreatePostDataElement();
                        element.Bytes = chromiumWebBrowser.PostData;
                        request.PostData.AddElement(element);
                        chromiumWebBrowser.PostData = null;
                    }

                    chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
                    {
                        NewWindowEventArgs e = new NewWindowEventArgs(targetUrl, request);
                        chromiumWebBrowser.OnNewWindow(e);
                    }));

                    chromiumWebBrowser.Dispatcher.Invoke(new Action(() =>
                    {
                        win.Close();
                    }));
                });
            }));

            newBrowser = null;
            return(false);
        }