-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
BrowserForm.cs
85 lines (70 loc) · 2.18 KB
/
BrowserForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// 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 System;
using System.Windows.Forms;
namespace CefSharp.WinForms.Example
{
public partial class BrowserForm : Form
{
public BrowserForm()
{
InitializeComponent();
Load += BrowserFormLoad;
Text = "CefSharp";
WindowState = FormWindowState.Maximized;
AddTab(CefExample.DefaultUrl);
}
private void AddTab(string url)
{
var browser = new BrowserTabUserControl
{
Dock = DockStyle.Fill,
};
var tabPage = new TabPage(url)
{
Dock = DockStyle.Fill
};
tabPage.Controls.Add(browser);
browserTabControl.Controls.Add(tabPage);
}
private void BrowserFormLoad(object sender, EventArgs e)
{
}
private void ExitMenuItemClick(object sender, EventArgs e)
{
Cef.Shutdown();
Close();
}
private void AboutToolStripMenuItemClick(object sender, EventArgs e)
{
new AboutBox().ShowDialog();
}
private void FindMenuItemClick(object sender, EventArgs e)
{
var control = GetCurrentTabControl();
if (control != null)
{
control.ShowFind();
}
}
private void CopySourceToClipBoardAsyncClick(object sender, EventArgs e)
{
var control = GetCurrentTabControl();
if (control != null)
{
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;
}
}
}