76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
///
|
|
/// Copyright (c) 2013-2015 Sensus Metering Systems
|
|
///
|
|
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()
|
|
{
|
|
Program.LocalSettings.Save();
|
|
localSettings = LocalSettings.Load(Program.LocalSettingsFileName);
|
|
if (localSettings == null) throw new Exception("Cannot load local settings");
|
|
|
|
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)
|
|
{
|
|
localSettings.Save();
|
|
Program.LocalSettings = LocalSettings.Load(Program.LocalSettingsFileName);
|
|
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;
|
|
}
|
|
}
|
|
} |