-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cs
96 lines (77 loc) · 2.78 KB
/
Main.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
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;
using InputTransmiter.Language;
using InputTransmiter.Core;
using WindowsInput;
using IniParser;
using IniParser.Model;
namespace InputTransmiter
{
public partial class Main : Form
{
public Lang Lang = new Lang();
public string[] languages;
public Main()
{
InitializeComponent();
languages = new string[2] { "en", "fr" };
this.FormClosing += this_close;
Lang = new Lang();
Program.log.addLoggingElement(Lang.log);
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
this.FormBorderStyle = FormBorderStyle.FixedSingle;
statusStrip1.Items[0].Text = "Version : " + Program.version.ToString();
FileIniDataParser settingsParse = new FileIniDataParser();
IniData settings = settingsParse.ReadFile("settings.ini");
comboBox1.SelectedIndex = languages.ToList<string>().IndexOf(settings["settings"]["lang"]);
Program.Language = settings["settings"]["lang"];
Lang.LoadLang(languages[Math.Max(Math.Min(comboBox1.SelectedIndex, 0),1)]);
loadNames();
}
private void this_close(object sender, FormClosingEventArgs e)
{
this.Dispose();
this.Close();
Application.ExitThread();
}
private void Main_Load(object sender, EventArgs e)
{
}
private void loadNames()
{
button1.Text = Lang.strings["butHost"];
button2.Text = Lang.strings["butClient"];
button3.Text = Lang.strings["butHelp"];
label1.Text = Lang.strings["comboLang"] + " :";
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
FileIniDataParser iniFile = new FileIniDataParser();
IniData iniData = iniFile.ReadFile("settings.ini");
iniData["settings"]["lang"] = languages[comboBox1.SelectedIndex];
iniFile.WriteFile("settings.ini", iniData);
Program.Language = iniData["settings"]["lang"];
Lang.LoadLang(languages[comboBox1.SelectedIndex]);
loadNames();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Host host = new Host();
host.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Client client = new Client();
client.ShowDialog();
}
}
}