Add rand settings persistence

Closes #129
This commit is contained in:
Kurt 2017-12-20 01:28:02 -08:00
parent bf94aef729
commit b9e0bf355b
23 changed files with 121 additions and 56 deletions

View File

@ -34,6 +34,7 @@ public EggMoveEditor6(byte[][] infiles)
CB_Species.ValueMember = "Value";
CB_Species.DataSource = newlist;
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private readonly byte[][] files;
private int entry = -1;
@ -154,6 +155,7 @@ private void B_Dump_Click(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void calcStats()
{

View File

@ -77,6 +77,7 @@ public EvolutionEditor6(byte[][] infiles)
CB_Species.Items.RemoveAt(0);
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, GB_Randomizer.Controls);
}
private readonly byte[][] files;
private readonly ComboBox[] pb;
@ -181,6 +182,7 @@ private void B_Dump_Click(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
RandSettings.SetFormSettings(this, GB_Randomizer.Controls);
}
private void changeMethod(object sender, EventArgs e)

View File

@ -36,6 +36,7 @@ public GiftEditor6()
CB_HeldItem.Items.Add(s);
CB_Nature.Items.Add("Random");
CB_Nature.Items.AddRange(natureslist.Take(25).ToArray());
RandSettings.GetFormSettings(this, tabPage2.Controls);
loadData();
}
@ -62,6 +63,7 @@ private void B_Save_Click(object sender, EventArgs e)
{
saveEntry();
saveData();
RandSettings.SetFormSettings(this, tabPage2.Controls);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)

View File

@ -39,6 +39,7 @@ public LevelUpEditor6(byte[][] infiles)
CB_Species.ValueMember = "Value";
CB_Species.DataSource = newlist;
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private readonly byte[][] files;
@ -186,6 +187,7 @@ private void B_Dump_Click(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void CHK_TypeBias_CheckedChanged(object sender, EventArgs e)

View File

@ -15,6 +15,7 @@ public MoveEditor6(byte[][] infiles)
InitializeComponent();
Setup();
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private byte[][] files;
private readonly string[] types = Main.Config.getText(TextName.Types);
@ -163,6 +164,7 @@ private void setEntry()
private void formClosing(object sender, FormClosingEventArgs e)
{
setEntry();
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void B_RandAll_Click(object sender, EventArgs e)

View File

@ -38,6 +38,7 @@ public PersonalEditor6(byte[][] infiles)
Setup(); //Turn string resources into arrays
CB_Species.SelectedIndex = 1;
RandSettings.GetFormSettings(this, TP_Randomizer.Controls);
}
#region Global Variables
private readonly string mode = Main.Config.ORAS ? "ORAS" : "XY";
@ -441,6 +442,7 @@ private void CHK_Ability_CheckedChanged(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
if (entry > -1) saveEntry();
RandSettings.SetFormSettings(this, TP_Randomizer.Controls);
}
}
}

View File

@ -270,6 +270,7 @@ public RSWE()
};
RSWE_Load();
openQuick(Directory.GetFiles("encdata"));
RandSettings.GetFormSettings(this, GB_Tweak.Controls);
}
private readonly ComboBox[] spec;
private readonly NumericUpDown[] min;

View File

@ -61,6 +61,7 @@ private void InitializeComponent()
this.L_Set2 = new System.Windows.Forms.Label();
this.CHK_Gen = new System.Windows.Forms.CheckBox();
this.CHK_BST = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
((System.ComponentModel.ISupportInitialize)(this.PB_G1_0)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G1_1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G1_2)).BeginInit();
@ -73,6 +74,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.PB_G4_2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G4_1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G4_0)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// PB_G1_0
@ -413,7 +415,7 @@ private void InitializeComponent()
// CHK_Gen
//
this.CHK_Gen.AutoSize = true;
this.CHK_Gen.Location = new System.Drawing.Point(93, 314);
this.CHK_Gen.Location = new System.Drawing.Point(16, 15);
this.CHK_Gen.Name = "CHK_Gen";
this.CHK_Gen.Size = new System.Drawing.Size(104, 17);
this.CHK_Gen.TabIndex = 471;
@ -425,20 +427,30 @@ private void InitializeComponent()
this.CHK_BST.AutoSize = true;
this.CHK_BST.Checked = true;
this.CHK_BST.CheckState = System.Windows.Forms.CheckState.Checked;
this.CHK_BST.Location = new System.Drawing.Point(93, 328);
this.CHK_BST.Location = new System.Drawing.Point(16, 29);
this.CHK_BST.Name = "CHK_BST";
this.CHK_BST.Size = new System.Drawing.Size(108, 17);
this.CHK_BST.TabIndex = 472;
this.CHK_BST.Text = "Keep Similar BST";
this.CHK_BST.UseVisualStyleBackColor = true;
//
// Starters
// groupBox1
//
this.groupBox1.Controls.Add(this.CHK_BST);
this.groupBox1.Controls.Add(this.CHK_Gen);
this.groupBox1.Location = new System.Drawing.Point(93, 306);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(200, 45);
this.groupBox1.TabIndex = 473;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Randomizer Settings";
//
// StarterEditor6
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(804, 352);
this.Controls.Add(this.CHK_BST);
this.Controls.Add(this.CHK_Gen);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.L_Set2);
this.Controls.Add(this.L_Set4);
this.Controls.Add(this.L_Set3);
@ -488,6 +500,8 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.PB_G4_2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G4_1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PB_G4_0)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -528,6 +542,6 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_Set2;
private System.Windows.Forms.CheckBox CHK_Gen;
private System.Windows.Forms.CheckBox CHK_BST;
private System.Windows.Forms.GroupBox groupBox1;
}
}

