forked from TKGP/STALK-IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptionsForm.cs
105 lines (96 loc) · 3.33 KB
/
OptionsForm.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
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace STALK_IRC
{
public partial class OptionsForm : Form
{
ClientForm parent;
public OptionsForm(ClientForm parentForm)
{
parent = parentForm;
InitializeComponent();
}
private void Options_Load(object sender, EventArgs e)
{
textBox1.Text = parent.name;
comboBox1.SelectedItem = (string)ClientForm.REGISTRY.GetValue("Faction", "Loners");
textBox2.Text = parent.timeout;
comboBox2.SelectedItem = parent.chatKey;
checkBox1.Checked = parent.sendDeaths;
checkBox2.Checked = parent.receiveDeaths;
checkBox3.Checked = parent.muhAtmospheres;
}
// Name - Random
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = SIStrings.GenerateName();
}
// Confirm
private void button2_Click(object sender, EventArgs e)
{
bool error = false;
if (textBox1.Text == "")
{
error = true;
textBox1.BackColor = Color.LightPink;
}
if (textBox2.Text == "")
{
error = true;
textBox2.BackColor = Color.LightPink;
}
try
{
Convert.ToInt32(textBox2.Text);
}
catch
{
error = true;
textBox2.BackColor = Color.LightPink;
}
if (!error)
{
string name = textBox1.Text.Replace(' ', '_');
parent.name = name;
parent.irc.RfcNick(name);
parent.faction = Regex.Replace(comboBox1.Text, " ", "");
parent.timeout = textBox2.Text;
parent.SendCommandAll(1, "timeout", textBox2.Text);
parent.chatKey = comboBox2.Text;
parent.SendCommandAll(1, "chatkey", comboBox2.Text);
parent.sendDeaths = checkBox1.Checked;
parent.receiveDeaths = checkBox2.Checked;
parent.muhAtmospheres = checkBox3.Checked;
parent.SendCommandAll(1, "atmospheres", checkBox3.Checked.ToString());
RegistryKey registry = ClientForm.REGISTRY;
registry.SetValue("Name", name);
registry.SetValue("Faction", comboBox1.Text);
registry.SetValue("Timeout", textBox2.Text);
registry.SetValue("ChatKey", comboBox2.Text);
registry.SetValue("SendDeaths", checkBox1.Checked);
registry.SetValue("ReceiveDeaths", checkBox2.Checked);
registry.SetValue("MuhAtmospheres", checkBox3.Checked);
Close();
}
}
// Cancel
private void button3_Click(object sender, EventArgs e)
{
Close();
}
private void OptionsForm_HelpButtonClicked(object sender, CancelEventArgs e)
{
e.Cancel = true;
new HelpForm(3).ShowDialog();
}
}
}