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

            //IWebView wv = (IWebView)browserControl.GetWebView();

            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 TestClass();

            // 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)
            {
                string appPath  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                string htmlPath = Path.Combine(appPath, "index.html");
                browser.Navigate(Uri.EscapeUriString(new Uri(htmlPath).ToString()));
            }
            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;
                }
            };

            /* {@@} */
            if (!browser.IsWebBrowserContextMenuEnabled)
            {
                CreateContextMenu();
                // ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
                browser.ContextMenuOpen += new EventHandler(ContextMenuStrip_Opening2);
            }
            /* {@@} */
        }
        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;
                }
            };
        }
        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;
            };
        }
示例#4
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

            //IWebView wv = (IWebView)browserControl.GetWebView();

            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 TestClass();

            // 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)
            {
                string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                string htmlPath = Path.Combine(appPath, "index.html");
                browser.Navigate(Uri.EscapeUriString(new Uri(htmlPath).ToString()));
            }
            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;
            };

            /* {@@} */
            if (!browser.IsWebBrowserContextMenuEnabled)
            {
                CreateContextMenu();
             // ContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(ContextMenuStrip_Opening);
                browser.ContextMenuOpen += new EventHandler(ContextMenuStrip_Opening2);
            }
            /* {@@} */
        }