Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 System.IO;
- using System.Xml.Serialization;
- using System.Threading;
- using System.Globalization;
- using ClassLibraryStudent_2017;
- namespace Serialization_2017
- {
- public partial class Form1 : Form
- {
- private string language;
- public Form1()
- {
- InitializeComponent();
- }
- private void ChangeElementsLanguage(
- string language,
- CultureInfo culture,
- ComponentResourceManager resources,
- Control currentControl)
- {
- resources.ApplyResources(currentControl, currentControl.Name, culture);
- if (currentControl.Controls.Count > 0)
- {
- foreach (Control c in currentControl.Controls)
- {
- this.ChangeElementsLanguage(language, culture, resources, c);
- }
- }
- }
- private void ChangeLanguage(string language)
- {
- CultureInfo myCulture = new CultureInfo(language);
- Thread.CurrentThread.CurrentCulture = myCulture;
- Thread.CurrentThread.CurrentUICulture = myCulture;
- ComponentResourceManager resources = new ComponentResourceManager(this.GetType());
- this.Text = resources.GetString("$this.Text", myCulture);
- foreach (Control control in this.Controls)
- {
- this.ChangeElementsLanguage(language, myCulture, resources, control);
- }
- }
- private void btnEng_Click(object sender, EventArgs e)
- {
- this.language = "en-US";
- this.ChangeLanguage(this.language);
- }
- private void btnBg_Click(object sender, EventArgs e)
- {
- this.language = "bg-BG";
- this.ChangeLanguage(this.language);
- }
- private void btnExit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement