internal static TransLation Load(string fileName) { var transLation = new TransLation(); // Load defaults. if (File.Exists(fileName)) { using (TextReader reader = new StreamReader(fileName)) { transLation = new XmlSerializer(typeof(TransLation)).Deserialize(reader) as TransLation; } } return(transLation); }
private void Dispatch(TransLation translation) { this.translation = translation; var dictionary = GetAllControls(this); foreach (var form in this.OwnedForms) { var dic2 = GetAllControls(form); dic2.ToList().ForEach(x => dictionary.Add(x.Key, x.Value)); } foreach (KeyValue kv in translation.MenuItems) { if (dictionary.ContainsKey(kv.Key)) { var text = kv.Value; var control = dictionary[kv.Key]; if (control is ComboBox) { var comboBox = control as ComboBox; var save = comboBox.SelectedIndex; comboBox.Items.Clear(); comboBox.Items.AddRange(text.Split(';')); comboBox.SelectedIndex = save; } else if (control is Control) { (control as Control).Text = text; } else if (control is ToolStripMenuItem) { (control as ToolStripMenuItem).Text = text; } else { continue; } } else if (!kv.Key.Contains("Dynamic")) { Status($"{kv.Key} not on form."); } } }
private void btnLoad_Click(object sender, EventArgs e) => Dispatch(TransLation.Load($"Language\\{comboBox1.Text}.xml"));