SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using System.Xml.Serialization;
  12. using System.Threading;
  13. using System.Globalization;
  14. using ClassLibraryStudent_2017;
  15.  
  16. namespace Serialization_2017
  17. {
  18.     public partial class Form1 : Form
  19.     {
  20.         private string language;
  21.  
  22.         public Form1()
  23.         {
  24.             InitializeComponent();
  25.         }
  26.  
  27.         private void ChangeElementsLanguage(
  28.             string language,
  29.             CultureInfo culture,
  30.             ComponentResourceManager resources,
  31.             Control currentControl)
  32.         {
  33.             resources.ApplyResources(currentControl, currentControl.Name, culture);
  34.  
  35.             if (currentControl.Controls.Count > 0)
  36.             {
  37.                 foreach (Control c in currentControl.Controls)
  38.                 {
  39.                     this.ChangeElementsLanguage(language, culture, resources, c);
  40.                 }
  41.             }
  42.         }
  43.  
  44.         private void ChangeLanguage(string language)
  45.         {
  46.             CultureInfo myCulture = new CultureInfo(language);
  47.             Thread.CurrentThread.CurrentCulture = myCulture;
  48.             Thread.CurrentThread.CurrentUICulture = myCulture;
  49.  
  50.             ComponentResourceManager resources = new ComponentResourceManager(this.GetType());
  51.             this.Text = resources.GetString("$this.Text", myCulture);
  52.             foreach (Control control in this.Controls)
  53.             {
  54.                 this.ChangeElementsLanguage(language, myCulture, resources, control);
  55.             }
  56.         }
  57.  
  58.         private void btnEng_Click(object sender, EventArgs e)
  59.         {
  60.             this.language = "en-US";
  61.             this.ChangeLanguage(this.language);
  62.         }
  63.  
  64.         private void btnBg_Click(object sender, EventArgs e)
  65.         {
  66.             this.language = "bg-BG";
  67.             this.ChangeLanguage(this.language);
  68.         }
  69.  
  70.         private void btnExit_Click(object sender, EventArgs e)
  71.         {
  72.             Application.Exit();
  73.         }
  74.     }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top