-
Notifications
You must be signed in to change notification settings - Fork 0
/
language_form.cs
77 lines (68 loc) · 2.34 KB
/
language_form.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
using System;
using System.ComponentModel;
using System.Threading;
using System.Windows.Forms;
namespace ATM_system
{
public partial class Language_form : Form
{
private Services obj_services;
public Language_form(Services servicesForm)
{
InitializeComponent();
obj_services = servicesForm;
}
private void radbtn_CheckedChanged(object sender, EventArgs e)
{
if (sender is RadioButton radioButton && radioButton.Checked)
{
switch (radioButton.Name)
{
case "radbtn_english":
ChangeLanguage("en-US");
break;
case "radbtn_bulgarian":
ChangeLanguage("bg-BG");
break;
case "radbtn_french":
ChangeLanguage("fr-FR");
break;
case "radbtn_german":
ChangeLanguage("de-DE");
break;
}
}
}
private void ChangeLanguage(string cultureName)
{
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cultureName);
// Update language for all open forms
foreach (Form form in Application.OpenForms)
{
ComponentResourceManager resources = new ComponentResourceManager(form.GetType());
resources.ApplyResources(form, "$this");
ApplyResources(form.Controls, resources);
}
}
private void ApplyResources(Control.ControlCollection controls, ComponentResourceManager resources)
{
foreach (Control control in controls)
{
resources.ApplyResources(control, control.Name);
if (control.Controls.Count > 0)
{
ApplyResources(control.Controls, resources);
}
}
}
private void btn_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btn_continue_Click(object sender, EventArgs e)
{
obj_services.Show(); // Show the existing Services form
this.Hide();
}
}
}