Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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.");
                }
            }
        }
Ejemplo n.º 3
0
 private void btnLoad_Click(object sender, EventArgs e) => Dispatch(TransLation.Load($"Language\\{comboBox1.Text}.xml"));