save last translation window choices

This commit is contained in:
Tim Young 2017-10-03 15:19:18 -05:00
parent eca5aef396
commit 3373c325b3
6 changed files with 79 additions and 6 deletions

View File

@ -40,6 +40,12 @@
<setting name="AutoDHCP" serializeAs="String">
<value>False</value>
</setting>
<setting name="LastTrans1Lang" serializeAs="String">
<value />
</setting>
<setting name="LastTrans2Lang" serializeAs="String">
<value />
</setting>
</EduNetworkBuilder.Properties.Settings>
</userSettings>
</configuration>

View File

@ -33,6 +33,8 @@ namespace EduNetworkBuilder
public string ProcessingLevel = "none";
public UInt32 NextID = 100;
public bool AutoDHCPAllMachinesAtNetworkLoad = false; //Mainly for teachers
public string LastTrans1Lang = "";
public string LastTrans2Lang = "";
public NBSettings()
{
@ -117,8 +119,10 @@ namespace EduNetworkBuilder
MainWindowHeight = Properties.Settings.Default.MainWindowHeight;
MainWindowWidth = Properties.Settings.Default.MainWindowWidth;
AutoDHCPAllMachinesAtNetworkLoad = Properties.Settings.Default.AutoDHCP;
LastTrans1Lang = Properties.Settings.Default.LastTrans1Lang;
LastTrans2Lang = Properties.Settings.Default.LastTrans2Lang;
foreach(string one in Properties.Settings.Default.ScoreList)
foreach (string one in Properties.Settings.Default.ScoreList)
{
if (!ScoreList.Contains(one))
ScoreList.Add(one);
@ -247,6 +251,8 @@ namespace EduNetworkBuilder
Properties.Settings.Default.MainWindowHeight = MainWindowHeight;
Properties.Settings.Default.MainWindowWidth = MainWindowWidth;
Properties.Settings.Default.AutoDHCP = AutoDHCPAllMachinesAtNetworkLoad;
Properties.Settings.Default.LastTrans1Lang = LastTrans1Lang;
Properties.Settings.Default.LastTrans2Lang = LastTrans2Lang;
Properties.Settings.Default.ScoreList.Clear();
foreach(string One in ScoreList)

View File

@ -164,5 +164,29 @@ namespace EduNetworkBuilder.Properties {
this["AutoDHCP"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastTrans1Lang {
get {
return ((string)(this["LastTrans1Lang"]));
}
set {
this["LastTrans1Lang"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LastTrans2Lang {
get {
return ((string)(this["LastTrans2Lang"]));
}
set {
this["LastTrans2Lang"] = value;
}
}
}
}

View File

@ -38,5 +38,11 @@
<Setting Name="AutoDHCP" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="LastTrans1Lang" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="LastTrans2Lang" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@ -100,6 +100,7 @@
this.Controls.Add(this.cb1Language);
this.Name = "TranslationWindow";
this.Text = "TranslationWindow";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TranslationWindow_FormClosing);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TranslationWindow_KeyDown);
this.ResumeLayout(false);
this.PerformLayout();

View File

@ -27,20 +27,45 @@ namespace EduNetworkBuilder
string[,] LanguageChoices = NB.LanguageChoices;
cb1Language.Items.Clear();
cb2Language.Items.Clear();
NBSettings mySettings = NB.GetSettings();
for (int i = 0; i < LanguageChoices.GetLength(0); i++)
{
cb1Language.Items.Add(LanguageChoices[i, 0]);
cb2Language.Items.Add(LanguageChoices[i, 0]);
if(mySettings.LastTrans1Lang == LanguageChoices[i, 1])
{
cb1Language.SelectedItem = LanguageChoices[i, 0];
}
if (mySettings.LastTrans2Lang == LanguageChoices[i, 1])
{
cb2Language.SelectedItem = LanguageChoices[i, 0];
}
}
if (LanguageChoices.Length > 0)
cb1Language.SelectedIndex = 0;
if (LanguageChoices.Length > 1)
cb1Language.SelectedIndex = 1;
if (cb1Language.SelectedIndex == -1) cb1Language.SelectedIndex = 0;
if (cb2Language.SelectedIndex == -1) cb2Language.SelectedIndex = 0;
Icon = Properties.Resources.NBIco;
}
private void btnClose_Click(object sender, EventArgs e)
private void ClosingStuff()
{
string[,] LanguageChoices = NB.LanguageChoices;
NBSettings mySettings = NB.GetSettings();
for (int i = 0; i < LanguageChoices.GetLength(0); i++)
{
if (cb1Language.Text == LanguageChoices[i, 0])
{
mySettings.LastTrans1Lang = LanguageChoices[i, 1];
}
if (cb2Language.Text == LanguageChoices[i, 0])
{
mySettings.LastTrans2Lang = LanguageChoices[i, 1];
}
}
mySettings.Save();
}
private void btnClose_Click(object sender, EventArgs e)
{
Close();
}
@ -57,5 +82,10 @@ namespace EduNetworkBuilder
Save();
}
}
private void TranslationWindow_FormClosing(object sender, FormClosingEventArgs e)
{
ClosingStuff();
}
}
}