View File

@ -45,6 +45,7 @@ public StarterEditor6()
Width = Main.Config.ORAS ? Width : Width/2 + 2;
loadData();
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private readonly string CROPath = Path.Combine(Main.RomFSPath, "DllPoke3Select.cro");
private readonly string FieldPath = Path.Combine(Main.RomFSPath, "DllField.cro");
@ -62,6 +63,7 @@ public StarterEditor6()
private void B_Save_Click(object sender, EventArgs e)
{
saveData();
RandSettings.SetFormSettings(this, groupBox1.Controls);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)

View File

@ -32,6 +32,7 @@ public StaticEncounterEditor6()
foreach (string s in itemlist)
CB_HeldItem.Items.Add(s);
loadData();
RandSettings.GetFormSettings(this, tabPage2.Controls);
}
private readonly string FieldPath = Path.Combine(Main.RomFSPath, "DllField.cro");
private byte[] FieldData;
@ -45,6 +46,7 @@ private void B_Save_Click(object sender, EventArgs e)
{
saveEntry();
saveData();
RandSettings.SetFormSettings(this, tabPage2.Controls);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)

View File

@ -17,6 +17,7 @@ public TrainerRand()
foreach (string tclass in trClass.Where(tclass => !trClassnorep.Contains(tclass) && !tclass.StartsWith("[~")))
trClassnorep.Add(tclass);
trClassnorep.Sort();
RandSettings.GetFormSettings(this, Controls);
}
private string[] trName = Main.Config.getText(TextName.TrainerNames);
@ -103,6 +104,7 @@ private void B_Save_Click(object sender, EventArgs e)
RSTE.rSpeciesRand.Initialize();
RSTE.rDoRand = true;
RandSettings.SetFormSettings(this, Controls);
Close();
}

View File

