WebKit Browser Control.
Inheritance: System.Windows.Forms.UserControl, IWebKitBrowserHost, IWebKitBrowser
Exemplo n.º 1
1
 public CustomUndoSystem(WebKitBrowser browser)
 {
     Owner = browser;
     Owner.Navigating += new WebKitBrowserNavigatingEventHandler(Owner_Navigating);
     Owner.TextChangeInArea += new TextDidChangeInArea(Owner_TextChangeInArea);
     Owner.TextChangeInField += new TextDidChangeInField(Owner_TextChangeInField);
 }
Exemplo n.º 2
0
 public void setCallback(SensorCallback callback, WebKitBrowser webView)
 {
     this.callback = callback;
     thread = new Thread(new ThreadStart(run));
     thread.SetApartmentState(ApartmentState.STA);
     thread.IsBackground = true;
 }
Exemplo n.º 3
0
 public CustomUndoSystem(WebKitBrowser browser)
 {
     Owner                    = browser;
     Owner.Navigating        += new WebKitBrowserNavigatingEventHandler(Owner_Navigating);
     Owner.TextChangeInArea  += new TextDidChangeInArea(Owner_TextChangeInArea);
     Owner.TextChangeInField += new TextDidChangeInField(Owner_TextChangeInField);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes several code routines after the webkit containing element loads
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void browserContainer_Loaded(object sender, RoutedEventArgs e)
        {
            WindowsFormsHost host = new WindowsFormsHost();

            wkBrowser = new WebKit.WebKitBrowser();
            host.Child = wkBrowser;

            this.browserContainer.Children.Add(host);


            wkBrowser.Navigate(ConfigurationManager.AppSettings["url"]);

            this.ViewModel.PropertyChanged += (o, f) =>
            {
                if (f.PropertyName.Equals("URI"))
                {
                    MakeJSCall(this.ViewModel.URI);
                    playSoundFeedback();
                }
            };

            setupTimer.Start();


        }
Exemplo n.º 5
0
 void AddEvents(WebKitBrowser browser)
 {
     browser.Navigating += new WebKitBrowserNavigatingEventHandler(webKitBrowser1_Navigating);
     browser.DocumentCompleted +=new WebBrowserDocumentCompletedEventHandler(webKitBrowser1_DocumentCompleted);
     browser.CanGoBackChanged +=new CanGoBackChanged(webKitBrowser1_CanGoBackChanged);
     browser.GeolocationPositionRequest += new GeolocationRequest(browser_GeolocationPositionRequest);
     browser.CanGoForwardChanged +=new CanGoForwardChanged(webKitBrowser1_CanGoForwardChanged);
     browser.CloseWindowRequest +=new EventHandler(webKitBrowser1_CloseWindowRequest);
     browser.DangerousSiteDetected +=new EventHandler(webKitBrowser1_DangerousSiteDetected);
     browser.DocumentTitleChanged +=new EventHandler(webKitBrowser1_DocumentTitleChanged);
     browser.FaviconAvailable +=new FaviconAvailable(webKitBrowser1_FaviconAvaiable);
     browser.HeadersAvailable += new HeadersAvailableEventHandler(browser_HeadersAvailable);
     browser.FormSubmit +=new WillSubmitForm(webKitBrowser1_FormSubmit);
     browser.NewWindowCreated +=new NewWindowCreatedEventHandler(webKitBrowser1_NewWindowCreated);
     browser.PopupCreated +=new NewWindowCreatedEventHandler(webKitBrowser1_PopupCreated);
     browser.ProgressChanged +=new WebKit.ProgressChangedEventHandler(webKitBrowser1_ProgressChanged);
     browser.ShowJavaScriptAlertPanel +=new ShowJavaScriptAlertPanelEventHandler(webKitBrowser1_ShowJavaScriptAlertPanel);
     browser.ShowJavaScriptConfirmPanel +=new ShowJavaScriptConfirmPanelEventHandler(webKitBrowser1_ShowJavaScriptConfirmPanel);
     browser.ShowJavaScriptPromptBeforeUnload +=new ShowJavaScriptPromptBeforeUnloadEventHandler(webKitBrowser1_ShowJavaScriptPromptBeforeUnload);
     browser.ShowJavaScriptPromptPanel +=new ShowJavaScriptPromptPanelEventHandler(webKitBrowser1_ShowJavaScriptPromptPanel);
     browser.StatusTextChanged +=new StatusTextChanged(webKitBrowser1_StatusTextChanged);
     browser.CustomContextMenuManager.ShowContextMenu += new ShowContextMenu(CustomContextMenuManager_ShowContextMenu);
     browser.ResourceIntercepter.ResourceSizeAvailableEvent += new ResourceSizeAvailable(ResourceIntercepter_ResourceProgressChangedEvent);
     browser.ResourceIntercepter.ResourceFinishedLoadingEvent += new ResourceFinishedLoadingHandler(ResourceIntercepter_ResourceFinishedLoadingEvent);
     browser.ResourceIntercepter.ResourceStartedLoadingEvent += new ResourceStartedLoadingHandler(ResourceIntercepter_ResourceStartedLoadingEvent);
     browser.ResourceIntercepter.ResourcesSendRequest += new ResourceSendRequestEventHandler(ResourceIntercepter_ResourcesSendRequest);
     browser.ResourceIntercepter.ResourceFailedLoading += new ResourceFailedHandler(ResourceIntercepter_ResourceFailedLoading);
 }
Exemplo n.º 6
0
 public PrintManager(PrintDocument Document, WebKitBrowser Owner)
 {
     this._document = Document;
     this._owner = Owner;
     this._webFramePrivate =
         (IWebFramePrivate)((IWebView)_owner.GetWebView()).mainFrame();
 }
Exemplo n.º 7
0
 public PrintManager(PrintDocument Document, WebKitBrowser Owner)
 {
     this._document        = Document;
     this._owner           = Owner;
     this._webFramePrivate =
         (IWebFramePrivate)((IWebView)_owner.GetWebView()).mainFrame();
 }
Exemplo n.º 8
0
 public BrowserHelper(string path, Control browserContainer, object scriptObject,bool isUrl = false)
 {
     Browser = new WebKitBrowser();
     Browser.Dock = DockStyle.Fill;
     browserContainer.Controls.Add(Browser);
     Browser.GetScriptManager.ScriptObject = scriptObject;//必须在Add到父控件后GetScriptManager才不为空
     Browser.Navigate(isUrl ? path : LocalToUrl(AppDomain.CurrentDomain.BaseDirectory + path));
 }
Exemplo n.º 9
0
 public SourceViewForm(string text, WebKitBrowser current)
 {
     InitializeComponent();
     textBox.Text = text;
     textBox.Select(0, 0);                   /* @@ */
     textBox.ScrollBars = ScrollBars.Both;   /* @@ */
     this.current = current;
 }
Exemplo n.º 10
0
        public JSManagement(WebKitBrowser browser)
        {
            _owner = browser;
            IWebFrame fe = (IWebFrame)browser.webView.mainFrame();

            ScriptObject = new JSCore.JSContext(fe);
            browser.uiDelegate.AddMessageToConsole += new AddMessage(uiDelegate_AddMessageToConsole);
        }
Exemplo n.º 11
0
 public TextContextMenu(WebKitBrowser br)
 {
     this.owner  = br;
     this.Popup += new EventHandler(TextContextMenu_Popup);
     this.MenuItems.Add(LanguageLoader.SearchWithGoogle).Click += new EventHandler(SearchContextMenu_Click);
     this.MenuItems.Add("-");
     this.MenuItems.Add(LanguageLoader.Copy).Click += new EventHandler(CopyContextMenu_Click);
 }
Exemplo n.º 12
0
 public WebPolicyDelegate(bool AllowNavigation, bool AllowDownloads, bool AllowNewWindows, WebKitBrowser owner)
 {
     this.AllowDownloads = AllowDownloads;
     this.AllowNavigation = AllowNavigation;
     this.AllowNewWindows = AllowNewWindows;
     this.Owner = owner;
     AllowInitialNavigation = true;
 }
Exemplo n.º 13
0
 public WebPolicyDelegate(bool AllowNavigation, bool AllowDownloads, bool AllowNewWindows, WebKitBrowser owner)
 {
     this.AllowDownloads    = AllowDownloads;
     this.AllowNavigation   = AllowNavigation;
     this.AllowNewWindows   = AllowNewWindows;
     this.Owner             = owner;
     AllowInitialNavigation = true;
 }
Exemplo n.º 14
0
        public JSManagement(WebKitBrowser browser)
        {
            _owner = browser;
            IWebFrame fe = (IWebFrame)browser.webView.mainFrame();

            ScriptObject = new JSCore.JSContext(fe);
            browser.uiDelegate.AddMessageToConsole += new AddMessage(uiDelegate_AddMessageToConsole);
        }
Exemplo n.º 15
0
 public ContextMenuManager(WebKitBrowser browser)
 {
     this.Owner                  = browser;
     this.BodyMenu               = new BodyContextMenu(browser);
     this.SelectedTextMenu       = new TextContextMenu(browser);
     this.LinkContextMenu        = new LinkContextMenu(browser);
     this.LinkOrImageContextMenu = new LinkAndImageContextMenu(browser);
     this.ImageContextMenu       = new ImageContextMenu(browser);
 }
Exemplo n.º 16
0
 public ImageContextMenu(WebKitBrowser br)
 {
     owner = br;
     this.MenuItems.Add("Open Image").Click += new EventHandler(ImageContextMenu1);
     this.MenuItems.Add("Open Image in New Window").Click += new EventHandler(ImageContextMenu2);
     this.MenuItems.Add("Download Image").Click           += new EventHandler(ImageContextMenu3);
     this.MenuItems.Add("-");
     this.MenuItems.Add("Inspect").Click += new EventHandler(Inspect);
 }
Exemplo n.º 17
0
 void init()
 {
     this.title = System.Configuration.ConfigurationSettings.AppSettings.Get("title");
     this.url   = System.Configuration.ConfigurationSettings.AppSettings.Get("url");
     this.Text  = title;
     browser    = new WebKitBrowser();
     //browser.Dock = DockStyle.Fill;
     //browser.IsScriptingEnabled = true;
     this.Controls.Add(browser);
 }
Exemplo n.º 18
0
 void AddTab(WebKitBrowser browser)
 {
     TabPage tab = new TabPage();
     tab.Controls.Add(browser);
     browser.Name = "WebKitBrowser";
     browser.Dock = DockStyle.Fill;
     tabControl1.Controls.Add(tab);
     tabControl1.SelectedTab = tab;
     AddEvents(browser);
 }
Exemplo n.º 19
0
 public LinkContextMenu(WebKitBrowser br)
 {
     this.owner = br;
     this.MenuItems.Add("Open Link").Click += new EventHandler(LinkContextMenu_Click);
     this.MenuItems.Add("Open Link in New Window").Click += new EventHandler(LinkContextMenu2_Click);
     this.MenuItems.Add("Download Linked File").Click    += new EventHandler(LinkContextMenu3_Click);
     this.MenuItems.Add("Copy Link").Click += new EventHandler(CopyContextMenu_Click);
     this.MenuItems.Add("-");
     this.MenuItems.Add("Inspect").Click += new EventHandler(Inspect);
 }
Exemplo n.º 20
0
 public BrowserHelper(BrowserHelperParam p)
 {
     Browser = new WebKitBrowser();
     Browser.Dock = DockStyle.Fill;
     Browser.Load += (o, e) =>
     {
         Browser.GetScriptManager.ScriptObject = p.ScriptObject;//必须在Add到父控件后GetScriptManager才不为空
     };
     p.Container.Controls.Add(Browser);
     Browser.Navigate(p.GetUrl());
 }
Exemplo n.º 21
0
 void AddTab(string url)
 {
     WebKitBrowser browser = new WebKitBrowser();
     TabPage tab = new TabPage();
     tab.Controls.Add(browser);
     browser.Name = "WebKitBrowser";
     browser.Dock = DockStyle.Fill;
     tabControl1.Controls.Add(tab);
     tabControl1.SelectedTab = tab;
     AddEvents(browser);
     browser.Navigate(url);
 }
Exemplo n.º 22
0
 public BodyContextMenu(WebKitBrowser br)
 {
     this.owner  = br;
     this.Popup += new EventHandler(BodyContextMenu_Popup);
     this.MenuItems.Add(LanguageLoader.NavBack).Click    += new EventHandler(BodyContextMenuBack_Click);
     this.MenuItems.Add(LanguageLoader.NavForward).Click += new EventHandler(BodyContextMenuForward_Click);
     this.MenuItems.Add("-");
     this.MenuItems.Add(LanguageLoader.Reload).Click += new EventHandler(BodyContextMenu_Click);
     this.MenuItems.Add(LanguageLoader.Stop).Click   += new EventHandler(BodyContextMenuStop_Click);
     this.MenuItems.Add("-");
     this.MenuItems.Add(LanguageLoader.ViewSource).Click += new EventHandler(BodyContextMenuStopViewSource_Click);
     this.MenuItems.Add("Inspector").Click += new EventHandler(InspectorContextMenu);
 }
Exemplo n.º 23
0
        public WebBrowserTabPage(WebKitBrowser browserControl, bool goHome)
        {
            InitializeComponent();

            statusStrip = new StatusStrip();
            statusStrip.Name = "statusStrip";
            statusStrip.Visible = true;
            statusStrip.SizingGrip = false;

            container = new ToolStripContainer();
            container.Name = "container";
            container.Visible = true;
            container.Dock = DockStyle.Fill;

            statusLabel = new ToolStripLabel();
            statusLabel.Name = "statusLabel";
            statusLabel.Text = "Done";
            statusLabel.Visible = true;

            iconLabel = new ToolStripLabel();
            iconLabel.Name = "iconLabel";
            iconLabel.Text = "No Icon";
            iconLabel.Visible = true;

            statusStrip.Items.Add(statusLabel);
            statusStrip.Items.Add(iconLabel);

            container.BottomToolStripPanel.Controls.Add(statusStrip);

            // create webbrowser control
            browser = browserControl;
            browser.Visible = true;
            browser.Dock = DockStyle.Fill;
            browser.Name = "browser";
            container.ContentPanel.Controls.Add(browser);

            // context menu

            this.Controls.Add(container);
            this.Text = "<New Tab>";

            // events
            browser.DocumentTitleChanged += (s, e) => this.Text = browser.DocumentTitle;
            browser.Navigating += (s, e) => statusLabel.Text = "Loading...";
            browser.Navigated += (s, e) => { statusLabel.Text = "Downloading..."; };
            browser.DocumentCompleted += (s, e) => { statusLabel.Text = "Done"; };
            if (goHome)
                browser.Navigate("http://www.google.com");
            browser.ApplicationName = "WebKit.NET-test";
        }
Exemplo n.º 24
0
        public void AddTab(WebKitBrowser browser)
        {
            var tabInfo = new TabInfo();
            browser.Dock = DockStyle.Fill;
            browser.Load += (o, e) =>
            {

                browser.GetScriptManager.ScriptObject = new RecordAdapter() { ListBrowser = WebKitBrowser };
            };
            RegisterEvent(tabInfo, browser);

            tabInfo.TabPage.Controls.Add(browser);
            ucTabContainer1.AddTab(tabInfo);
        }
Exemplo n.º 25
0
        public static void RunScript(WebKitBrowser browser, String function, params object[] args)
        {
            Element scriptElm = browser.Document.CreateElement("script");
            StringBuilder sb = new StringBuilder();
            sb.Append(function + "(");
            foreach (object o in args)
            {
                sb.Append("'" + o.ToString() + "', ");
            }
            sb.Remove(sb.Length - 2, 2);
            sb.Append(")");
            Console.WriteLine("Writing: {0}", sb.ToString());
            scriptElm.AppendChild(browser.Document.CreateTextNode(sb.ToString()));

            NodeList headElm = browser.Document.GetElementsByTagName("head");
            headElm[0].AppendChild(scriptElm);
        }
Exemplo n.º 26
0
 private static void RegisterEvent(TabInfo tabInfo, WebKitBrowser browser)
 {
     tabInfo.TabButton.OnDragOut += (t) =>
     {
         t.MoveToNewForm(MousePosition);
     };
     browser.DocumentCompleted += (o, e) =>
     {
         tabInfo.TabButton.UCText = browser.DocumentTitle;
         tabInfo.TabButton.Tip = browser.DocumentTitle;
     };
     browser.NewWindowCreated += (o, e) =>
     {
         FmTabBase.Default.AddTab(e.WebKitBrowser);
         if (!FmTabBase.Default.Visible)
             FmTabBase.Default.Show();
     };
 }
Exemplo n.º 27
0
        private void uiDelegate_CreateWebViewWithRequest(IWebURLRequest request, out WebView webView)
        {
            // Todo: find out why url seems to always be empty
            string url = (request == null) ? "" : request.url();
            NewWindowRequestEventArgs args = new NewWindowRequestEventArgs(url);

            NewWindowRequest(this, args);

            if (!args.Cancel)
            {
                WebKitBrowser b = new WebKitBrowser();
                webView = (WebView)b.webView;
                NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
            }
            else
            {
                webView = null;
            }
        }
Exemplo n.º 28
0
        private void uiDelegate_CreateWebViewWithRequest(IWebURLRequest request, out WebView webView)
        {
            // TODO: find out why url seems to always be empty:
            // https://bugs.webkit.org/show_bug.cgi?id=41441 explains all
            string url = (request == null) ? "" : request.url();
            NewWindowRequestEventArgs args = new NewWindowRequestEventArgs(url);

            NewWindowRequest(this, args);

            if (!args.Cancel)
            {
                WebKitBrowser b = new WebKitBrowser();
                webView = (WebView)b.webView;
                NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
            }
            else
            {
                webView = null;
            }
        }
Exemplo n.º 29
0
        public WebBrowserPageView(int type, int webBrowserType = 0)
        {
            InitializeComponent();

            if (type == 1)
            {
                serverIndexPage  = CompnayIndexPage;
                lblTitle.Content = "公司介绍";
            }
            else
            {
                serverIndexPage  = SchoolIndexPage;
                lblTitle.Content = "校园介绍";
            }

            //默认WebBrowser
            if (webBrowserType == 0)
            {
                webBrowser = new System.Windows.Forms.WebBrowser();
                webBrowser.ObjectForScripting     = new WebBrowserCallbackClass();
                webBrowser.ScriptErrorsSuppressed = true;
                webBrowser.Navigate(serverIndexPage);

                windowsFormsHost.Child = webBrowser;
                grdBrowserHost.Children.Add(windowsFormsHost);
            }
            else
            {
                kitBrowser = new WebKit.WebKitBrowser();
                kitBrowser.Navigate(serverIndexPage);
                windowsFormsHost.Child = kitBrowser;
                grdBrowserHost.Children.Add(windowsFormsHost);

                kitBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(kitBrowser_DocumentCompleted);
            }

            if (System.Configuration.ConfigurationManager.AppSettings["IsDev"] == "true")
            {
                this.Topmost = false;
            }
        }
Exemplo n.º 30
0
        public MainForm(string url, string tmpname)
        {
            InitializeComponent();

            browser = new WebKitBrowser();
            browser.Visible = true;
            browser.Dock = DockStyle.Fill;
            browser.Name = "browser";
            browser.IsWebBrowserContextMenuEnabled = false;
            browser.IsScriptingEnabled = false;

            Controls.Add(browser);
            RegisterBrowserEvents();

            fsw = new FileSystemWatcher(Path.GetDirectoryName(tmpname));
            fsw.Created += new FileSystemEventHandler(fsw_Created);
            fsw.EnableRaisingEvents = true;
            temp_file_name = tmpname;

            browser.Navigate(url);
            browser.Focus();
        }
Exemplo n.º 31
0
 public ResourcesIntercepter(WebKitBrowser browser)
 {
     this.Owner = browser;
     Resources = new List<WebKitResource>();
 }
 public WebResourceLoadDelegate(WebKitBrowser o)
 {
     Owner = o;
 }
Exemplo n.º 33
0
        private void uiDelegate_CreateWebViewWithRequest(IWebURLRequest request, out WebView webView)
        {
            // Todo: find out why url seems to always be empty
            string url = (request == null) ? "" : request.url();
            NewWindowRequestEventArgs args = new NewWindowRequestEventArgs(url);
            NewWindowRequest(this, args);

            if (!args.Cancel)
            {
                WebKitBrowser b = new WebKitBrowser();
                webView = (WebView) b.webView;
                NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
            }
            else
            {
                webView = null;
            }
        }
Exemplo n.º 34
0
 public WebFormDelegate(WebKitBrowser owner)
 {
     this._browser = owner;
 }
Exemplo n.º 35
0
        private void uiDelegate_CreateWebViewWithRequest(IWebURLRequest request, out WebView webView)
        {
            // TODO: find out why url seems to always be empty:
            // https://bugs.webkit.org/show_bug.cgi?id=41441 explains all
            string url = (request == null) ? "" : request.url();
            NewWindowRequestEventArgs args = new NewWindowRequestEventArgs(url);
            NewWindowRequest(this, args);

            if (!args.Cancel)
            {
                WebKitBrowser b = new WebKitBrowser();
                webView = (WebView) b.webView;
                NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
            }
            else
            {
                webView = null;
            }
        }
Exemplo n.º 36
0
 public GlobalPreferences(WebKitBrowser Browser)
 {
     WebKitBrowser.activationContext.Activate();
     this.browser = Browser;
     WebKitBrowser.activationContext.Deactivate();
 }
Exemplo n.º 37
0
 public WebUIDelegate(WebKitBrowser browser)
 {
     this.owner = browser;
 }
Exemplo n.º 38
0
 public WebDownloadDelegate(WebKitBrowser browser)
 {
     this.parent = browser;
 }
Exemplo n.º 39
0
 public WebUIDelegate(WebKitBrowser browser)
 {
     this.owner = browser;
 }
Exemplo n.º 40
0
 public WebEditingDelegate(WebKitBrowser browser)
 {
     this.owner = browser;
 }
 public WebResourceLoadDelegate(WebKitBrowser o)
 {
     Owner = o;
 }
Exemplo n.º 42
0
 public WebFormDelegate(WebKitBrowser owner)
 {
     this._browser = owner;
 }
 public WebDownloadDelegate(WebKitBrowser browser)
 {
     this.parent = browser;
 }
 /// <summary>
 /// Initializes a new instance of the NewWindowCreatedEventArgs class.
 /// </summary>
 /// <param name="browser">The WebKitBrowser showing the contents of the new window.</param>
 public NewWindowCreatedEventArgs(WebKitBrowser browser)
 {
     WebKitBrowser = browser;
 }
Exemplo n.º 45
0
 public ResourcesIntercepter(WebKitBrowser browser)
 {
     this.Owner = browser;
     Resources  = new List <WebKitResource>();
 }
Exemplo n.º 46
0
 public SourceViewForm(string text, WebKitBrowser current)
 {
     InitializeComponent();
     textBox.Text = text;
     this.current = current;
 }
Exemplo n.º 47
0
 public GlobalPreferences(WebKitBrowser Browser)
 {
     WebKitBrowser.activationContext.Activate();
     this.browser = Browser;
     WebKitBrowser.activationContext.Deactivate();
 }
Exemplo n.º 48
0
 /// <summary>
 /// Initializes a new instance of the NewWindowCreatedEventArgs class.
 /// </summary>
 /// <param name="browser">The WebKitBrowser showing the contents of the new window.</param>
 public NewWindowCreatedEventArgs(WebKitBrowser browser)
 {
     WebKitBrowser = browser;
 }
Exemplo n.º 49
0
 public WebEditingDelegate(WebKitBrowser browser)
 {
     this.owner = browser;
 }
Exemplo n.º 50
0
 private void uiDelegate_CreateWebViewWithRequest(IWebURLRequest request, out WebView webView, bool popup = false)
 {
     WebKitBrowser b = new WebKitBrowser();
     if (request != null)
     {
         if (!string.IsNullOrEmpty(request.url()))
             b.Navigate(request.url());
     }
     webView = (WebView) b.webView;
     string url = newwindowurl;
     if (string.IsNullOrEmpty(newwindowurl) && request != null)
         url = request.url();
     
     NewWindowRequestEventArgs args = new NewWindowRequestEventArgs(url);
     if (popup == true)
     {
         PopupCreated(this, new NewWindowCreatedEventArgs(b));
     }
     else
     {
         NewWindowRequest(this, args);
         NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
     }
     //if (this.Focused == false || ElementAtPoint(this.PointToClient(Cursor.Current.HotSpot)).Type == ElementType.Body || (GetCurrentElement().Type != ElementType.LinkOrUknown || GetCurrentElement().TagName == "BODY" || GetCurrentElement().TagName == "IFRAME" || GetCurrentElement() == null && GetCurrentElement().TagName != "OBJECT"))
     //    {
     //        PopupCreated(this, new NewWindowCreatedEventArgs(b));
     //    }
     //    else
     //    {
     //        NewWindowRequest(this, args);
     //        NewWindowCreated(this, new NewWindowCreatedEventArgs(b));
     //    }
 }
Exemplo n.º 51
0
        public WebBrowserTabPage(WebKitBrowser browserControl, bool goHome)
        {
            InitializeComponent();

            statusStrip = new StatusStrip();
            statusStrip.Name = "statusStrip";
            statusStrip.Visible = true;
            statusStrip.SizingGrip = false;

            container = new ToolStripContainer();
            container.Name = "container";
            container.Visible = true;
            container.Dock = DockStyle.Fill;

            statusLabel = new ToolStripLabel();
            statusLabel.Name = "statusLabel";
            statusLabel.Text = "Done";
            statusLabel.Visible = true;

            iconLabel = new ToolStripLabel();
            iconLabel.Name = "iconLabel";
            iconLabel.Text = "No Icon";
            iconLabel.Visible = true;

            progressBar = new ToolStripProgressBar();
            progressBar.Name = "progressBar";
            progressBar.Visible = true;

            statusStrip.Items.Add(statusLabel);
            statusStrip.Items.Add(iconLabel);
            statusStrip.Items.Add(progressBar);

            container.BottomToolStripPanel.Controls.Add(statusStrip);

            // create webbrowser control
            browser = browserControl;
            browser.Visible = true;
            browser.Dock = DockStyle.Fill;
            browser.Name = "browser";
            //browser.IsWebBrowserContextMenuEnabled = false;
            //browser.IsScriptingEnabled = false;
            container.ContentPanel.Controls.Add(browser);

            browser.ObjectForScripting = new TestScriptObject();

            // context menu

            this.Controls.Add(container);
            this.Text = "<New Tab>";

            // events
            browser.DocumentTitleChanged += (s, e) => this.Text = browser.DocumentTitle;
            browser.Navigating += (s, e) => statusLabel.Text = "Loading...";
            browser.Navigated += (s, e) => { statusLabel.Text = "Downloading..."; };
            browser.DocumentCompleted += (s, e) => { statusLabel.Text = "Done"; };
            browser.ProgressStarted += (s, e) => { progressBar.Visible = true; };
            browser.ProgressChanged += (s, e) => { progressBar.Value = e.ProgressPercentage; };
            browser.ProgressFinished += (s, e) => { progressBar.Visible = false; };
            if (goHome)
                browser.Navigate("http://www.google.com");

            browser.ShowJavaScriptAlertPanel += (s, e) => MessageBox.Show(e.Message, "[JavaScript Alert]");
            browser.ShowJavaScriptConfirmPanel += (s, e) =>
            {
                e.ReturnValue = MessageBox.Show(e.Message, "[JavaScript Confirm]", MessageBoxButtons.YesNo) == DialogResult.Yes;
            };
            browser.ShowJavaScriptPromptPanel += (s, e) =>
            {
                var frm = new JSPromptForm(e.Message, e.DefaultValue);
                if (frm.ShowDialog() == DialogResult.OK)
                    e.ReturnValue = frm.Value;
            };
        }