mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
First run at implementing TabControl
This commit is contained in:
+23
-191
@@ -29,18 +29,6 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BrowserForm));
|
||||
this.toolStripContainer = new System.Windows.Forms.ToolStripContainer();
|
||||
this.toolStrip2 = new System.Windows.Forms.ToolStrip();
|
||||
this.findTextBox = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.findPreviousButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.findNextButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.findCloseButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.outputLabel = new System.Windows.Forms.Label();
|
||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||
this.backButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.forwardButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.urlTextBox = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.goButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -60,152 +48,10 @@
|
||||
this.selectAllMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.copySourceToClipBoardAsyncMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripContainer.BottomToolStripPanel.SuspendLayout();
|
||||
this.toolStripContainer.ContentPanel.SuspendLayout();
|
||||
this.toolStripContainer.TopToolStripPanel.SuspendLayout();
|
||||
this.toolStripContainer.SuspendLayout();
|
||||
this.toolStrip2.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
this.browserTabControl = new System.Windows.Forms.TabControl();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// toolStripContainer
|
||||
//
|
||||
//
|
||||
// toolStripContainer.BottomToolStripPanel
|
||||
//
|
||||
this.toolStripContainer.BottomToolStripPanel.Controls.Add(this.toolStrip2);
|
||||
//
|
||||
// toolStripContainer.ContentPanel
|
||||
//
|
||||
this.toolStripContainer.ContentPanel.Controls.Add(this.outputLabel);
|
||||
this.toolStripContainer.ContentPanel.Size = new System.Drawing.Size(730, 416);
|
||||
this.toolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.toolStripContainer.LeftToolStripPanelVisible = false;
|
||||
this.toolStripContainer.Location = new System.Drawing.Point(0, 24);
|
||||
this.toolStripContainer.Name = "toolStripContainer";
|
||||
this.toolStripContainer.RightToolStripPanelVisible = false;
|
||||
this.toolStripContainer.Size = new System.Drawing.Size(730, 466);
|
||||
this.toolStripContainer.TabIndex = 0;
|
||||
this.toolStripContainer.Text = "toolStripContainer1";
|
||||
//
|
||||
// toolStripContainer.TopToolStripPanel
|
||||
//
|
||||
this.toolStripContainer.TopToolStripPanel.Controls.Add(this.toolStrip1);
|
||||
//
|
||||
// toolStrip2
|
||||
//
|
||||
this.toolStrip2.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.toolStrip2.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.findTextBox,
|
||||
this.findPreviousButton,
|
||||
this.findNextButton,
|
||||
this.findCloseButton});
|
||||
this.toolStrip2.Location = new System.Drawing.Point(3, 0);
|
||||
this.toolStrip2.Name = "toolStrip2";
|
||||
this.toolStrip2.Size = new System.Drawing.Size(205, 25);
|
||||
this.toolStrip2.TabIndex = 0;
|
||||
//
|
||||
// findTextBox
|
||||
//
|
||||
this.findTextBox.Name = "findTextBox";
|
||||
this.findTextBox.Size = new System.Drawing.Size(100, 25);
|
||||
this.findTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FindTextBoxKeyDown);
|
||||
//
|
||||
// findPreviousButton
|
||||
//
|
||||
this.findPreviousButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.findPreviousButton.Image = global::CefSharp.WinForms.Example.Properties.Resources.nav_left_green;
|
||||
this.findPreviousButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.findPreviousButton.Name = "findPreviousButton";
|
||||
this.findPreviousButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.findPreviousButton.Text = "Find Previous";
|
||||
this.findPreviousButton.Click += new System.EventHandler(this.FindPreviousButtonClick);
|
||||
//
|
||||
// findNextButton
|
||||
//
|
||||
this.findNextButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.findNextButton.Image = global::CefSharp.WinForms.Example.Properties.Resources.nav_right_green;
|
||||
this.findNextButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.findNextButton.Name = "findNextButton";
|
||||
this.findNextButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.findNextButton.Text = "Find Next";
|
||||
this.findNextButton.Click += new System.EventHandler(this.FindNextButtonClick);
|
||||
//
|
||||
// findCloseButton
|
||||
//
|
||||
this.findCloseButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
|
||||
this.findCloseButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
|
||||
this.findCloseButton.Font = new System.Drawing.Font("Segoe UI", 8F, System.Drawing.FontStyle.Bold);
|
||||
this.findCloseButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.findCloseButton.Name = "findCloseButton";
|
||||
this.findCloseButton.Size = new System.Drawing.Size(23, 22);
|
||||
this.findCloseButton.Text = "X";
|
||||
this.findCloseButton.Click += new System.EventHandler(this.FindCloseButtonClick);
|
||||
//
|
||||
// outputLabel
|
||||
//
|
||||
this.outputLabel.AutoSize = true;
|
||||
this.outputLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.outputLabel.Location = new System.Drawing.Point(0, 403);
|
||||
this.outputLabel.Name = "outputLabel";
|
||||
this.outputLabel.Size = new System.Drawing.Size(0, 13);
|
||||
this.outputLabel.TabIndex = 0;
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.backButton,
|
||||
this.forwardButton,
|
||||
this.urlTextBox,
|
||||
this.goButton});
|
||||
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.toolStrip1.Name = "toolStrip1";
|
||||
this.toolStrip1.Padding = new System.Windows.Forms.Padding(0);
|
||||
this.toolStrip1.Size = new System.Drawing.Size(730, 25);
|
||||
this.toolStrip1.Stretch = true;
|
||||
this.toolStrip1.TabIndex = 0;
|
||||
this.toolStrip1.Layout += new System.Windows.Forms.LayoutEventHandler(this.HandleToolStripLayout);
|
||||
//
|
||||
// backButton
|
||||
//
|
||||
this.backButton.Enabled = false;
|
||||
this.backButton.Image = global::CefSharp.WinForms.Example.Properties.Resources.nav_left_green;
|
||||
this.backButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.backButton.Name = "backButton";
|
||||
this.backButton.Size = new System.Drawing.Size(52, 22);
|
||||
this.backButton.Text = "Back";
|
||||
this.backButton.Click += new System.EventHandler(this.BackButtonClick);
|
||||
//
|
||||
// forwardButton
|
||||
//
|
||||
this.forwardButton.Enabled = false;
|
||||
this.forwardButton.Image = global::CefSharp.WinForms.Example.Properties.Resources.nav_right_green;
|
||||
this.forwardButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.forwardButton.Name = "forwardButton";
|
||||
this.forwardButton.Size = new System.Drawing.Size(70, 22);
|
||||
this.forwardButton.Text = "Forward";
|
||||
this.forwardButton.Click += new System.EventHandler(this.ForwardButtonClick);
|
||||
//
|
||||
// urlTextBox
|
||||
//
|
||||
this.urlTextBox.AutoSize = false;
|
||||
this.urlTextBox.Name = "urlTextBox";
|
||||
this.urlTextBox.Size = new System.Drawing.Size(500, 25);
|
||||
this.urlTextBox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.UrlTextBoxKeyUp);
|
||||
//
|
||||
// goButton
|
||||
//
|
||||
this.goButton.Image = global::CefSharp.WinForms.Example.Properties.Resources.nav_plain_green;
|
||||
this.goButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.goButton.Name = "goButton";
|
||||
this.goButton.Size = new System.Drawing.Size(42, 22);
|
||||
this.goButton.Text = "Go";
|
||||
this.goButton.Click += new System.EventHandler(this.GoButtonClick);
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
@@ -283,92 +129,89 @@
|
||||
// undoMenuItem
|
||||
//
|
||||
this.undoMenuItem.Name = "undoMenuItem";
|
||||
this.undoMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.undoMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.undoMenuItem.Text = "Undo";
|
||||
//
|
||||
// redoMenuItem
|
||||
//
|
||||
this.redoMenuItem.Name = "redoMenuItem";
|
||||
this.redoMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.redoMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.redoMenuItem.Text = "Redo";
|
||||
//
|
||||
// findMenuItem
|
||||
//
|
||||
this.findMenuItem.Name = "findMenuItem";
|
||||
this.findMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.findMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.findMenuItem.Text = "Find";
|
||||
this.findMenuItem.Click += new System.EventHandler(this.FindMenuItemClick);
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(119, 6);
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(248, 6);
|
||||
//
|
||||
// cutMenuItem
|
||||
//
|
||||
this.cutMenuItem.Name = "cutMenuItem";
|
||||
this.cutMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.cutMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.cutMenuItem.Text = "Cut";
|
||||
//
|
||||
// copyMenuItem
|
||||
//
|
||||
this.copyMenuItem.Name = "copyMenuItem";
|
||||
this.copyMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.copyMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.copyMenuItem.Text = "Copy";
|
||||
//
|
||||
// pasteMenuItem
|
||||
//
|
||||
this.pasteMenuItem.Name = "pasteMenuItem";
|
||||
this.pasteMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.pasteMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.pasteMenuItem.Text = "Paste";
|
||||
//
|
||||
// deleteMenuItem
|
||||
//
|
||||
this.deleteMenuItem.Name = "deleteMenuItem";
|
||||
this.deleteMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.deleteMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.deleteMenuItem.Text = "Delete";
|
||||
//
|
||||
// selectAllMenuItem
|
||||
//
|
||||
this.selectAllMenuItem.Name = "selectAllMenuItem";
|
||||
this.selectAllMenuItem.Size = new System.Drawing.Size(122, 22);
|
||||
this.selectAllMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.selectAllMenuItem.Text = "Select All";
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(242, 6);
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(248, 6);
|
||||
//
|
||||
// copySourceToClipBoardAsyncMenuItem
|
||||
//
|
||||
this.copySourceToClipBoardAsyncMenuItem.Name = "copySourceToClipBoardAsyncMenuItem";
|
||||
this.copySourceToClipBoardAsyncMenuItem.Size = new System.Drawing.Size(245, 22);
|
||||
this.copySourceToClipBoardAsyncMenuItem.Size = new System.Drawing.Size(251, 22);
|
||||
this.copySourceToClipBoardAsyncMenuItem.Text = "Copy Source to Clipboard (async)";
|
||||
this.copySourceToClipBoardAsyncMenuItem.Click += new System.EventHandler(this.CopySourceToClipBoardAsyncClick);
|
||||
//
|
||||
// browserTabControl
|
||||
//
|
||||
this.browserTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.browserTabControl.Location = new System.Drawing.Point(0, 24);
|
||||
this.browserTabControl.Name = "browserTabControl";
|
||||
this.browserTabControl.SelectedIndex = 0;
|
||||
this.browserTabControl.Size = new System.Drawing.Size(730, 466);
|
||||
this.browserTabControl.TabIndex = 2;
|
||||
//
|
||||
// BrowserForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(730, 490);
|
||||
this.Controls.Add(this.toolStripContainer);
|
||||
this.Controls.Add(this.browserTabControl);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "BrowserForm";
|
||||
this.Text = "BrowserForm";
|
||||
this.toolStripContainer.BottomToolStripPanel.ResumeLayout(false);
|
||||
this.toolStripContainer.BottomToolStripPanel.PerformLayout();
|
||||
this.toolStripContainer.ContentPanel.ResumeLayout(false);
|
||||
this.toolStripContainer.ContentPanel.PerformLayout();
|
||||
this.toolStripContainer.TopToolStripPanel.ResumeLayout(false);
|
||||
this.toolStripContainer.TopToolStripPanel.PerformLayout();
|
||||
this.toolStripContainer.ResumeLayout(false);
|
||||
this.toolStripContainer.PerformLayout();
|
||||
this.toolStrip2.ResumeLayout(false);
|
||||
this.toolStrip2.PerformLayout();
|
||||
this.toolStrip1.ResumeLayout(false);
|
||||
this.toolStrip1.PerformLayout();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
@@ -378,17 +221,10 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ToolStripContainer toolStripContainer;
|
||||
private System.Windows.Forms.ToolStrip toolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton backButton;
|
||||
private System.Windows.Forms.ToolStripButton forwardButton;
|
||||
private System.Windows.Forms.ToolStripTextBox urlTextBox;
|
||||
private System.Windows.Forms.ToolStripButton goButton;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
|
||||
private System.Windows.Forms.Label outputLabel;
|
||||
private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem undoMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem redoMenuItem;
|
||||
@@ -401,14 +237,10 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem showDevToolsMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeDevToolsMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
|
||||
private System.Windows.Forms.ToolStrip toolStrip2;
|
||||
private System.Windows.Forms.ToolStripButton findPreviousButton;
|
||||
private System.Windows.Forms.ToolStripTextBox findTextBox;
|
||||
private System.Windows.Forms.ToolStripButton findNextButton;
|
||||
private System.Windows.Forms.ToolStripButton findCloseButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem findMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripMenuItem copySourceToClipBoardAsyncMenuItem;
|
||||
private System.Windows.Forms.TabControl browserTabControl;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,13 @@
|
||||
// Copyright © 2010-2014 The CefSharp Authors. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
using CefSharp.Example;
|
||||
using CefSharp.WinForms.Example.Controls;
|
||||
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.using CefSharp.Example;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CefSharp.WinForms.Example
|
||||
{
|
||||
public partial class BrowserForm : Form
|
||||
{
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
|
||||
public BrowserForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -23,216 +17,59 @@ namespace CefSharp.WinForms.Example
|
||||
Text = "CefSharp";
|
||||
WindowState = FormWindowState.Maximized;
|
||||
|
||||
browser = new ChromiumWebBrowser(CefExample.DefaultUrl)
|
||||
AddTab(CefExample.DefaultUrl);
|
||||
}
|
||||
|
||||
private void AddTab(string url)
|
||||
{
|
||||
var browser = new BrowserTabUserControl
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
};
|
||||
toolStripContainer.ContentPanel.Controls.Add(browser);
|
||||
|
||||
browser.DownloadHandler = new DownloadHandler();
|
||||
browser.MenuHandler = new MenuHandler();
|
||||
browser.NavStateChanged += OnBrowserNavStateChanged;
|
||||
browser.ConsoleMessage += OnBrowserConsoleMessage;
|
||||
browser.TitleChanged += OnBrowserTitleChanged;
|
||||
browser.AddressChanged += OnBrowserAddressChanged;
|
||||
|
||||
var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
|
||||
DisplayOutput(version);
|
||||
var tabPage = new TabPage(url)
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
tabPage.Controls.Add(browser);
|
||||
browserTabControl.Controls.Add(tabPage);
|
||||
}
|
||||
|
||||
private void BrowserFormLoad(object sender, EventArgs e)
|
||||
{
|
||||
ToggleBottomToolStrip();
|
||||
}
|
||||
|
||||
private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args)
|
||||
{
|
||||
DisplayOutput(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message));
|
||||
}
|
||||
|
||||
private void OnBrowserNavStateChanged(object sender, NavStateChangedEventArgs args)
|
||||
{
|
||||
SetCanGoBack(args.CanGoBack);
|
||||
SetCanGoForward(args.CanGoForward);
|
||||
|
||||
this.InvokeOnUiThreadIfRequired(() => SetIsLoading(!args.CanReload));
|
||||
}
|
||||
|
||||
private void OnBrowserTitleChanged(object sender, TitleChangedEventArgs args)
|
||||
{
|
||||
this.InvokeOnUiThreadIfRequired(() => Text = args.Title);
|
||||
}
|
||||
|
||||
private void OnBrowserAddressChanged(object sender, AddressChangedEventArgs args)
|
||||
{
|
||||
this.InvokeOnUiThreadIfRequired(() => urlTextBox.Text = args.Address);
|
||||
}
|
||||
|
||||
private void SetCanGoBack(bool canGoBack)
|
||||
{
|
||||
this.InvokeOnUiThreadIfRequired(() => backButton.Enabled = canGoBack);
|
||||
}
|
||||
|
||||
private void SetCanGoForward(bool canGoForward)
|
||||
{
|
||||
this.InvokeOnUiThreadIfRequired(() => forwardButton.Enabled = canGoForward);
|
||||
}
|
||||
|
||||
private void SetIsLoading(bool isLoading)
|
||||
{
|
||||
goButton.Text = isLoading ?
|
||||
"Stop" :
|
||||
"Go";
|
||||
goButton.Image = isLoading ?
|
||||
Properties.Resources.nav_plain_red :
|
||||
Properties.Resources.nav_plain_green;
|
||||
|
||||
HandleToolStripLayout();
|
||||
}
|
||||
|
||||
public void ExecuteScript(string script)
|
||||
{
|
||||
browser.ExecuteScriptAsync(script);
|
||||
}
|
||||
|
||||
public object EvaluateScript(string script)
|
||||
{
|
||||
return browser.EvaluateScript(script);
|
||||
}
|
||||
|
||||
public void DisplayOutput(string output)
|
||||
{
|
||||
this.InvokeOnUiThreadIfRequired(() => outputLabel.Text = output);
|
||||
}
|
||||
|
||||
private void HandleToolStripLayout(object sender, LayoutEventArgs e)
|
||||
{
|
||||
HandleToolStripLayout();
|
||||
}
|
||||
|
||||
private void HandleToolStripLayout()
|
||||
{
|
||||
var width = toolStrip1.Width;
|
||||
foreach (ToolStripItem item in toolStrip1.Items)
|
||||
{
|
||||
if (item != urlTextBox)
|
||||
{
|
||||
width -= item.Width - item.Margin.Horizontal;
|
||||
}
|
||||
}
|
||||
urlTextBox.Width = Math.Max(0, width - urlTextBox.Margin.Horizontal - 18);
|
||||
|
||||
}
|
||||
|
||||
private void ExitMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
browser.Dispose();
|
||||
Cef.Shutdown();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void GoButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
LoadUrl(urlTextBox.Text);
|
||||
}
|
||||
|
||||
private void BackButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
browser.Back();
|
||||
}
|
||||
|
||||
private void ForwardButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
browser.Forward();
|
||||
}
|
||||
|
||||
private void UrlTextBoxKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode != Keys.Enter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LoadUrl(urlTextBox.Text);
|
||||
}
|
||||
|
||||
private void LoadUrl(string url)
|
||||
{
|
||||
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
|
||||
{
|
||||
browser.Load(url);
|
||||
}
|
||||
}
|
||||
|
||||
private void AboutToolStripMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
new AboutBox().ShowDialog();
|
||||
}
|
||||
|
||||
private void FindCloseButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
ToggleBottomToolStrip();
|
||||
}
|
||||
|
||||
private void FindMenuItemClick(object sender, EventArgs e)
|
||||
{
|
||||
ToggleBottomToolStrip();
|
||||
|
||||
}
|
||||
|
||||
private void ToggleBottomToolStrip()
|
||||
{
|
||||
if (toolStripContainer.BottomToolStripPanelVisible)
|
||||
{
|
||||
browser.StopFinding(true);
|
||||
toolStripContainer.BottomToolStripPanelVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripContainer.BottomToolStripPanelVisible = true;
|
||||
findTextBox.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void FindNextButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
Find(true);
|
||||
}
|
||||
|
||||
private void FindPreviousButtonClick(object sender, EventArgs e)
|
||||
{
|
||||
Find(false);
|
||||
}
|
||||
|
||||
private void Find(bool next)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(findTextBox.Text))
|
||||
{
|
||||
browser.Find(0, findTextBox.Text, next, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindTextBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode != Keys.Enter)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Find(true);
|
||||
}
|
||||
|
||||
private void CopySourceToClipBoardAsyncClick(object sender, EventArgs e)
|
||||
{
|
||||
var task = browser.GetSourceAsync();
|
||||
//var task = browser.GetSourceAsync();
|
||||
|
||||
task.ContinueWith(t =>
|
||||
{
|
||||
if (!t.IsFaulted)
|
||||
{
|
||||
Clipboard.SetText(t.Result);
|
||||
DisplayOutput("HTML Source copied to clipboard");
|
||||
}
|
||||
},
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
//task.ContinueWith(t =>
|
||||
//{
|
||||
// if (!t.IsFaulted)
|
||||
// {
|
||||
// Clipboard.SetText(t.Result);
|
||||
// DisplayOutput("HTML Source copied to clipboard");
|
||||
// }
|
||||
//},
|
||||
//TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>237, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>122, 17</value>
|
||||
</metadata>
|
||||
|
||||
Reference in New Issue
Block a user