@ -276,6 +276,7 @@ private void InitializeComponent()
this.label25 = new System.Windows.Forms.Label();
this.TabPage_Horde = new System.Windows.Forms.TabPage();
this.GB_Tweak = new System.Windows.Forms.GroupBox();
this.CHK_HomogeneousHordes = new System.Windows.Forms.CheckBox();
this.CHK_MegaForm = new System.Windows.Forms.CheckBox();
this.L_RandOpt = new System.Windows.Forms.Label();
this.CHK_BST = new System.Windows.Forms.CheckBox();
@ -562,7 +563,6 @@ private void InitializeComponent()
this.CB_FormeList = new System.Windows.Forms.ComboBox();
this.B_Randomize = new System.Windows.Forms.Button();
this.B_Dump = new System.Windows.Forms.Button();
this.CHK_HomogeneousHordes = new System.Windows.Forms.CheckBox();
this.TabControl_EncounterData.SuspendLayout();
this.TabPage_Land.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUP_RockSmashMax5)).BeginInit();
@ -15529,6 +15529,16 @@ private void InitializeComponent()
this.GB_Tweak.TabStop = false;
this.GB_Tweak.Text = "Extra Tweaks";
//
// CHK_HomogeneousHordes
//
this.CHK_HomogeneousHordes.AutoSize = true;
this.CHK_HomogeneousHordes.Location = new System.Drawing.Point(18, 97);
this.CHK_HomogeneousHordes.Name = "CHK_HomogeneousHordes";
this.CHK_HomogeneousHordes.Size = new System.Drawing.Size(133, 17);
this.CHK_HomogeneousHordes.TabIndex = 297;
this.CHK_HomogeneousHordes.Text = "Single Species Hordes";
this.CHK_HomogeneousHordes.UseVisualStyleBackColor = true;
//
// CHK_MegaForm
//
this.CHK_MegaForm.AutoSize = true;
@ -27918,16 +27928,6 @@ private void InitializeComponent()
this.B_Dump.UseVisualStyleBackColor = true;
this.B_Dump.Click += new System.EventHandler(this.B_Dump_Click);
//
// CHK_HomogeneousHordes
//
this.CHK_HomogeneousHordes.AutoSize = true;
this.CHK_HomogeneousHordes.Location = new System.Drawing.Point(18, 97);
this.CHK_HomogeneousHordes.Name = "CHK_HomogeneousHordes";
this.CHK_HomogeneousHordes.Size = new System.Drawing.Size(133, 17);
this.CHK_HomogeneousHordes.TabIndex = 297;
this.CHK_HomogeneousHordes.Text = "Single Species Hordes";
this.CHK_HomogeneousHordes.UseVisualStyleBackColor = true;
//
// XYWE
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -27946,6 +27946,7 @@ private void InitializeComponent()
this.MinimumSize = new System.Drawing.Size(964, 454);
this.Name = "XYWE";
this.Text = "XY Wild Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.XYWE_FormClosing);
this.Load += new System.EventHandler(this.PreloadTabs);
this.TabControl_EncounterData.ResumeLayout(false);
this.TabPage_Land.ResumeLayout(false);

View File

@ -275,6 +275,7 @@ public XYWE()
};
Load_XYWE();
openQuick(Directory.GetFiles("encdata"));
RandSettings.GetFormSettings(this, GB_Tweak.Controls);
}
private readonly ComboBox[] spec;
private readonly NumericUpDown[] min;
@ -660,5 +661,10 @@ private void modifyLevels(object sender, EventArgs e)
Enabled = true;
WinFormsUtil.Alert("Modified all Level ranges according to specification!", "Press the Dump Tables button to view the new Level ranges!");
}
private void XYWE_FormClosing(object sender, FormClosingEventArgs e)
{
RandSettings.SetFormSettings(this, GB_Tweak.Controls);
}
}
}

View File

@ -51,6 +51,7 @@ public EggMoveEditor7(byte[][] infiles)
CB_Species.DataSource = newlist;
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private readonly EggMoves7[] entries;
@ -170,6 +171,7 @@ private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
entries.Select(z => z.Write()).ToArray().CopyTo(files, 0);
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void B_Goto_Click(object sender, EventArgs e)

View File

@ -97,6 +97,7 @@ public EvolutionEditor7(byte[][] infiles)
CB_Species.Items.RemoveAt(0);
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, GB_Randomizer.Controls);
}
private readonly byte[][] files;
private readonly ComboBox[] pb, mb, rb;
@ -221,6 +222,7 @@ private void B_Dump_Click(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
RandSettings.SetFormSettings(this, GB_Randomizer.Controls);
}
private void changeMethod(object sender, EventArgs e)

View File

@ -40,6 +40,7 @@ public LevelUpEditor7(byte[][] infiles)
CB_Species.ValueMember = "Value";
CB_Species.DataSource = newlist;
CB_Species.SelectedIndex = 0;
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private readonly byte[][] files;
@ -183,6 +184,7 @@ private void B_Dump_Click(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
setList();
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void CHK_TypeBias_CheckedChanged(object sender, EventArgs e)

View File

@ -16,6 +16,7 @@ public MoveEditor7(byte[][] infiles)
InitializeComponent();
Setup();
RandSettings.GetFormSettings(this, groupBox1.Controls);
}
private byte[][] files;
private readonly string[] types = Main.Config.getText(TextName.Types);
@ -164,6 +165,7 @@ private void setEntry()
private void formClosing(object sender, FormClosingEventArgs e)
{
setEntry();
RandSettings.SetFormSettings(this, groupBox1.Controls);
}
private void B_RandAll_Click(object sender, EventArgs e)

View File

