private void SupportedLanguagesButton_Click(object sender, EventArgs e) { List<string> locales = new List<string>(); locales.AddRange(SupportedLanguagesField.Text.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)); LocaleManager frmLocaleMan = new LocaleManager(ref locales); if (frmLocaleMan.ShowDialog(this) == DialogResult.OK) { SupportedLanguagesField.Text = String.Join(" ", locales.ToArray()); } }
private void LocaleManagerButton_Click(object sender, EventArgs e) { List<string> originalLocales = new List<string>(); originalLocales.AddRange(_locales); //Save active PropertyManager.SetProperty("name", NameField, GetSelectedLocale(), GetSelectedLocaleIsDefault()); PropertyManager.SetProperty("description", DescriptionField, GetSelectedLocale(), GetSelectedLocaleIsDefault()); LocaleManager frmLocaleMan = new LocaleManager(ref _locales); if (frmLocaleMan.ShowDialog(this) == DialogResult.OK) { //Check to see if any locales have been removed foreach (string locale in originalLocales) { if (!_locales.Contains(locale)) { //remove affected properties from properties file PropertyManager.RemoveLocalizedProperty("name", locale); PropertyManager.RemoveLocalizedProperty("description", locale); } } //Check to see if any locales have been added foreach (string locale in _locales) { if (!originalLocales.Contains(locale)) { //create the affected properties now, even though value is empty, so the locale //will be preserved if the user closes the form without specifying a value PropertyManager.CreateLocalizedProperty("name", locale, (Boolean)_locales[0].Equals(locale)); PropertyManager.CreateLocalizedProperty("description", locale, (Boolean)_locales[0].Equals(locale)); } } //Re-initialize locales and refresh affected property fields InitializeLocales(); PropertyManager.GetProperty("name", NameField, GetSelectedLocale()); PropertyManager.GetProperty("description", DescriptionField, GetSelectedLocale()); } else { //reset the locales in case any changes were made _locales.Clear(); _locales.AddRange(originalLocales); } }