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"> <setting name="AutoDHCP" serializeAs="String">
<value>False</value> <value>False</value>
</setting> </setting>
<setting name="LastTrans1Lang" serializeAs="String">
<value />
</setting>
<setting name="LastTrans2Lang" serializeAs="String">
<value />
</setting>
</EduNetworkBuilder.Properties.Settings> </EduNetworkBuilder.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -33,6 +33,8 @@ namespace EduNetworkBuilder
public string ProcessingLevel = "none"; public string ProcessingLevel = "none";
public UInt32 NextID = 100; public UInt32 NextID = 100;
public bool AutoDHCPAllMachinesAtNetworkLoad = false; //Mainly for teachers public bool AutoDHCPAllMachinesAtNetworkLoad = false; //Mainly for teachers
public string LastTrans1Lang = "";
public string LastTrans2Lang = "";
public NBSettings() public NBSettings()
{ {
@ -117,6 +119,8 @@ namespace EduNetworkBuilder
MainWindowHeight = Properties.Settings.Default.MainWindowHeight; MainWindowHeight = Properties.Settings.Default.MainWindowHeight;
MainWindowWidth = Properties.Settings.Default.MainWindowWidth; MainWindowWidth = Properties.Settings.Default.MainWindowWidth;
AutoDHCPAllMachinesAtNetworkLoad = Properties.Settings.Default.AutoDHCP; 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)
{ {
@ -247,6 +251,8 @@ namespace EduNetworkBuilder
Properties.Settings.Default.MainWindowHeight = MainWindowHeight; Properties.Settings.Default.MainWindowHeight = MainWindowHeight;
Properties.Settings.Default.MainWindowWidth = MainWindowWidth; Properties.Settings.Default.MainWindowWidth = MainWindowWidth;
Properties.Settings.Default.AutoDHCP = AutoDHCPAllMachinesAtNetworkLoad; Properties.Settings.Default.AutoDHCP = AutoDHCPAllMachinesAtNetworkLoad;
Properties.Settings.Default.LastTrans1Lang = LastTrans1Lang;
Properties.Settings.Default.LastTrans2Lang = LastTrans2Lang;
Properties.Settings.Default.ScoreList.Clear(); Properties.Settings.Default.ScoreList.Clear();
foreach(string One in ScoreList) foreach(string One in ScoreList)

View File

@ -164,5 +164,29 @@ namespace EduNetworkBuilder.Properties {
this["AutoDHCP"] = value; 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"> <Setting Name="AutoDHCP" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </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> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -100,6 +100,7 @@
this.Controls.Add(this.cb1Language); this.Controls.Add(this.cb1Language);
this.Name = "TranslationWindow"; this.Name = "TranslationWindow";
this.Text = "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.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TranslationWindow_KeyDown);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View File

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