@ -33,6 +33,7 @@ public PersonalEditor7(byte[][] infiles)
Setup();
CB_Species.SelectedIndex = 1;
RandSettings.GetFormSettings(this, TP_Randomizer.Controls);
}
#region Global Variables
private readonly byte[][] files;
@ -431,6 +432,7 @@ private void CHK_Ability_CheckedChanged(object sender, EventArgs e)
private void formClosing(object sender, FormClosingEventArgs e)
{
if (entry > -1) saveEntry();
RandSettings.SetFormSettings(this, TP_Randomizer.Controls);
}
}
}

View File

@ -55,6 +55,7 @@ public SMTE(byte[][] trc, byte[][] trd, byte[][] trp)
CB_Moves.SelectedIndex = 0;
TrainerClasses_7 = Main.Config.USUM ? Legal.SpecialClasses_USUM : Legal.SpecialClasses_SM;
RandSettings.GetFormSettings(this, Tab_Misc.Controls);
}
private int GetSlot(object sender)
@ -401,6 +402,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
if (TrainerNames.Modified)
Main.Config.setText(TextName.TrainerNames, TrainerNames.Lines);
base.OnFormClosing(e);
RandSettings.SetFormSettings(this, Tab_Misc.Controls);
}
// Dumping

View File

@ -39,6 +39,9 @@ private void InitializeComponent()
this.L_Max = new System.Windows.Forms.Label();
this.L_Table = new System.Windows.Forms.Label();
this.GB_Encounters = new System.Windows.Forms.GroupBox();
this.B_PasteAll = new System.Windows.Forms.Button();
this.B_Paste = new System.Windows.Forms.Button();
this.B_Copy = new System.Windows.Forms.Button();
this.GB_Tweak = new System.Windows.Forms.GroupBox();
this.CB_SlotRand = new System.Windows.Forms.ComboBox();
this.L_SOS = new System.Windows.Forms.Label();
@ -256,9 +259,6 @@ private void InitializeComponent()
this.CB_TableID = new System.Windows.Forms.ComboBox();
this.B_Export = new System.Windows.Forms.Button();
this.CopySOS = new System.Windows.Forms.Button();
this.B_Copy = new System.Windows.Forms.Button();
this.B_Paste = new System.Windows.Forms.Button();
this.B_PasteAll = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.NUP_Min)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NUP_Max)).BeginInit();
this.GB_Encounters.SuspendLayout();
@ -688,6 +688,38 @@ private void InitializeComponent()
this.GB_Encounters.TabStop = false;
this.GB_Encounters.Text = "Encounters (100%)";
//
// B_PasteAll
//
this.B_PasteAll.Enabled = false;
this.B_PasteAll.Location = new System.Drawing.Point(206, 359);
this.B_PasteAll.Name = "B_PasteAll";
this.B_PasteAll.Size = new System.Drawing.Size(90, 40);
this.B_PasteAll.TabIndex = 510;
this.B_PasteAll.Text = "Paste To All (Location)";
this.B_PasteAll.UseVisualStyleBackColor = true;
this.B_PasteAll.Click += new System.EventHandler(this.B_PasteAll_Click);
//
// B_Paste
//
this.B_Paste.Enabled = false;
this.B_Paste.Location = new System.Drawing.Point(110, 359);
this.B_Paste.Name = "B_Paste";
this.B_Paste.Size = new System.Drawing.Size(90, 40);
this.B_Paste.TabIndex = 509;
this.B_Paste.Text = "Paste Current Table";
this.B_Paste.UseVisualStyleBackColor = true;
this.B_Paste.Click += new System.EventHandler(this.B_Paste_Click);
//
// B_Copy
//
this.B_Copy.Location = new System.Drawing.Point(14, 359);
this.B_Copy.Name = "B_Copy";
this.B_Copy.Size = new System.Drawing.Size(90, 40);
this.B_Copy.TabIndex = 508;
this.B_Copy.Text = "Copy Current Table";
this.B_Copy.UseVisualStyleBackColor = true;
this.B_Copy.Click += new System.EventHandler(this.B_Copy_Click);
//
// GB_Tweak
//
this.GB_Tweak.Controls.Add(this.CB_SlotRand);
@ -3052,38 +3084,6 @@ private void InitializeComponent()
this.CopySOS.UseVisualStyleBackColor = true;
this.CopySOS.Click += new System.EventHandler(this.CopySOS_Click);
//
// B_Copy
//
this.B_Copy.Location = new System.Drawing.Point(14, 359);
this.B_Copy.Name = "B_Copy";
this.B_Copy.Size = new System.Drawing.Size(90, 40);
this.B_Copy.TabIndex = 508;
this.B_Copy.Text = "Copy Current Table";
this.B_Copy.UseVisualStyleBackColor = true;
this.B_Copy.Click += new System.EventHandler(this.B_Copy_Click);
//
// B_Paste
//
this.B_Paste.Enabled = false;
this.B_Paste.Location = new System.Drawing.Point(110, 359);
this.B_Paste.Name = "B_Paste";
this.B_Paste.Size = new System.Drawing.Size(90, 40);
this.B_Paste.TabIndex = 509;
this.B_Paste.Text = "Paste Current Table";
this.B_Paste.UseVisualStyleBackColor = true;
this.B_Paste.Click += new System.EventHandler(this.B_Paste_Click);
//
// B_PasteAll
//
this.B_PasteAll.Enabled = false;
this.B_PasteAll.Location = new System.Drawing.Point(206, 359);
this.B_PasteAll.Name = "B_PasteAll";
this.B_PasteAll.Size = new System.Drawing.Size(90, 40);
this.B_PasteAll.TabIndex = 510;
this.B_PasteAll.Text = "Paste To All (Location)";
this.B_PasteAll.UseVisualStyleBackColor = true;
this.B_PasteAll.Click += new System.EventHandler(this.B_PasteAll_Click);
//
// SMWE
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -3105,6 +3105,7 @@ private void InitializeComponent()
this.Controls.Add(this.CB_LocationID);
this.Name = "SMWE";
this.Text = "Sun/Moon Wild Editor";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SMWE_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.NUP_Min)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NUP_Max)).EndInit();
this.GB_Encounters.ResumeLayout(false);

