diff --git a/CefSharp.WinForms.Example/BrowserForm.Designer.cs b/CefSharp.WinForms.Example/BrowserForm.Designer.cs
index 56e15ba65..9d130463c 100644
--- a/CefSharp.WinForms.Example/BrowserForm.Designer.cs
+++ b/CefSharp.WinForms.Example/BrowserForm.Designer.cs
@@ -29,24 +29,13 @@
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.statusLabel = new System.Windows.Forms.Label();
- 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.newTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.closeTabToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.showDevToolsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.closeDevToolsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -61,162 +50,11 @@
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.closeDevToolsMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
- // toolStripContainer
- //
- //
- // toolStripContainer.BottomToolStripPanel
- //
- this.toolStripContainer.BottomToolStripPanel.Controls.Add(this.toolStrip2);
- //
- // toolStripContainer.ContentPanel
- //
- this.toolStripContainer.ContentPanel.Controls.Add(this.statusLabel);
- 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);
- //
- // statusLabel
- //
- this.statusLabel.AutoSize = true;
- this.statusLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
- this.statusLabel.Location = new System.Drawing.Point(0, 403);
- this.statusLabel.Name = "statusLabel";
- this.statusLabel.Size = new System.Drawing.Size(0, 13);
- this.statusLabel.TabIndex = 1;
- //
- // 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[] {
@@ -231,6 +69,9 @@
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.newTabToolStripMenuItem,
+ this.closeTabToolStripMenuItem,
+ this.printToolStripMenuItem,
this.aboutToolStripMenuItem,
this.showDevToolsMenuItem,
this.closeDevToolsMenuItem,
@@ -240,6 +81,27 @@
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
+ // newTabToolStripMenuItem
+ //
+ this.newTabToolStripMenuItem.Name = "newTabToolStripMenuItem";
+ this.newTabToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
+ this.newTabToolStripMenuItem.Text = "&New Tab";
+ this.newTabToolStripMenuItem.Click += new System.EventHandler(this.NewTabToolStripMenuItemClick);
+ //
+ // closeTabToolStripMenuItem
+ //
+ this.closeTabToolStripMenuItem.Name = "closeTabToolStripMenuItem";
+ this.closeTabToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
+ this.closeTabToolStripMenuItem.Text = "&Close Tab";
+ this.closeTabToolStripMenuItem.Click += new System.EventHandler(this.CloseTabToolStripMenuItemClick);
+ //
+ // printToolStripMenuItem
+ //
+ this.printToolStripMenuItem.Name = "printToolStripMenuItem";
+ this.printToolStripMenuItem.Size = new System.Drawing.Size(158, 22);
+ this.printToolStripMenuItem.Text = "&Print";
+ this.printToolStripMenuItem.Click += new System.EventHandler(this.PrintToolStripMenuItemClick);
+ //
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
@@ -294,92 +156,103 @@
// 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";
+ this.undoMenuItem.Click += new System.EventHandler(this.UndoMenuItemClick);
//
// 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";
+ this.redoMenuItem.Click += new System.EventHandler(this.RedoMenuItemClick);
//
// 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";
+ this.cutMenuItem.Click += new System.EventHandler(this.CutMenuItemClick);
//
// 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";
+ this.copyMenuItem.Click += new System.EventHandler(this.CopyMenuItemClick);
//
// 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";
+ this.pasteMenuItem.Click += new System.EventHandler(this.PasteMenuItemClick);
//
// 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";
+ this.deleteMenuItem.Click += new System.EventHandler(this.DeleteMenuItemClick);
//
// 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";
+ this.selectAllMenuItem.Click += new System.EventHandler(this.SelectAllMenuItemClick);
//
// 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;
+ //
+ // closeDevToolsMenuItem
+ //
+ this.closeDevToolsMenuItem.Name = "closeDevToolsMenuItem";
+ this.closeDevToolsMenuItem.Size = new System.Drawing.Size(158, 22);
+ this.closeDevToolsMenuItem.Text = "Close Dev Tools";
+ this.closeDevToolsMenuItem.Click += new System.EventHandler(this.CloseDevToolsMenuItemClick);
+ //
// 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);
@@ -389,17 +262,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;
@@ -410,17 +276,15 @@
private System.Windows.Forms.ToolStripMenuItem selectAllMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
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.Label statusLabel;
+ private System.Windows.Forms.TabControl browserTabControl;
+ private System.Windows.Forms.ToolStripMenuItem newTabToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem closeTabToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem printToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem closeDevToolsMenuItem;
}
}
\ No newline at end of file
diff --git a/CefSharp.WinForms.Example/BrowserForm.cs b/CefSharp.WinForms.Example/BrowserForm.cs
index e4545a20b..969ab0e8f 100644
--- a/CefSharp.WinForms.Example/BrowserForm.cs
+++ b/CefSharp.WinForms.Example/BrowserForm.cs
@@ -2,253 +2,224 @@
//
// 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;
using System;
-using System.Threading.Tasks;
using System.Windows.Forms;
+using CefSharp.Example;
namespace CefSharp.WinForms.Example
{
public partial class BrowserForm : Form
{
- private readonly ChromiumWebBrowser browser;
+ private const string DefaultUrlForAddedTabs = "https://www.google.com";
public BrowserForm()
{
InitializeComponent();
- Load += BrowserFormLoad;
-
Text = "CefSharp";
WindowState = FormWindowState.Maximized;
- browser = new ChromiumWebBrowser(CefExample.DefaultUrl)
+ AddTab(CefExample.DefaultUrl);
+ }
+
+ private void AddTab(string url, int? insertIndex = null)
+ {
+ browserTabControl.SuspendLayout();
+
+ var browser = new BrowserTabUserControl(url)
{
Dock = DockStyle.Fill,
};
- toolStripContainer.ContentPanel.Controls.Add(browser);
- browser.DownloadHandler = new DownloadHandler();
- browser.MenuHandler = new MenuHandler();
- browser.NavStateChanged += OnBrowserNavStateChanged;
- browser.ConsoleMessage += OnBrowserConsoleMessage;
- browser.StatusMessage += OnBrowserStatusMessage;
- browser.TitleChanged += OnBrowserTitleChanged;
- browser.AddressChanged += OnBrowserAddressChanged;
-
- var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
- DisplayOutput(version);
- }
-
- 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 OnBrowserStatusMessage(object sender, StatusMessageEventArgs args)
- {
- this.InvokeOnUiThreadIfRequired(() => statusLabel.Text = args.Value);
- }
-
- 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)
+ var tabPage = new TabPage(url)
{
- if (item != urlTextBox)
- {
- width -= item.Width - item.Margin.Horizontal;
- }
+ Dock = DockStyle.Fill
+ };
+
+ tabPage.Controls.Add(browser);
+
+ if (insertIndex == null)
+ {
+ browserTabControl.TabPages.Add(tabPage);
}
- urlTextBox.Width = Math.Max(0, width - urlTextBox.Margin.Horizontal - 18);
+ else
+ {
+ browserTabControl.TabPages.Insert(insertIndex.Value, tabPage);
+ }
+
+ //Make newly created tab active
+ browserTabControl.SelectedTab = tabPage;
+
+ browserTabControl.ResumeLayout(true);
}
private void ExitMenuItemClick(object sender, EventArgs e)
{
- browser.Dispose();
+ ExitApplication();
+ }
+
+ private void ExitApplication()
+ {
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)
+ var control = GetCurrentTabControl();
+ if (control != null)
{
- browser.StopFinding(true);
- toolStripContainer.BottomToolStripPanelVisible = false;
+ control.ShowFind();
}
- 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();
-
- task.ContinueWith(t =>
+ var control = GetCurrentTabControl();
+ if (control != null)
{
- if (!t.IsFaulted)
- {
- Clipboard.SetText(t.Result);
- DisplayOutput("HTML Source copied to clipboard");
- }
- },
- TaskScheduler.FromCurrentSynchronizationContext());
+ control.CopySourceToClipBoardAsync();
+ }
+ }
+
+ private BrowserTabUserControl GetCurrentTabControl()
+ {
+ if (browserTabControl.SelectedIndex == -1)
+ {
+ return null;
+ }
+
+ var tabPage = browserTabControl.Controls[browserTabControl.SelectedIndex];
+ var control = (BrowserTabUserControl)tabPage.Controls[0];
+
+ return control;
+ }
+
+ private void NewTabToolStripMenuItemClick(object sender, EventArgs e)
+ {
+ AddTab(DefaultUrlForAddedTabs);
+ }
+
+ private void CloseTabToolStripMenuItemClick(object sender, EventArgs e)
+ {
+ if(browserTabControl.Controls.Count == 0)
+ {
+ return;
+ }
+
+ var currentIndex = browserTabControl.SelectedIndex;
+
+ var tabPage = browserTabControl.Controls[currentIndex];
+
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Dispose();
+ }
+
+ browserTabControl.Controls.Remove(tabPage);
+
+ browserTabControl.SelectedIndex = currentIndex - 1;
+
+ if (browserTabControl.Controls.Count == 0)
+ {
+ ExitApplication();
+ }
+ }
+
+ private void UndoMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Undo();
+ }
+ }
+
+ private void RedoMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Redo();
+ }
+ }
+
+ private void CutMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Cut();
+ }
+ }
+
+ private void CopyMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Copy();
+ }
+ }
+
+ private void PasteMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Paste();
+ }
+ }
+
+ private void DeleteMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Delete();
+ }
+ }
+
+ private void SelectAllMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.SelectAll();
+ }
+ }
+
+ private void PrintToolStripMenuItemClick(object sender, EventArgs e)
+ {
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.Print();
+ }
}
private void ShowDevToolsMenuItemClick(object sender, EventArgs e)
{
- browser.ShowDevTools();
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.ShowDevTools();
+ }
}
private void CloseDevToolsMenuItemClick(object sender, EventArgs e)
{
- browser.CloseDevTools();
+ var control = GetCurrentTabControl();
+ if (control != null)
+ {
+ control.Browser.CloseDevTools();
+ }
}
}
}
diff --git a/CefSharp.WinForms.Example/BrowserForm.resx b/CefSharp.WinForms.Example/BrowserForm.resx
index bc7ad3a93..e8300c60c 100644
--- a/CefSharp.WinForms.Example/BrowserForm.resx
+++ b/CefSharp.WinForms.Example/BrowserForm.resx
@@ -117,12 +117,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 237, 17
-
-
- 17, 17
-
122, 17
diff --git a/CefSharp.WinForms.Example/BrowserTabUserControl.Designer.cs b/CefSharp.WinForms.Example/BrowserTabUserControl.Designer.cs
new file mode 100644
index 000000000..d6f786ec0
--- /dev/null
+++ b/CefSharp.WinForms.Example/BrowserTabUserControl.Designer.cs
@@ -0,0 +1,213 @@
+namespace CefSharp.WinForms.Example
+{
+ partial class BrowserTabUserControl
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ 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.statusLabel = new System.Windows.Forms.Label();
+ 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.browserPanel = new System.Windows.Forms.Panel();
+ this.toolStrip2.SuspendLayout();
+ this.toolStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // toolStrip2
+ //
+ this.toolStrip2.Dock = System.Windows.Forms.DockStyle.Bottom;
+ 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(0, 465);
+ this.toolStrip2.Name = "toolStrip2";
+ this.toolStrip2.Size = new System.Drawing.Size(730, 25);
+ this.toolStrip2.TabIndex = 0;
+ this.toolStrip2.Visible = false;
+ //
+ // 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);
+ //
+ // statusLabel
+ //
+ this.statusLabel.AutoSize = true;
+ this.statusLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.statusLabel.Location = new System.Drawing.Point(0, 439);
+ this.statusLabel.Name = "statusLabel";
+ this.statusLabel.Size = new System.Drawing.Size(0, 13);
+ this.statusLabel.TabIndex = 1;
+ //
+ // outputLabel
+ //
+ this.outputLabel.AutoSize = true;
+ this.outputLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.outputLabel.Location = new System.Drawing.Point(0, 452);
+ this.outputLabel.Name = "outputLabel";
+ this.outputLabel.Size = new System.Drawing.Size(0, 13);
+ this.outputLabel.TabIndex = 0;
+ //
+ // toolStrip1
+ //
+ 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);
+ //
+ // browserPanel
+ //
+ this.browserPanel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.browserPanel.Location = new System.Drawing.Point(0, 25);
+ this.browserPanel.Name = "browserPanel";
+ this.browserPanel.Size = new System.Drawing.Size(730, 414);
+ this.browserPanel.TabIndex = 2;
+ //
+ // BrowserTabUserControl
+ //
+ this.Controls.Add(this.browserPanel);
+ this.Controls.Add(this.toolStrip1);
+ this.Controls.Add(this.statusLabel);
+ this.Controls.Add(this.outputLabel);
+ this.Controls.Add(this.toolStrip2);
+ this.Name = "BrowserTabUserControl";
+ this.Size = new System.Drawing.Size(730, 490);
+ this.toolStrip2.ResumeLayout(false);
+ this.toolStrip2.PerformLayout();
+ this.toolStrip1.ResumeLayout(false);
+ this.toolStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ 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.Label outputLabel;
+
+ 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.Label statusLabel;
+ private System.Windows.Forms.Panel browserPanel;
+ }
+}
\ No newline at end of file
diff --git a/CefSharp.WinForms.Example/BrowserTabUserControl.cs b/CefSharp.WinForms.Example/BrowserTabUserControl.cs
new file mode 100644
index 000000000..f8c61bbd1
--- /dev/null
+++ b/CefSharp.WinForms.Example/BrowserTabUserControl.cs
@@ -0,0 +1,224 @@
+using System.Threading.Tasks;
+using CefSharp.WinForms.Example.Controls;
+using System;
+using System.Windows.Forms;
+
+namespace CefSharp.WinForms.Example
+{
+ public partial class BrowserTabUserControl : UserControl
+ {
+ public IWinFormsWebBrowser Browser { get; private set; }
+
+ public BrowserTabUserControl(string url)
+ {
+ InitializeComponent();
+
+ var browser = new ChromiumWebBrowser(url)
+ {
+ Dock = DockStyle.Fill
+ };
+
+ browserPanel.Controls.Add(browser);
+
+ Browser = browser;
+
+ Browser.MenuHandler = new MenuHandler();
+ Browser.NavStateChanged += OnBrowserNavStateChanged;
+ Browser.ConsoleMessage += OnBrowserConsoleMessage;
+ Browser.TitleChanged += OnBrowserTitleChanged;
+ Browser.AddressChanged += OnBrowserAddressChanged;
+ Browser.StatusMessage += OnBrowserStatusMessage;
+
+ var version = String.Format("Chromium: {0}, CEF: {1}, CefSharp: {2}", Cef.ChromiumVersion, Cef.CefVersion, Cef.CefSharpVersion);
+ DisplayOutput(version);
+
+ Disposed += BrowserTabUserControlDisposed;
+ }
+
+ private void BrowserTabUserControlDisposed(object sender, EventArgs e)
+ {
+ Disposed -= BrowserTabUserControlDisposed;
+
+ Browser.NavStateChanged -= OnBrowserNavStateChanged;
+ Browser.ConsoleMessage -= OnBrowserConsoleMessage;
+ Browser.TitleChanged -= OnBrowserTitleChanged;
+ Browser.AddressChanged -= OnBrowserAddressChanged;
+ Browser.StatusMessage -= OnBrowserStatusMessage;
+
+ Browser.Dispose();
+ }
+
+ private void OnBrowserConsoleMessage(object sender, ConsoleMessageEventArgs args)
+ {
+ DisplayOutput(string.Format("Line: {0}, Source: {1}, Message: {2}", args.Line, args.Source, args.Message));
+ }
+
+ private void OnBrowserStatusMessage(object sender, StatusMessageEventArgs args)
+ {
+ this.InvokeOnUiThreadIfRequired(() => statusLabel.Text = args.Value);
+ }
+
+ 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(() => Parent.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 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 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);
+ }
+ }
+
+ public void CopySourceToClipBoardAsync()
+ {
+ var task = Browser.GetSourceAsync();
+
+ task.ContinueWith(t =>
+ {
+ if (!t.IsFaulted)
+ {
+ Clipboard.SetText(t.Result);
+ DisplayOutput("HTML Source copied to clipboard");
+ }
+ },
+ TaskScheduler.FromCurrentSynchronizationContext());
+ }
+
+ private void ToggleBottomToolStrip()
+ {
+ if (toolStrip2.Visible)
+ {
+ Browser.StopFinding(true);
+ toolStrip2.Visible = false;
+ }
+ else
+ {
+ toolStrip2.Visible = 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);
+ }
+
+ public void ShowFind()
+ {
+ ToggleBottomToolStrip();
+ }
+
+ private void FindCloseButtonClick(object sender, EventArgs e)
+ {
+ ToggleBottomToolStrip();
+ }
+ }
+}
diff --git a/CefSharp.WinForms.Example/BrowserTabUserControl.resx b/CefSharp.WinForms.Example/BrowserTabUserControl.resx
new file mode 100644
index 000000000..938d2e289
--- /dev/null
+++ b/CefSharp.WinForms.Example/BrowserTabUserControl.resx
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
+ 122, 17
+
+
\ No newline at end of file
diff --git a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
index 3e58298d2..2855591b9 100644
--- a/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
+++ b/CefSharp.WinForms.Example/CefSharp.WinForms.Example.csproj
@@ -62,6 +62,12 @@
BrowserForm.cs
+
+ UserControl
+
+
+ BrowserTabUserControl.cs
+
@@ -81,6 +87,10 @@
BrowserForm.cs
Designer
+
+ BrowserTabUserControl.cs
+ Designer
+
ResXFileCodeGenerator
Resources.Designer.cs
diff --git a/CefSharp/IWebBrowser.cs b/CefSharp/IWebBrowser.cs
index 9734a0df8..f54efa44b 100644
--- a/CefSharp/IWebBrowser.cs
+++ b/CefSharp/IWebBrowser.cs
@@ -184,12 +184,12 @@ namespace CefSharp
void StopFinding(bool clearSelection);
///
- /// Navigates back, check before calling this method.
+ /// Navigates back, must check before calling this method.
///
void Back();
///
- /// Navigates forward, check before calling this method.
+ /// Navigates forward, must check before calling this method.
///
void Forward();