-
Notifications
You must be signed in to change notification settings - Fork 4
/
UI.cs
185 lines (168 loc) · 5.5 KB
/
UI.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
using System;
using System.Threading;
using System.Windows.Forms;
namespace alyx_multiplayer
{
public partial class UI : Form
{
public UI()
{
InitializeComponent();
}
/// <summary>
/// Executed when the UI form loads.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void form_Load(object sender, EventArgs e)
{
}
/// <summary>
/// Terminate all threads when form closed.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UI_FormClosed(object sender, FormClosedEventArgs e)
{
Environment.Exit(Environment.ExitCode);
}
/// <summary>
/// Copy IP when labelIP is clicked.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelIP_Click(object sender, EventArgs e)
{
Clipboard.SetText(labelIP.Text);
}
/// <summary>
/// Toggle console visibility.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItemConsole_Click(object sender, EventArgs e)
{
Core.ToggleConsole();
}
/// <summary>
/// Open the Info form.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItemInfo_Click(object sender, EventArgs e)
{
if (!Core.isInfoOpen)
{
Core.isInfoOpen = true;
Thread infoThread = new Thread(Core.InfoThread.ShowInfo);
infoThread.Start();
}
}
/// <summary>
/// Tooltip functionality for labelIP.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelIP_MouseHover(object sender, EventArgs e)
{
toolTipIP.Show("Click to copy IP!", labelIP.Owner);
}
/// <summary>
/// Submit the script path (by pressing either buttonPath or the return key).
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void buttonPath_Click(object sender, EventArgs e)
{
String path = textBoxPath.Text;
if (path.Length <= 0)
{
// do nothing
} else
{
Core.scriptPath = @path;
Core.Log("Set script path set to: \"" + path + "\"", false);
}
}
/// <summary>
/// Call buttonPath_Click() when return key pressed inside textBoxPath.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void textBoxPath_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
buttonPath_Click(sender, e);
e.Handled = true;
}
}
private void buttonEntSearch_Click(object sender, EventArgs e)
{
Core.entPrefixIndex = 0;
}
private void buttonLocalPort_Click(object sender, EventArgs e)
{
string newServerPort = textBoxLocalPort.Text;
if (newServerPort.Length <= 0)
{
// do nothing
}
else
{
Core.Log("Set local port to: " + newServerPort, false);
Core.networkHandler.ReconfigureServerPort(newServerPort);
}
}
private void textBoxLocalPort_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
buttonLocalPort_Click(sender, e);
e.Handled = true;
}
}
private void buttonPeerIP_Click(object sender, EventArgs e)
{
string newClientIP = textBoxPeerIP.Text;
if (newClientIP.Length <= 0)
{
// do nothing
}
else
{
Core.Log("Set client IP to: " + newClientIP, false);
Core.networkHandler.ReconfigureClientIP(newClientIP);
}
}
private void textBoxPeerIP_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
buttonPeerIP_Click(sender, e);
e.Handled = true;
}
}
private void buttonPeerPort_Click(object sender, EventArgs e)
{
string newClientPort = textBoxPeerPort.Text;
if (newClientPort.Length <= 0)
{
// do nothing
}
else
{
Core.Log("Set client port to: " + newClientPort, false);
Core.networkHandler.ReconfigureClientPort(newClientPort);
}
}
private void textBoxPeerPort_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Return)
{
buttonPeerPort_Click(sender, e);
e.Handled = true;
}
}
}
}