sync missing changes

oops
This commit is contained in:
Kurt
2017-12-20 00:16:41 -08:00
parent b467a0e8e3
commit bf94aef729
2 changed files with 12 additions and 7 deletions

View File

@@ -53,13 +53,17 @@ public static void LoadFormSettings(Form form, Control.ControlCollection control
public static void SaveFormSettings(Form form, Control.ControlCollection controls)
{
if (!Settings.TryGetValue(form.Name, out var list))
return;
{
list = new List<NameValue>();
Settings.Add(form.Name, list);
}
foreach (Control ctrl in controls)
{
SaveFormSettings(form, ctrl.Controls);
var pair = list.FirstOrDefault(z => ctrl.Name == z.Name) ?? new NameValue(ctrl.Name);
TrySetValue(ctrl, pair);
if (TrySetValue(ctrl, pair) && !list.Contains(pair))
list.Add(pair);
}
}
private static void TryGetValue(Control ctrl, string s)
@@ -83,22 +87,22 @@ private static void TryGetValue(Control ctrl, string s)
break;
}
}
private static void TrySetValue(Control ctrl, NameValue v)
private static bool TrySetValue(Control ctrl, NameValue v)
{
switch (ctrl)
{
case NumericUpDown nud:
v.Value = nud.Value.ToString(CultureInfo.InvariantCulture);
break;
return true;
case ComboBox cb:
v.Value = cb.SelectedIndex.ToString();
break;
return true;
case CheckBox ck:
v.Value = ck.Checked.ToString();
break;
return true;
default:
System.Diagnostics.Debug.WriteLine($"{ctrl.Name}: unknown control type.");
break;
return false;
}
}

View File

@@ -84,6 +84,7 @@
<Compile Include="Subforms\Gen7\Wild\Encounter7.cs" />
<Compile Include="Subforms\Gen7\Wild\EncounterTable.cs" />
<Compile Include="Subforms\Gen7\Wild\Wild7Randomizer.cs" />
<Compile Include="Tools\RandSettings.cs" />
<Compile Include="WinFormsUtil.cs" />
<Compile Include="Misc\ErrorWindow.cs">
<SubType>Form</SubType>