This repository has been archived by the owner on Dec 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
83 lines (67 loc) · 2.16 KB
/
Form1.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
using System;
using System.Windows.Forms;
using CefSharp.WinForms;
using CefSharp;
using CefSharp.Example;
using CefSharp.Example.Handlers;
using LightBrowser_2020.Properties;
using System.Drawing.Text;
namespace LightBrowser_2020
{
public partial class MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
}
ChromiumWebBrowser browser;
public ChromiumWebBrowser AddressChanged { get; private set; }
public BrowserSettings BrowserSettings { get; private set; }
private void Form1_Load(object sender, EventArgs e)
{
CefSettings settings = new CefSettings();
settings.CefCommandLineArgs.Add("enable-gpu", "1");
settings.CefCommandLineArgs.Add("start-in-incognito", "1");
Cef.Initialize(settings);
browser = new ChromiumWebBrowser(textBox1.Text);
browser.Dock = DockStyle.Fill;
browser.Load("duckduckgo.com");
browser.DownloadHandler = new DownloadHandler();
this.pContainer.Controls.Add(browser);
BrowserSettings = new BrowserSettings()
{
Javascript = CefState.Enabled,
WebGl = CefState.Enabled,
WebSecurity = CefState.Enabled,
ApplicationCache = CefState.Disabled,
};
}
private void textBox1KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
browser.Load(textBox1.Text);
}
}
private void btnBack_Click(object sender, EventArgs e)
{
browser.Back();
}
private void btnFwd_Click(object sender, EventArgs e)
{
browser.Forward();
}
private void btnReload_Click(object sender, EventArgs e)
{
browser.Reload();
}
// Shortcut-based controls
private void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers == Keys.Control && e.KeyCode == Keys.P)
{
browser.Print();
}
}
}
}