-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClimateToolsGo
78 lines (69 loc) · 1.99 KB
/
ClimateToolsGo
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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
public partial class BrowserForm : Form
{
private WebBrowser webBrowser;
private List<string> history = new List<string>();
private int currentHistoryIndex = -1;
public BrowserForm()
{
InitializeComponent();
webBrowser = new WebBrowser()
{
Dock = DockStyle.Fill,
};
webBrowser.Navigated += WebBrowser_Navigated;
Controls.Add(webBrowser);
// Navigation panel
var navigationPanel = new Panel()
{
Height = 30,
Dock = DockStyle.Top,
};
Controls.Add(navigationPanel);
// URL text box
var urlTextBox = new TextBox()
{
Dock = DockStyle.Fill,
};
navigationPanel.Controls.Add(urlTextBox);
// Go button
var goButton = new Button()
{
Text = "Go",
Dock = DockStyle.Right,
};
goButton.Click += (sender, e) =>
{
webBrowser.Navigate(urlTextBox.Text);
};
navigationPanel.Controls.Add(goButton);
// Back button
var backButton = new Button()
{
Text = "Back",
Dock = DockStyle.Left,
};
backButton.Click += (sender, e) =>
{
if (currentHistoryIndex > 0)
{
currentHistoryIndex--;
webBrowser.Navigate(history[currentHistoryIndex]);
}
};
navigationPanel.Controls.Add(backButton);
}
private void WebBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
// Clear forward history when new URL is visited
if (currentHistoryIndex < history.Count - 1)
{
history.RemoveRange(currentHistoryIndex + 1, history.Count - currentHistoryIndex - 1);
}
// Add URL to history
history.Add(e.Url.ToString());
currentHistoryIndex++;
}
}