-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
98 lines (87 loc) · 2.92 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Chrom
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
WebBrowser.Navigate("https://www.google.pl");
WebBrowser.DocumentCompleted += WebBrowser_DocumentCompleted;
}
private void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
tabControl.SelectedTab.Text = WebBrowser.DocumentTitle;
}
private void goButton_Click(object sender, EventArgs e)
{
WebBrowser browser = tabControl.SelectedTab.Controls[0] as WebBrowser;
if (browser != null)
{
browser.Navigate(urlBox.Text);
}
}
WebBrowser bTab = null;
private void newTabButton_Click(object sender, EventArgs e)
{
TabPage tab = new TabPage();
tab.Text = "Nowa karta";
tabControl.Controls.Add(tab);
tabControl.SelectTab(tabControl.TabCount-1);
bTab = new WebBrowser() { ScriptErrorsSuppressed = true };
bTab.Parent = tab;
bTab.Dock = DockStyle.Fill;
bTab.Navigate("https://www.google.pl");
urlBox.Text = "https://www.google.pl";
bTab.DocumentCompleted += BTab_DocumentCompleted;
}
private void BTab_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
tabControl.SelectedTab.Text = bTab.DocumentTitle;
}
private void backButton_Click(object sender, EventArgs e)
{
WebBrowser browser = tabControl.SelectedTab.Controls[0] as WebBrowser;
if(browser!=null)
{
if(browser.CanGoBack)
{
browser.GoBack();
}
}
}
private void forwardButton_Click(object sender, EventArgs e)
{
WebBrowser browser = tabControl.SelectedTab.Controls[0] as WebBrowser;
if (browser != null)
{
if (browser.CanGoForward)
{
browser.GoForward();
}
}
}
private void urlBox_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar==(char)13)
{
WebBrowser browser = tabControl.SelectedTab.Controls[0] as WebBrowser;
if(browser!=null)
{
browser.Navigate(urlBox.Text);
}
}
}
}
}