71 lines
2.3 KiB
C#
71 lines
2.3 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// Dialog to edit local settings that specify UI preferences, language, etc. (S1.1)
|
|
/// </summary>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Update setting, return DialogResult.OK
|
|
/// </summary>
|
|
/// <param name="sender">Not used</param>
|
|
/// <param name="e">Not used</param>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Throw away changes, return DialogResult.Cancel
|
|
/// </summary>
|
|
/// <param name="sender">Not used</param>
|
|
/// <param name="e">Not used</param>
|
|
private void cancelButton_Click(object sender, EventArgs e)
|
|
{
|
|
DialogResult = DialogResult.Cancel;
|
|
Close();
|
|
return;
|
|
}
|
|
}
|
|
} |