View File

@ -39,6 +39,7 @@ public SMWE(lzGARCFile ed, lzGARCFile zd, lzGARCFile wd)
Areas = areas.OrderBy(a => a.Zones[0].Name).ToArray();
LoadData();
RandSettings.GetFormSettings(this, GB_Tweak.Controls);
// ExportEncounters("um", "uu");
}
@ -530,6 +531,11 @@ private IEnumerable<byte[]> GetLocationDump(Dictionary<int, List<uint>> dict)
}
}
}
private void SMWE_FormClosing(object sender, FormClosingEventArgs e)
{
RandSettings.SetFormSettings(this, GB_Tweak.Controls);
}
}
public static partial class Extensions

View File

@ -125,6 +125,7 @@ public StaticEncounterEditor7(byte[][] infiles)
// Select last tab (Randomization) by default in case info already randomized.
TC_Tabs.SelectedIndex = TC_Tabs.TabCount - 1;
RandSettings.GetFormSettings(this, Tab_Randomizer.Controls);
// ExportEncounters();
}
private void getListBoxEntries()
@ -153,6 +154,7 @@ private void B_Save_Click(object sender, EventArgs e)
setEncounter();
setTrade();
saveData();
RandSettings.SetFormSettings(this, Tab_Randomizer.Controls);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)

View File

@ -35,14 +35,16 @@ public static string[] Save()
return result.ToArray();
}
public static void LoadFormSettings(Form form, Control.ControlCollection controls)
public static void GetFormSettings(Form form, Control.ControlCollection controls)
{
if (!Settings.TryGetValue(form.Name, out var list))
return;
foreach (Control ctrl in controls)
{
LoadFormSettings(form, ctrl.Controls);
GetFormSettings(form, ctrl.Controls);
if (string.IsNullOrWhiteSpace(ctrl.Name))
continue;
var pair = list.FirstOrDefault(z => ctrl.Name == z.Name);
if (pair == null)
continue;
@ -50,7 +52,7 @@ public static void LoadFormSettings(Form form, Control.ControlCollection control
TryGetValue(ctrl, pair.Value);
}
}
public static void SaveFormSettings(Form form, Control.ControlCollection controls)
public static void SetFormSettings(Form form, Control.ControlCollection controls)
{
if (!Settings.TryGetValue(form.Name, out var list))
{
@ -60,7 +62,9 @@ public static void SaveFormSettings(Form form, Control.ControlCollection control
foreach (Control ctrl in controls)
{
SaveFormSettings(form, ctrl.Controls);
SetFormSettings(form, ctrl.Controls);
if (string.IsNullOrWhiteSpace(ctrl.Name))
continue;
var pair = list.FirstOrDefault(z => ctrl.Name == z.Name) ?? new NameValue(ctrl.Name);
if (TrySetValue(ctrl, pair) && !list.Contains(pair))
list.Add(pair);