From ba184ba028dcd7c5f3c66209817a5d292f01551c Mon Sep 17 00:00:00 2001 From: starik222 Date: Sat, 30 Nov 2024 23:32:17 +0900 Subject: [PATCH] Fixed a bug that interrupted the autotagger if the model did not contain additional settings. #169 --- BooruDatasetTagManager/Form_AutoTaggerSettings.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BooruDatasetTagManager/Form_AutoTaggerSettings.cs b/BooruDatasetTagManager/Form_AutoTaggerSettings.cs index 95210f5..c11e48a 100644 --- a/BooruDatasetTagManager/Form_AutoTaggerSettings.cs +++ b/BooruDatasetTagManager/Form_AutoTaggerSettings.cs @@ -10,12 +10,14 @@ using System.Threading.Tasks; using System.Windows.Forms; using Manina.Windows.Forms; +using Microsoft.VisualBasic.Devices; namespace BooruDatasetTagManager { public partial class Form_AutoTaggerSettings : Form { private Dictionary interrogatorSettingsControls = new Dictionary(); + private List selectedInterrogators = new List(); private string ctrlPattern = "(.*?)_ctrl_(.*)"; public Form_AutoTaggerSettings() { @@ -214,6 +216,7 @@ private async Task CreateInterrogatorTabAsync(string name) MessageBox.Show(intParams.ErrMes, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } + selectedInterrogators.Add(name); Tab tab = new Tab(); tab.Name = name; tab.Text = name; @@ -293,6 +296,7 @@ private void RemoveTab(string name) { TaggerSettingTabs.Tabs.Remove(tab); } + selectedInterrogators.Remove(name); var ctrlsToRemove = interrogatorSettingsControls.Where(a => a.Key.StartsWith(name + "_ctrl")).Select(a => a.Key); foreach(var item in ctrlsToRemove) interrogatorSettingsControls.Remove(item); @@ -332,6 +336,15 @@ private void SetSavedSettingsToControls() private void SaveSettingsFromControls() { Program.Settings.AutoTagger.InterragatorParams.Clear(); + + foreach (var network in selectedInterrogators) + { + if (!Program.Settings.AutoTagger.InterragatorParams.ContainsKey(network)) + { + Program.Settings.AutoTagger.InterragatorParams.Add(network, new List()); + } + } + foreach (var item in interrogatorSettingsControls) { Regex r = new Regex(ctrlPattern, RegexOptions.Compiled);