using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Globalization; using TBF.Resources; namespace TBF { /// /// Dialog to edit local settings that specify UI preferences, language, etc. (S1.1) /// public partial class PreferencesDlg : Form { // Local copy of 'local settings' initialized to Program.localSettings. // Dialog modifies this copy and updates Program.localSettings just // when 'OK' is pressed. LocalSettings localSettings; public PreferencesDlg() { localSettings = new LocalSettings(); localSettings.Assign(Program.LocalSettings); InitializeComponent(); // Initialize the list box with langauges for (int i = 0; i < (int)LocalSettings.Languages.Count; i++) { languageListBox.Items.Add(((LocalSettings.Languages)i).ToString()); } languageListBox.Text = localSettings.Language; } private void languageListBox_SelectedIndexChanged(object sender, EventArgs e) { localSettings.Language = ((LocalSettings.Languages)languageListBox.SelectedIndex).ToString(); } /// /// Update setting, return DialogResult.OK /// /// Not used /// Not used private void okButton_Click(object sender, EventArgs e) { Program.LocalSettings.Assign(localSettings); // Update 'global' local settings DialogResult = DialogResult.OK; Close(); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(localSettings.Language); DialogResult response = MessageBox.Show(Strings.Restart_To_Apply_Changes); return; } /// /// Throw away changes, return DialogResult.Cancel /// /// Not used /// Not used private void cancelButton_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); return; } } }