-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preferences.cs
84 lines (71 loc) · 2.53 KB
/
Preferences.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
using DocumentFormat.OpenXml.VariantTypes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HeroForge_OnceAgain
{
public partial class Preferences : Form
{
public Preferences()
{
InitializeComponent();
}
private void btCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btSaveSettings_Click(object sender, EventArgs e)
{
SaveChooses();
//Properties.Settings.Default.SystemofUnit = cBBaseUnit.SelectedIndex;
//Properties.Settings.Default.Save();
var mainForm = Application.OpenForms.OfType<Form1>().Single();
mainForm.Reload();
this.Close();
}
private void Preferences_Load(object sender, EventArgs e)
{
cBBaseUnit.SelectedIndex = Properties.Settings.Default.SystemofUnit;
cBLanguage.SelectedIndex = Properties.Settings.Default.LanguageIndex;
}
private void cBLanguage_SelectedIndexChanged(object sender, EventArgs e)
{
//SaveChooseLanguage(cBLanguage.Text, cBLanguage.SelectedIndex);
}
private void SaveChooses()
{
switch (cBLanguage.SelectedIndex)
{
case 0:
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
break;
case 1:
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("pt-BR");
break;
}
Properties.Settings.Default.Language = cBLanguage.Text;
Properties.Settings.Default.LanguageIndex = cBLanguage.SelectedIndex;
Properties.Settings.Default.SystemofUnit = cBBaseUnit.SelectedIndex;
Properties.Settings.Default.Save();
this.Controls.Clear();
ChangeLanguage();
InitializeComponent();
}
private void ChangeLanguage()
{
foreach (Control c in this.Controls)
{
ComponentResourceManager resources = new ComponentResourceManager(typeof(Form1));
resources.ApplyResources(c, c.Name, new CultureInfo(cBLanguage.Text));
}
}
}
}