From 51711bb65909c6ca88baeafe0acb5c11d5f90b25 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 7 Feb 2026 02:30:03 -0600 Subject: [PATCH] Extract entity filters UserControl, add Nickname Introduce nickname searching and a reusable EntitySearchControl UI. SearchSettings: add Nickname property, centralize search predicate creation Add SatisfiesFilterNickname that reads the PKM nickname (stackalloc buffer) and performs a case-insensitive substring match. --- PKHeX.Core/PKM/Searching/SearchSettings.cs | 32 +- PKHeX.Core/PKM/Searching/SearchUtil.cs | 10 + .../Controls/EntitySearchControl.Designer.cs | 719 ++++++++++++++++++ .../Controls/EntitySearchControl.cs | 219 ++++++ .../Subforms/SAV_Database.Designer.cs | 653 +--------------- PKHeX.WinForms/Subforms/SAV_Database.cs | 167 +--- 6 files changed, 990 insertions(+), 810 deletions(-) create mode 100644 PKHeX.WinForms/Controls/EntitySearchControl.Designer.cs create mode 100644 PKHeX.WinForms/Controls/EntitySearchControl.cs diff --git a/PKHeX.Core/PKM/Searching/SearchSettings.cs b/PKHeX.Core/PKM/Searching/SearchSettings.cs index 44f53d22d..1b1f25a29 100644 --- a/PKHeX.Core/PKM/Searching/SearchSettings.cs +++ b/PKHeX.Core/PKM/Searching/SearchSettings.cs @@ -14,6 +14,7 @@ public sealed class SearchSettings public byte Format { get; init; } public byte Generation { get; init; } public required ushort Species { get; init; } + public string Nickname { get; init; } = string.Empty; public int Ability { get; init; } = -1; public Nature Nature { get; init; } = Nature.Random; public int Item { get; init; } = -1; @@ -63,9 +64,11 @@ public void AddMove(ushort move) /// Search results that match all criteria public IEnumerable Search(IEnumerable list) { - InitializeFilters(); - var result = SearchInner(list); + var predicate = CreateSearchPredicate(); + var result = SearchInner(list, predicate); + // Run cross-comparison checks. + // This is done after all other filters to minimize the number of comparisons needed. if (SearchClones != CloneDetectionMethod.None) { var method = SearchUtil.GetCloneDetectMethod(SearchClones); @@ -82,9 +85,11 @@ public IEnumerable Search(IEnumerable list) /// Search results that match all criteria public IEnumerable Search(IEnumerable list) { - InitializeFilters(); - var result = SearchInner(list); + var predicate = CreateSearchPredicate(); + var result = SearchInner(list, predicate); + // Run cross-comparison checks. + // This is done after all other filters to minimize the number of comparisons needed. if (SearchClones != CloneDetectionMethod.None) { var method = SearchUtil.GetCloneDetectMethod(SearchClones); @@ -105,29 +110,38 @@ private void InitializeFilters() BatchFiltersMeta = meta; } - private IEnumerable SearchInner(IEnumerable list) + private static IEnumerable SearchInner(IEnumerable list, Func predicate) { foreach (var pk in list) { - if (!IsSearchMatch(pk)) + if (!predicate(pk)) continue; yield return pk; } } - private IEnumerable SearchInner(IEnumerable list) + private IEnumerable SearchInner(IEnumerable list, Func predicate) { foreach (var entry in list) { var pk = entry.Entity; if (BatchFiltersMeta.Count != 0 && !BatchEditing.IsFilterMatchMeta(BatchFiltersMeta, entry)) continue; - if (!IsSearchMatch(pk)) + if (!predicate(pk)) continue; yield return entry; } } + /// + /// Creates a predicate that evaluates a against this search settings instance. + /// + public Func CreateSearchPredicate() + { + InitializeFilters(); + return IsSearchMatch; + } + private bool IsSearchMatch(PKM pk) { if (!SearchSimple(pk)) @@ -159,6 +173,8 @@ private bool SearchSimple(PKM pk) return false; if (Version.IsValidSavedVersion() && pk.Version != Version) return false; + if (!string.IsNullOrWhiteSpace(Nickname) && !SearchUtil.SatisfiesFilterNickname(pk, Nickname)) + return false; return true; } diff --git a/PKHeX.Core/PKM/Searching/SearchUtil.cs b/PKHeX.Core/PKM/Searching/SearchUtil.cs index bf14cd4fd..fbef8f6fa 100644 --- a/PKHeX.Core/PKM/Searching/SearchUtil.cs +++ b/PKHeX.Core/PKM/Searching/SearchUtil.cs @@ -120,4 +120,14 @@ public static IEnumerable GetExtraClones(IEnumerable db, Func nicknameSubstring) + { + Span name = stackalloc char[pk.MaxStringLengthNickname]; + int length = pk.LoadString(pk.NicknameTrash, name); + name = name[..length]; + + // Compare the nickname filter against the PKM's nickname, ignoring case. + return name.Contains(nicknameSubstring, StringComparison.OrdinalIgnoreCase); + } } diff --git a/PKHeX.WinForms/Controls/EntitySearchControl.Designer.cs b/PKHeX.WinForms/Controls/EntitySearchControl.Designer.cs new file mode 100644 index 000000000..4d7b00734 --- /dev/null +++ b/PKHeX.WinForms/Controls/EntitySearchControl.Designer.cs @@ -0,0 +1,719 @@ +namespace PKHeX.WinForms.Controls +{ + partial class EntitySearchControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + CB_Ability = new System.Windows.Forms.ComboBox(); + CB_HeldItem = new System.Windows.Forms.ComboBox(); + CB_Nature = new System.Windows.Forms.ComboBox(); + CB_Species = new System.Windows.Forms.ComboBox(); + TB_Nickname = new System.Windows.Forms.TextBox(); + CB_Move4 = new System.Windows.Forms.ComboBox(); + CB_Move3 = new System.Windows.Forms.ComboBox(); + CB_Move2 = new System.Windows.Forms.ComboBox(); + CB_Move1 = new System.Windows.Forms.ComboBox(); + TB_Level = new System.Windows.Forms.MaskedTextBox(); + Label_CurLevel = new System.Windows.Forms.Label(); + Label_HeldItem = new System.Windows.Forms.Label(); + Label_Ability = new System.Windows.Forms.Label(); + Label_Nature = new System.Windows.Forms.Label(); + Label_Species = new System.Windows.Forms.Label(); + Label_Nickname = new System.Windows.Forms.Label(); + CB_EVTrain = new System.Windows.Forms.ComboBox(); + CB_HPType = new System.Windows.Forms.ComboBox(); + Label_HiddenPowerPrefix = new System.Windows.Forms.Label(); + CB_GameOrigin = new System.Windows.Forms.ComboBox(); + CB_IV = new System.Windows.Forms.ComboBox(); + CB_Level = new System.Windows.Forms.ComboBox(); + L_Version = new System.Windows.Forms.Label(); + L_Move1 = new System.Windows.Forms.Label(); + L_Move2 = new System.Windows.Forms.Label(); + L_Move3 = new System.Windows.Forms.Label(); + L_Move4 = new System.Windows.Forms.Label(); + L_Potential = new System.Windows.Forms.Label(); + L_EVTraining = new System.Windows.Forms.Label(); + L_Generation = new System.Windows.Forms.Label(); + CB_Generation = new System.Windows.Forms.ComboBox(); + FLP_Egg = new System.Windows.Forms.FlowLayoutPanel(); + CHK_IsEgg = new System.Windows.Forms.CheckBox(); + L_ESV = new System.Windows.Forms.Label(); + MT_ESV = new System.Windows.Forms.MaskedTextBox(); + CHK_Shiny = new System.Windows.Forms.CheckBox(); + TLP_Filters = new System.Windows.Forms.TableLayoutPanel(); + FLP_Format = new System.Windows.Forms.FlowLayoutPanel(); + CB_FormatComparator = new System.Windows.Forms.ComboBox(); + CB_Format = new System.Windows.Forms.ComboBox(); + L_Format = new System.Windows.Forms.Label(); + FLP_Level = new System.Windows.Forms.FlowLayoutPanel(); + FLP_Egg.SuspendLayout(); + TLP_Filters.SuspendLayout(); + FLP_Format.SuspendLayout(); + FLP_Level.SuspendLayout(); + SuspendLayout(); + // + // CB_Ability + // + CB_Ability.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Ability.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Ability.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Ability.FormattingEnabled = true; + CB_Ability.Items.AddRange(new object[] { "Item" }); + CB_Ability.Location = new System.Drawing.Point(101, 104); + CB_Ability.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Ability.Name = "CB_Ability"; + CB_Ability.Size = new System.Drawing.Size(142, 25); + CB_Ability.TabIndex = 70; + // + // CB_HeldItem + // + CB_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_HeldItem.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_HeldItem.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_HeldItem.FormattingEnabled = true; + CB_HeldItem.Location = new System.Drawing.Point(101, 78); + CB_HeldItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_HeldItem.Name = "CB_HeldItem"; + CB_HeldItem.Size = new System.Drawing.Size(142, 25); + CB_HeldItem.TabIndex = 69; + // + // CB_Nature + // + CB_Nature.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Nature.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Nature.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Nature.FormattingEnabled = true; + CB_Nature.Location = new System.Drawing.Point(101, 52); + CB_Nature.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Nature.Name = "CB_Nature"; + CB_Nature.Size = new System.Drawing.Size(142, 25); + CB_Nature.TabIndex = 68; + // + // CB_Species + // + CB_Species.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Species.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Species.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Species.FormattingEnabled = true; + CB_Species.Location = new System.Drawing.Point(101, 26); + CB_Species.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Species.Name = "CB_Species"; + CB_Species.Size = new System.Drawing.Size(142, 25); + CB_Species.TabIndex = 67; + // + // TB_Nickname + // + TB_Nickname.Anchor = System.Windows.Forms.AnchorStyles.Left; + TB_Nickname.Location = new System.Drawing.Point(101, 52); + TB_Nickname.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + TB_Nickname.Name = "TB_Nickname"; + TB_Nickname.Size = new System.Drawing.Size(142, 25); + TB_Nickname.TabIndex = 68; + // + // CB_Move4 + // + CB_Move4.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Move4.FormattingEnabled = true; + CB_Move4.Location = new System.Drawing.Point(101, 312); + CB_Move4.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Move4.Name = "CB_Move4"; + CB_Move4.Size = new System.Drawing.Size(142, 25); + CB_Move4.TabIndex = 74; + // + // CB_Move3 + // + CB_Move3.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Move3.FormattingEnabled = true; + CB_Move3.Location = new System.Drawing.Point(101, 286); + CB_Move3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Move3.Name = "CB_Move3"; + CB_Move3.Size = new System.Drawing.Size(142, 25); + CB_Move3.TabIndex = 73; + // + // CB_Move2 + // + CB_Move2.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Move2.FormattingEnabled = true; + CB_Move2.Location = new System.Drawing.Point(101, 260); + CB_Move2.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Move2.Name = "CB_Move2"; + CB_Move2.Size = new System.Drawing.Size(142, 25); + CB_Move2.TabIndex = 72; + // + // CB_Move1 + // + CB_Move1.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_Move1.FormattingEnabled = true; + CB_Move1.Location = new System.Drawing.Point(101, 234); + CB_Move1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Move1.Name = "CB_Move1"; + CB_Move1.Size = new System.Drawing.Size(142, 25); + CB_Move1.TabIndex = 71; + // + // TB_Level + // + TB_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; + TB_Level.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + TB_Level.Location = new System.Drawing.Point(0, 0); + TB_Level.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + TB_Level.Mask = "000"; + TB_Level.Name = "TB_Level"; + TB_Level.Size = new System.Drawing.Size(25, 25); + TB_Level.TabIndex = 89; + TB_Level.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // Label_CurLevel + // + Label_CurLevel.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_CurLevel.AutoSize = true; + Label_CurLevel.Location = new System.Drawing.Point(57, 134); + Label_CurLevel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_CurLevel.Name = "Label_CurLevel"; + Label_CurLevel.Size = new System.Drawing.Size(40, 17); + Label_CurLevel.TabIndex = 88; + Label_CurLevel.Text = "Level:"; + Label_CurLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // Label_HeldItem + // + Label_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_HeldItem.AutoSize = true; + Label_HeldItem.Location = new System.Drawing.Point(30, 82); + Label_HeldItem.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_HeldItem.Name = "Label_HeldItem"; + Label_HeldItem.Size = new System.Drawing.Size(67, 17); + Label_HeldItem.TabIndex = 93; + Label_HeldItem.Text = "Held Item:"; + Label_HeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // Label_Ability + // + Label_Ability.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_Ability.AutoSize = true; + Label_Ability.Location = new System.Drawing.Point(51, 108); + Label_Ability.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_Ability.Name = "Label_Ability"; + Label_Ability.Size = new System.Drawing.Size(46, 17); + Label_Ability.TabIndex = 92; + Label_Ability.Text = "Ability:"; + Label_Ability.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // Label_Nature + // + Label_Nature.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_Nature.AutoSize = true; + Label_Nature.Location = new System.Drawing.Point(46, 56); + Label_Nature.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_Nature.Name = "Label_Nature"; + Label_Nature.Size = new System.Drawing.Size(51, 17); + Label_Nature.TabIndex = 91; + Label_Nature.Text = "Nature:"; + Label_Nature.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // Label_Species + // + Label_Species.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_Species.AutoSize = true; + Label_Species.Location = new System.Drawing.Point(42, 30); + Label_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_Species.Name = "Label_Species"; + Label_Species.Size = new System.Drawing.Size(55, 17); + Label_Species.TabIndex = 90; + Label_Species.Text = "Species:"; + Label_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // Label_Nickname + // + Label_Nickname.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_Nickname.AutoSize = true; + Label_Nickname.Location = new System.Drawing.Point(20, 56); + Label_Nickname.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_Nickname.Name = "Label_Nickname"; + Label_Nickname.Size = new System.Drawing.Size(77, 17); + Label_Nickname.TabIndex = 91; + Label_Nickname.Text = "Nickname:"; + Label_Nickname.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // CB_EVTrain + // + CB_EVTrain.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_EVTrain.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_EVTrain.DropDownWidth = 85; + CB_EVTrain.FormattingEnabled = true; + CB_EVTrain.Items.AddRange(new object[] { "Any", "None (0)", "Some (127-1)", "Half (128-507)", "Full (508+)" }); + CB_EVTrain.Location = new System.Drawing.Point(101, 182); + CB_EVTrain.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_EVTrain.Name = "CB_EVTrain"; + CB_EVTrain.Size = new System.Drawing.Size(109, 25); + CB_EVTrain.TabIndex = 94; + // + // CB_HPType + // + CB_HPType.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_HPType.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; + CB_HPType.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; + CB_HPType.DropDownWidth = 80; + CB_HPType.FormattingEnabled = true; + CB_HPType.Location = new System.Drawing.Point(101, 208); + CB_HPType.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_HPType.Name = "CB_HPType"; + CB_HPType.Size = new System.Drawing.Size(142, 25); + CB_HPType.TabIndex = 96; + // + // Label_HiddenPowerPrefix + // + Label_HiddenPowerPrefix.Anchor = System.Windows.Forms.AnchorStyles.Right; + Label_HiddenPowerPrefix.AutoSize = true; + Label_HiddenPowerPrefix.Location = new System.Drawing.Point(4, 212); + Label_HiddenPowerPrefix.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + Label_HiddenPowerPrefix.Name = "Label_HiddenPowerPrefix"; + Label_HiddenPowerPrefix.Size = new System.Drawing.Size(93, 17); + Label_HiddenPowerPrefix.TabIndex = 95; + Label_HiddenPowerPrefix.Text = "Hidden Power:"; + Label_HiddenPowerPrefix.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // CB_GameOrigin + // + CB_GameOrigin.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_GameOrigin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_GameOrigin.FormattingEnabled = true; + CB_GameOrigin.Location = new System.Drawing.Point(101, 338); + CB_GameOrigin.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_GameOrigin.Name = "CB_GameOrigin"; + CB_GameOrigin.Size = new System.Drawing.Size(142, 25); + CB_GameOrigin.TabIndex = 97; + CB_GameOrigin.SelectedIndexChanged += ChangeGame; + // + // CB_IV + // + CB_IV.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_IV.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_IV.DropDownWidth = 85; + CB_IV.FormattingEnabled = true; + CB_IV.Items.AddRange(new object[] { "Any", "<= 90", "91-120", "121-150", "151-179", "180+", "== 186" }); + CB_IV.Location = new System.Drawing.Point(101, 156); + CB_IV.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_IV.Name = "CB_IV"; + CB_IV.Size = new System.Drawing.Size(109, 25); + CB_IV.TabIndex = 100; + // + // CB_Level + // + CB_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Level.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_Level.DropDownWidth = 85; + CB_Level.FormattingEnabled = true; + CB_Level.Items.AddRange(new object[] { "Any", "==", ">=", "<=" }); + CB_Level.Location = new System.Drawing.Point(25, 0); + CB_Level.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Level.Name = "CB_Level"; + CB_Level.Size = new System.Drawing.Size(76, 25); + CB_Level.TabIndex = 103; + CB_Level.SelectedIndexChanged += ChangeLevel; + // + // L_Version + // + L_Version.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Version.AutoSize = true; + L_Version.Location = new System.Drawing.Point(23, 342); + L_Version.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Version.Name = "L_Version"; + L_Version.Size = new System.Drawing.Size(74, 17); + L_Version.TabIndex = 104; + L_Version.Text = "OT Version:"; + L_Version.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Move1 + // + L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Move1.AutoSize = true; + L_Move1.Location = new System.Drawing.Point(42, 238); + L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Move1.Name = "L_Move1"; + L_Move1.Size = new System.Drawing.Size(55, 17); + L_Move1.TabIndex = 105; + L_Move1.Text = "Move 1:"; + L_Move1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Move2 + // + L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Move2.AutoSize = true; + L_Move2.Location = new System.Drawing.Point(42, 264); + L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Move2.Name = "L_Move2"; + L_Move2.Size = new System.Drawing.Size(55, 17); + L_Move2.TabIndex = 106; + L_Move2.Text = "Move 2:"; + L_Move2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Move3 + // + L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Move3.AutoSize = true; + L_Move3.Location = new System.Drawing.Point(42, 290); + L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Move3.Name = "L_Move3"; + L_Move3.Size = new System.Drawing.Size(55, 17); + L_Move3.TabIndex = 107; + L_Move3.Text = "Move 3:"; + L_Move3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Move4 + // + L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Move4.AutoSize = true; + L_Move4.Location = new System.Drawing.Point(42, 316); + L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Move4.Name = "L_Move4"; + L_Move4.Size = new System.Drawing.Size(55, 17); + L_Move4.TabIndex = 108; + L_Move4.Text = "Move 4:"; + L_Move4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Potential + // + L_Potential.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Potential.AutoSize = true; + L_Potential.Location = new System.Drawing.Point(21, 160); + L_Potential.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Potential.Name = "L_Potential"; + L_Potential.Size = new System.Drawing.Size(76, 17); + L_Potential.TabIndex = 109; + L_Potential.Text = "IV Potential:"; + L_Potential.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_EVTraining + // + L_EVTraining.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_EVTraining.AutoSize = true; + L_EVTraining.Location = new System.Drawing.Point(21, 186); + L_EVTraining.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_EVTraining.Name = "L_EVTraining"; + L_EVTraining.Size = new System.Drawing.Size(76, 17); + L_EVTraining.TabIndex = 110; + L_EVTraining.Text = "EV Training:"; + L_EVTraining.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // L_Generation + // + L_Generation.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Generation.AutoSize = true; + L_Generation.Location = new System.Drawing.Point(22, 368); + L_Generation.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Generation.Name = "L_Generation"; + L_Generation.Size = new System.Drawing.Size(75, 17); + L_Generation.TabIndex = 116; + L_Generation.Text = "Generation:"; + L_Generation.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // CB_Generation + // + CB_Generation.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Generation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_Generation.FormattingEnabled = true; + CB_Generation.Items.AddRange(new object[] { "Any", "Gen 1 (RBY/GSC)", "Gen 2 (RBY/GSC)", "Gen 3 (RSE/FRLG/CXD)", "Gen 4 (DPPt/HGSS)", "Gen 5 (BW/B2W2)", "Gen 6 (XY/ORAS)", "Gen 7 (SM/USUM/LGPE)", "Gen 8 (SWSH/BDSP/LA)", "Gen 9 (SV)" }); + CB_Generation.Location = new System.Drawing.Point(101, 364); + CB_Generation.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Generation.Name = "CB_Generation"; + CB_Generation.Size = new System.Drawing.Size(142, 25); + CB_Generation.TabIndex = 115; + CB_Generation.SelectedIndexChanged += ChangeGeneration; + // + // FLP_Egg + // + FLP_Egg.Anchor = System.Windows.Forms.AnchorStyles.Left; + FLP_Egg.AutoSize = true; + FLP_Egg.Controls.Add(CHK_IsEgg); + FLP_Egg.Controls.Add(L_ESV); + FLP_Egg.Controls.Add(MT_ESV); + FLP_Egg.Location = new System.Drawing.Point(101, 0); + FLP_Egg.Margin = new System.Windows.Forms.Padding(0); + FLP_Egg.Name = "FLP_Egg"; + FLP_Egg.Size = new System.Drawing.Size(136, 26); + FLP_Egg.TabIndex = 120; + // + // CHK_IsEgg + // + CHK_IsEgg.Anchor = System.Windows.Forms.AnchorStyles.Left; + CHK_IsEgg.AutoSize = true; + CHK_IsEgg.Checked = true; + CHK_IsEgg.CheckState = System.Windows.Forms.CheckState.Indeterminate; + CHK_IsEgg.Location = new System.Drawing.Point(0, 4); + CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1); + CHK_IsEgg.Name = "CHK_IsEgg"; + CHK_IsEgg.Size = new System.Drawing.Size(50, 21); + CHK_IsEgg.TabIndex = 98; + CHK_IsEgg.Text = "Egg"; + CHK_IsEgg.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + CHK_IsEgg.ThreeState = true; + CHK_IsEgg.UseVisualStyleBackColor = true; + CHK_IsEgg.CheckStateChanged += ToggleESV; + // + // L_ESV + // + L_ESV.Anchor = System.Windows.Forms.AnchorStyles.Left; + L_ESV.Location = new System.Drawing.Point(50, 3); + L_ESV.Margin = new System.Windows.Forms.Padding(0); + L_ESV.Name = "L_ESV"; + L_ESV.Size = new System.Drawing.Size(50, 20); + L_ESV.TabIndex = 113; + L_ESV.Text = "ESV:"; + L_ESV.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + L_ESV.Visible = false; + // + // MT_ESV + // + MT_ESV.Anchor = System.Windows.Forms.AnchorStyles.Left; + MT_ESV.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + MT_ESV.Location = new System.Drawing.Point(100, 0); + MT_ESV.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + MT_ESV.Mask = "0000"; + MT_ESV.Name = "MT_ESV"; + MT_ESV.Size = new System.Drawing.Size(36, 25); + MT_ESV.TabIndex = 112; + MT_ESV.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + MT_ESV.Visible = false; + // + // CHK_Shiny + // + CHK_Shiny.Anchor = System.Windows.Forms.AnchorStyles.Right; + CHK_Shiny.AutoSize = true; + CHK_Shiny.Checked = true; + CHK_Shiny.CheckState = System.Windows.Forms.CheckState.Indeterminate; + CHK_Shiny.Location = new System.Drawing.Point(44, 4); + CHK_Shiny.Margin = new System.Windows.Forms.Padding(0, 4, 0, 1); + CHK_Shiny.Name = "CHK_Shiny"; + CHK_Shiny.Size = new System.Drawing.Size(57, 21); + CHK_Shiny.TabIndex = 99; + CHK_Shiny.Text = "Shiny"; + CHK_Shiny.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + CHK_Shiny.ThreeState = true; + CHK_Shiny.UseVisualStyleBackColor = true; + // + // TLP_Filters + // + TLP_Filters.AutoScroll = true; + TLP_Filters.AutoScrollMargin = new System.Drawing.Size(3, 3); + TLP_Filters.AutoSize = true; + TLP_Filters.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + TLP_Filters.ColumnCount = 2; + TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + TLP_Filters.Controls.Add(FLP_Format, 1, 16); + TLP_Filters.Controls.Add(L_Format, 0, 16); + TLP_Filters.Controls.Add(FLP_Egg, 1, 0); + TLP_Filters.Controls.Add(CHK_Shiny, 0, 0); + TLP_Filters.Controls.Add(Label_Species, 0, 1); + TLP_Filters.Controls.Add(CB_Species, 1, 1); + TLP_Filters.Controls.Add(Label_Nickname, 0, 2); + TLP_Filters.Controls.Add(TB_Nickname, 1, 2); + TLP_Filters.Controls.Add(Label_Nature, 0, 3); + TLP_Filters.Controls.Add(CB_Nature, 1, 3); + TLP_Filters.Controls.Add(Label_HeldItem, 0, 4); + TLP_Filters.Controls.Add(CB_HeldItem, 1, 4); + TLP_Filters.Controls.Add(Label_Ability, 0, 5); + TLP_Filters.Controls.Add(CB_Ability, 1, 5); + TLP_Filters.Controls.Add(FLP_Level, 1, 6); + TLP_Filters.Controls.Add(Label_CurLevel, 0, 6); + TLP_Filters.Controls.Add(L_Potential, 0, 7); + TLP_Filters.Controls.Add(CB_IV, 1, 7); + TLP_Filters.Controls.Add(L_EVTraining, 0, 8); + TLP_Filters.Controls.Add(CB_EVTrain, 1, 8); + TLP_Filters.Controls.Add(Label_HiddenPowerPrefix, 0, 9); + TLP_Filters.Controls.Add(CB_HPType, 1, 9); + TLP_Filters.Controls.Add(L_Move1, 0, 10); + TLP_Filters.Controls.Add(CB_Move1, 1, 10); + TLP_Filters.Controls.Add(L_Move2, 0, 11); + TLP_Filters.Controls.Add(CB_Move2, 1, 11); + TLP_Filters.Controls.Add(L_Move3, 0, 12); + TLP_Filters.Controls.Add(CB_Move3, 1, 12); + TLP_Filters.Controls.Add(L_Move4, 0, 13); + TLP_Filters.Controls.Add(CB_Move4, 1, 13); + TLP_Filters.Controls.Add(L_Version, 0, 14); + TLP_Filters.Controls.Add(CB_GameOrigin, 1, 14); + TLP_Filters.Controls.Add(L_Generation, 0, 15); + TLP_Filters.Controls.Add(CB_Generation, 1, 15); + TLP_Filters.Dock = System.Windows.Forms.DockStyle.Fill; + TLP_Filters.Location = new System.Drawing.Point(0, 0); + TLP_Filters.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + TLP_Filters.Name = "TLP_Filters"; + TLP_Filters.RowCount = 18; + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); + TLP_Filters.Size = new System.Drawing.Size(292, 471); + TLP_Filters.TabIndex = 118; + // + // FLP_Format + // + FLP_Format.AutoSize = true; + FLP_Format.Controls.Add(CB_FormatComparator); + FLP_Format.Controls.Add(CB_Format); + FLP_Format.Location = new System.Drawing.Point(101, 390); + FLP_Format.Margin = new System.Windows.Forms.Padding(0); + FLP_Format.Name = "FLP_Format"; + FLP_Format.Size = new System.Drawing.Size(141, 26); + FLP_Format.TabIndex = 124; + // + // CB_FormatComparator + // + CB_FormatComparator.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_FormatComparator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_FormatComparator.FormattingEnabled = true; + CB_FormatComparator.Items.AddRange(new object[] { "Any", "==", ">=", "<=" }); + CB_FormatComparator.Location = new System.Drawing.Point(0, 0); + CB_FormatComparator.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_FormatComparator.Name = "CB_FormatComparator"; + CB_FormatComparator.Size = new System.Drawing.Size(62, 25); + CB_FormatComparator.TabIndex = 122; + CB_FormatComparator.SelectedIndexChanged += ChangeFormatFilter; + // + // CB_Format + // + CB_Format.Anchor = System.Windows.Forms.AnchorStyles.Left; + CB_Format.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + CB_Format.FormattingEnabled = true; + CB_Format.Items.AddRange(new object[] { "Any", ".pk9", ".pk8", ".pk7", ".pk6", ".pk5", ".pk4", ".pk3", ".pk2", ".pk1" }); + CB_Format.Location = new System.Drawing.Point(62, 0); + CB_Format.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); + CB_Format.Name = "CB_Format"; + CB_Format.Size = new System.Drawing.Size(79, 25); + CB_Format.TabIndex = 121; + CB_Format.Visible = false; + // + // L_Format + // + L_Format.Anchor = System.Windows.Forms.AnchorStyles.Right; + L_Format.AutoSize = true; + L_Format.Location = new System.Drawing.Point(45, 394); + L_Format.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + L_Format.Name = "L_Format"; + L_Format.Size = new System.Drawing.Size(52, 17); + L_Format.TabIndex = 122; + L_Format.Text = "Format:"; + L_Format.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // FLP_Level + // + FLP_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; + FLP_Level.AutoSize = true; + FLP_Level.Controls.Add(TB_Level); + FLP_Level.Controls.Add(CB_Level); + FLP_Level.Location = new System.Drawing.Point(101, 130); + FLP_Level.Margin = new System.Windows.Forms.Padding(0); + FLP_Level.Name = "FLP_Level"; + FLP_Level.Size = new System.Drawing.Size(101, 26); + FLP_Level.TabIndex = 119; + // + // EntitySearchControl + // + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; + AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + Controls.Add(TLP_Filters); + Name = "EntitySearchControl"; + Size = new System.Drawing.Size(292, 471); + FLP_Egg.ResumeLayout(false); + FLP_Egg.PerformLayout(); + TLP_Filters.ResumeLayout(false); + TLP_Filters.PerformLayout(); + FLP_Format.ResumeLayout(false); + FLP_Level.ResumeLayout(false); + FLP_Level.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.ComboBox CB_Ability; + private System.Windows.Forms.ComboBox CB_HeldItem; + private System.Windows.Forms.ComboBox CB_Nature; + private System.Windows.Forms.ComboBox CB_Species; + private System.Windows.Forms.TextBox TB_Nickname; + private System.Windows.Forms.ComboBox CB_Move4; + private System.Windows.Forms.ComboBox CB_Move3; + private System.Windows.Forms.ComboBox CB_Move2; + private System.Windows.Forms.ComboBox CB_Move1; + private System.Windows.Forms.MaskedTextBox TB_Level; + private System.Windows.Forms.Label Label_CurLevel; + private System.Windows.Forms.Label Label_HeldItem; + private System.Windows.Forms.Label Label_Ability; + private System.Windows.Forms.Label Label_Nature; + private System.Windows.Forms.Label Label_Species; + private System.Windows.Forms.Label Label_Nickname; + private System.Windows.Forms.ComboBox CB_EVTrain; + private System.Windows.Forms.ComboBox CB_HPType; + private System.Windows.Forms.Label Label_HiddenPowerPrefix; + private System.Windows.Forms.ComboBox CB_GameOrigin; + private System.Windows.Forms.ComboBox CB_IV; + private System.Windows.Forms.ComboBox CB_Level; + private System.Windows.Forms.Label L_Version; + private System.Windows.Forms.Label L_Move1; + private System.Windows.Forms.Label L_Move2; + private System.Windows.Forms.Label L_Move3; + private System.Windows.Forms.Label L_Move4; + private System.Windows.Forms.Label L_Potential; + private System.Windows.Forms.Label L_EVTraining; + private System.Windows.Forms.Label L_Generation; + private System.Windows.Forms.ComboBox CB_Generation; + private System.Windows.Forms.FlowLayoutPanel FLP_Egg; + private System.Windows.Forms.CheckBox CHK_IsEgg; + private System.Windows.Forms.Label L_ESV; + private System.Windows.Forms.MaskedTextBox MT_ESV; + private System.Windows.Forms.CheckBox CHK_Shiny; + private System.Windows.Forms.TableLayoutPanel TLP_Filters; + private System.Windows.Forms.FlowLayoutPanel FLP_Format; + private System.Windows.Forms.ComboBox CB_FormatComparator; + private System.Windows.Forms.ComboBox CB_Format; + private System.Windows.Forms.Label L_Format; + private System.Windows.Forms.FlowLayoutPanel FLP_Level; + } +} diff --git a/PKHeX.WinForms/Controls/EntitySearchControl.cs b/PKHeX.WinForms/Controls/EntitySearchControl.cs new file mode 100644 index 000000000..db0934ddc --- /dev/null +++ b/PKHeX.WinForms/Controls/EntitySearchControl.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using PKHeX.Core; +using PKHeX.Core.Searching; +using static PKHeX.Core.MessageStrings; + +namespace PKHeX.WinForms.Controls; + +public partial class EntitySearchControl : UserControl +{ + public int MaxFormat { get; set; } = Latest.Generation; + public int SaveGeneration { get; set; } = Latest.Generation; + + public EntitySearchControl() => InitializeComponent(); + + public int FormatComparatorSelectedIndex + { + get => CB_FormatComparator.SelectedIndex; + set => CB_FormatComparator.SelectedIndex = value; + } + + /// + /// Creates a filter function based on the current search settings, including any batch instructions. + /// + /// Optional batch instructions to include in the search settings. + public Func GetFilter(string batchInstructions = "") + => CreateSearchSettings(batchInstructions).CreateSearchPredicate(); + + /// + /// Populates combo box bindings with game data sources. + /// + public void PopulateComboBoxes() + { + CB_HeldItem.InitializeBinding(); + CB_Species.InitializeBinding(); + CB_Ability.InitializeBinding(); + CB_Nature.InitializeBinding(); + CB_GameOrigin.InitializeBinding(); + CB_HPType.InitializeBinding(); + + var comboAny = new ComboItem(MsgAny, -1); + + var filtered = GameInfo.FilteredSources; + var source = filtered.Source; + var species = new List(source.SpeciesDataSource) + { + [0] = comboAny + }; + CB_Species.DataSource = species; + + var items = new List(filtered.Items); + items.Insert(0, comboAny); + CB_HeldItem.DataSource = items; + + var natures = new List(source.NatureDataSource); + natures.Insert(0, comboAny); + CB_Nature.DataSource = natures; + + var abilities = new List(source.AbilityDataSource); + abilities.Insert(0, comboAny); + CB_Ability.DataSource = abilities; + + var versions = new List(source.VersionDataSource); + versions.Insert(0, comboAny); + versions.RemoveAt(versions.Count - 1); + CB_GameOrigin.DataSource = versions; + + var hptypes = source.Strings.HiddenPowerTypes; + var types = Util.GetCBList(hptypes); + types.Insert(0, comboAny); + CB_HPType.DataSource = types; + + var moves = new List(filtered.Moves); + moves.RemoveAt(0); + moves.Insert(0, comboAny); + foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }) + { + cb.InitializeBinding(); + cb.DataSource = new BindingSource(moves, string.Empty); + } + } + + /// + /// Sets the localized text for the format "Any" option. + /// + public void SetFormatAnyText(string text) + { + if (CB_Format.Items.Count > 0) + CB_Format.Items[0] = text; + } + + /// + /// Resets filters to their default state. + /// + public void ResetFilters() + { + CHK_Shiny.Checked = CHK_IsEgg.Checked = true; + CHK_Shiny.CheckState = CHK_IsEgg.CheckState = CheckState.Indeterminate; + MT_ESV.Text = string.Empty; + CB_HeldItem.SelectedIndex = 0; + CB_Species.SelectedIndex = 0; + CB_Ability.SelectedIndex = 0; + CB_Nature.SelectedIndex = 0; + CB_HPType.SelectedIndex = 0; + TB_Nickname.Text = string.Empty; + + CB_Level.SelectedIndex = 0; + TB_Level.Text = string.Empty; + CB_EVTrain.SelectedIndex = 0; + CB_IV.SelectedIndex = 0; + + CB_Move1.SelectedIndex = CB_Move2.SelectedIndex = CB_Move3.SelectedIndex = CB_Move4.SelectedIndex = 0; + + CB_GameOrigin.SelectedIndex = 0; + CB_Generation.SelectedIndex = 0; + + MT_ESV.Visible = L_ESV.Visible = false; + } + + /// + /// Resets combo box selections and text selection state. + /// + public void ResetComboBoxSelections() + { + foreach (var cb in TLP_Filters.Controls.OfType()) + cb.SelectedIndex = cb.SelectionLength = 0; + } + + /// + /// Creates search settings based on the current filter selection. + /// + public SearchSettings CreateSearchSettings(string batchInstructions) + { + var settings = new SearchSettings + { + Format = (byte)(MaxFormat - CB_Format.SelectedIndex + 1), + SearchFormat = (SearchComparison)CB_FormatComparator.SelectedIndex, + Generation = (byte)CB_Generation.SelectedIndex, + + Version = (GameVersion)WinFormsUtil.GetIndex(CB_GameOrigin), + HiddenPowerType = WinFormsUtil.GetIndex(CB_HPType), + + Species = GetU16(CB_Species), + Ability = WinFormsUtil.GetIndex(CB_Ability), + Nature = (Nature)WinFormsUtil.GetIndex(CB_Nature), + Item = WinFormsUtil.GetIndex(CB_HeldItem), + Nickname = TB_Nickname.Text.Trim(), + + BatchInstructions = batchInstructions, + + Level = byte.TryParse(TB_Level.Text, out var lvl) ? lvl : null, + SearchLevel = (SearchComparison)CB_Level.SelectedIndex, + EVType = CB_EVTrain.SelectedIndex, + IVType = CB_IV.SelectedIndex, + }; + + settings.AddMove(GetU16(CB_Move1)); + settings.AddMove(GetU16(CB_Move2)); + settings.AddMove(GetU16(CB_Move3)); + settings.AddMove(GetU16(CB_Move4)); + + if (CHK_Shiny.CheckState != CheckState.Indeterminate) + settings.SearchShiny = CHK_Shiny.CheckState == CheckState.Checked; + + if (CHK_IsEgg.CheckState != CheckState.Indeterminate) + { + settings.SearchEgg = CHK_IsEgg.CheckState == CheckState.Checked; + if (int.TryParse(MT_ESV.Text, out int esv)) + settings.ESV = esv; + } + + return settings; + + static ushort GetU16(ListControl cb) + { + var val = WinFormsUtil.GetIndex(cb); + if (val <= 0) + return 0; + return (ushort)val; + } + } + + private void ToggleESV(object? sender, EventArgs e) => L_ESV.Visible = MT_ESV.Visible = CHK_IsEgg.CheckState == CheckState.Checked; + + private void ChangeLevel(object? sender, EventArgs e) + { + if (CB_Level.SelectedIndex == 0) + TB_Level.Text = string.Empty; + } + + private void ChangeGame(object? sender, EventArgs e) + { + if (CB_GameOrigin.SelectedIndex != 0) + CB_Generation.SelectedIndex = 0; + } + + private void ChangeGeneration(object? sender, EventArgs e) + { + if (CB_Generation.SelectedIndex != 0) + CB_GameOrigin.SelectedIndex = 0; + } + + private void ChangeFormatFilter(object? sender, EventArgs e) + { + if (CB_FormatComparator.SelectedIndex == 0) + { + CB_Format.Visible = false; + CB_Format.SelectedIndex = 0; + } + else + { + CB_Format.Visible = true; + int index = MaxFormat - SaveGeneration + 1; + CB_Format.SelectedIndex = index < CB_Format.Items.Count ? index : 0; + } + } +} diff --git a/PKHeX.WinForms/Subforms/SAV_Database.Designer.cs b/PKHeX.WinForms/Subforms/SAV_Database.Designer.cs index 4aaa7cd33..dcdeda452 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.Designer.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.Designer.cs @@ -48,50 +48,11 @@ private void InitializeComponent() Menu_DeleteClones = new System.Windows.Forms.ToolStripMenuItem(); P_Results = new System.Windows.Forms.Panel(); DatabasePokeGrid = new Controls.PokeGrid(); - CB_Ability = new System.Windows.Forms.ComboBox(); - CB_HeldItem = new System.Windows.Forms.ComboBox(); - CB_Nature = new System.Windows.Forms.ComboBox(); - CB_Species = new System.Windows.Forms.ComboBox(); - CB_Move4 = new System.Windows.Forms.ComboBox(); - CB_Move3 = new System.Windows.Forms.ComboBox(); - CB_Move2 = new System.Windows.Forms.ComboBox(); - CB_Move1 = new System.Windows.Forms.ComboBox(); - TB_Level = new System.Windows.Forms.MaskedTextBox(); - Label_CurLevel = new System.Windows.Forms.Label(); - Label_HeldItem = new System.Windows.Forms.Label(); - Label_Ability = new System.Windows.Forms.Label(); - Label_Nature = new System.Windows.Forms.Label(); - Label_Species = new System.Windows.Forms.Label(); - CB_EVTrain = new System.Windows.Forms.ComboBox(); - CB_HPType = new System.Windows.Forms.ComboBox(); - Label_HiddenPowerPrefix = new System.Windows.Forms.Label(); - CB_GameOrigin = new System.Windows.Forms.ComboBox(); - CB_IV = new System.Windows.Forms.ComboBox(); + UC_EntitySearch = new Controls.EntitySearchControl(); B_Search = new System.Windows.Forms.Button(); - CB_Level = new System.Windows.Forms.ComboBox(); - L_Version = new System.Windows.Forms.Label(); - L_Move1 = new System.Windows.Forms.Label(); - L_Move2 = new System.Windows.Forms.Label(); - L_Move3 = new System.Windows.Forms.Label(); - L_Move4 = new System.Windows.Forms.Label(); - L_Potential = new System.Windows.Forms.Label(); - L_EVTraining = new System.Windows.Forms.Label(); B_Reset = new System.Windows.Forms.Button(); L_Count = new System.Windows.Forms.Label(); - L_Generation = new System.Windows.Forms.Label(); - CB_Generation = new System.Windows.Forms.ComboBox(); L_Viewed = new System.Windows.Forms.Label(); - FLP_Egg = new System.Windows.Forms.FlowLayoutPanel(); - CHK_IsEgg = new System.Windows.Forms.CheckBox(); - L_ESV = new System.Windows.Forms.Label(); - MT_ESV = new System.Windows.Forms.MaskedTextBox(); - CHK_Shiny = new System.Windows.Forms.CheckBox(); - TLP_Filters = new System.Windows.Forms.TableLayoutPanel(); - FLP_Format = new System.Windows.Forms.FlowLayoutPanel(); - CB_FormatComparator = new System.Windows.Forms.ComboBox(); - CB_Format = new System.Windows.Forms.ComboBox(); - L_Format = new System.Windows.Forms.Label(); - FLP_Level = new System.Windows.Forms.FlowLayoutPanel(); mnu = new System.Windows.Forms.ContextMenuStrip(components); mnuView = new System.Windows.Forms.ToolStripMenuItem(); mnuDelete = new System.Windows.Forms.ToolStripMenuItem(); @@ -103,10 +64,6 @@ private void InitializeComponent() RTB_Instructions = new System.Windows.Forms.RichTextBox(); menuStrip1.SuspendLayout(); P_Results.SuspendLayout(); - FLP_Egg.SuspendLayout(); - TLP_Filters.SuspendLayout(); - FLP_Format.SuspendLayout(); - FLP_Level.SuspendLayout(); mnu.SuspendLayout(); TC_SearchSettings.SuspendLayout(); Tab_General.SuspendLayout(); @@ -279,239 +236,6 @@ private void InitializeComponent() DatabasePokeGrid.Name = "DatabasePokeGrid"; DatabasePokeGrid.Size = new System.Drawing.Size(293, 399); DatabasePokeGrid.TabIndex = 2; - // - // CB_Ability - // - CB_Ability.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Ability.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Ability.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Ability.FormattingEnabled = true; - CB_Ability.Items.AddRange(new object[] { "Item" }); - CB_Ability.Location = new System.Drawing.Point(93, 92); - CB_Ability.Margin = new System.Windows.Forms.Padding(0); - CB_Ability.Name = "CB_Ability"; - CB_Ability.Size = new System.Drawing.Size(142, 23); - CB_Ability.TabIndex = 70; - // - // CB_HeldItem - // - CB_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_HeldItem.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_HeldItem.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_HeldItem.FormattingEnabled = true; - CB_HeldItem.Location = new System.Drawing.Point(93, 69); - CB_HeldItem.Margin = new System.Windows.Forms.Padding(0); - CB_HeldItem.Name = "CB_HeldItem"; - CB_HeldItem.Size = new System.Drawing.Size(142, 23); - CB_HeldItem.TabIndex = 69; - // - // CB_Nature - // - CB_Nature.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Nature.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Nature.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Nature.FormattingEnabled = true; - CB_Nature.Location = new System.Drawing.Point(93, 46); - CB_Nature.Margin = new System.Windows.Forms.Padding(0); - CB_Nature.Name = "CB_Nature"; - CB_Nature.Size = new System.Drawing.Size(142, 23); - CB_Nature.TabIndex = 68; - // - // CB_Species - // - CB_Species.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Species.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Species.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Species.FormattingEnabled = true; - CB_Species.Location = new System.Drawing.Point(93, 23); - CB_Species.Margin = new System.Windows.Forms.Padding(0); - CB_Species.Name = "CB_Species"; - CB_Species.Size = new System.Drawing.Size(142, 23); - CB_Species.TabIndex = 67; - // - // CB_Move4 - // - CB_Move4.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Move4.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Move4.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Move4.FormattingEnabled = true; - CB_Move4.Location = new System.Drawing.Point(93, 276); - CB_Move4.Margin = new System.Windows.Forms.Padding(0); - CB_Move4.Name = "CB_Move4"; - CB_Move4.Size = new System.Drawing.Size(142, 23); - CB_Move4.TabIndex = 74; - // - // CB_Move3 - // - CB_Move3.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Move3.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Move3.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Move3.FormattingEnabled = true; - CB_Move3.Location = new System.Drawing.Point(93, 253); - CB_Move3.Margin = new System.Windows.Forms.Padding(0); - CB_Move3.Name = "CB_Move3"; - CB_Move3.Size = new System.Drawing.Size(142, 23); - CB_Move3.TabIndex = 73; - // - // CB_Move2 - // - CB_Move2.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Move2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Move2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Move2.FormattingEnabled = true; - CB_Move2.Location = new System.Drawing.Point(93, 230); - CB_Move2.Margin = new System.Windows.Forms.Padding(0); - CB_Move2.Name = "CB_Move2"; - CB_Move2.Size = new System.Drawing.Size(142, 23); - CB_Move2.TabIndex = 72; - // - // CB_Move1 - // - CB_Move1.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Move1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_Move1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_Move1.FormattingEnabled = true; - CB_Move1.Location = new System.Drawing.Point(93, 207); - CB_Move1.Margin = new System.Windows.Forms.Padding(0); - CB_Move1.Name = "CB_Move1"; - CB_Move1.Size = new System.Drawing.Size(142, 23); - CB_Move1.TabIndex = 71; - // - // TB_Level - // - TB_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; - TB_Level.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - TB_Level.Location = new System.Drawing.Point(0, 0); - TB_Level.Margin = new System.Windows.Forms.Padding(0); - TB_Level.Mask = "000"; - TB_Level.Name = "TB_Level"; - TB_Level.Size = new System.Drawing.Size(25, 23); - TB_Level.TabIndex = 89; - TB_Level.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // - // Label_CurLevel - // - Label_CurLevel.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_CurLevel.AutoSize = true; - Label_CurLevel.Location = new System.Drawing.Point(52, 119); - Label_CurLevel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_CurLevel.Name = "Label_CurLevel"; - Label_CurLevel.Size = new System.Drawing.Size(37, 15); - Label_CurLevel.TabIndex = 88; - Label_CurLevel.Text = "Level:"; - Label_CurLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // Label_HeldItem - // - Label_HeldItem.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_HeldItem.AutoSize = true; - Label_HeldItem.Location = new System.Drawing.Point(27, 73); - Label_HeldItem.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_HeldItem.Name = "Label_HeldItem"; - Label_HeldItem.Size = new System.Drawing.Size(62, 15); - Label_HeldItem.TabIndex = 93; - Label_HeldItem.Text = "Held Item:"; - Label_HeldItem.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // Label_Ability - // - Label_Ability.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_Ability.AutoSize = true; - Label_Ability.Location = new System.Drawing.Point(45, 96); - Label_Ability.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_Ability.Name = "Label_Ability"; - Label_Ability.Size = new System.Drawing.Size(44, 15); - Label_Ability.TabIndex = 92; - Label_Ability.Text = "Ability:"; - Label_Ability.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // Label_Nature - // - Label_Nature.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_Nature.AutoSize = true; - Label_Nature.Location = new System.Drawing.Point(43, 50); - Label_Nature.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_Nature.Name = "Label_Nature"; - Label_Nature.Size = new System.Drawing.Size(46, 15); - Label_Nature.TabIndex = 91; - Label_Nature.Text = "Nature:"; - Label_Nature.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // Label_Species - // - Label_Species.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_Species.AutoSize = true; - Label_Species.Location = new System.Drawing.Point(40, 27); - Label_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_Species.Name = "Label_Species"; - Label_Species.Size = new System.Drawing.Size(49, 15); - Label_Species.TabIndex = 90; - Label_Species.Text = "Species:"; - Label_Species.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // CB_EVTrain - // - CB_EVTrain.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_EVTrain.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_EVTrain.DropDownWidth = 85; - CB_EVTrain.FormattingEnabled = true; - CB_EVTrain.Items.AddRange(new object[] { "Any", "None (0)", "Some (127-1)", "Half (128-507)", "Full (508+)" }); - CB_EVTrain.Location = new System.Drawing.Point(93, 161); - CB_EVTrain.Margin = new System.Windows.Forms.Padding(0); - CB_EVTrain.Name = "CB_EVTrain"; - CB_EVTrain.Size = new System.Drawing.Size(109, 23); - CB_EVTrain.TabIndex = 94; - // - // CB_HPType - // - CB_HPType.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_HPType.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; - CB_HPType.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems; - CB_HPType.DropDownWidth = 80; - CB_HPType.FormattingEnabled = true; - CB_HPType.Location = new System.Drawing.Point(93, 184); - CB_HPType.Margin = new System.Windows.Forms.Padding(0); - CB_HPType.Name = "CB_HPType"; - CB_HPType.Size = new System.Drawing.Size(142, 23); - CB_HPType.TabIndex = 96; - // - // Label_HiddenPowerPrefix - // - Label_HiddenPowerPrefix.Anchor = System.Windows.Forms.AnchorStyles.Right; - Label_HiddenPowerPrefix.AutoSize = true; - Label_HiddenPowerPrefix.Location = new System.Drawing.Point(4, 188); - Label_HiddenPowerPrefix.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - Label_HiddenPowerPrefix.Name = "Label_HiddenPowerPrefix"; - Label_HiddenPowerPrefix.Size = new System.Drawing.Size(85, 15); - Label_HiddenPowerPrefix.TabIndex = 95; - Label_HiddenPowerPrefix.Text = "Hidden Power:"; - Label_HiddenPowerPrefix.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // CB_GameOrigin - // - CB_GameOrigin.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_GameOrigin.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_GameOrigin.FormattingEnabled = true; - CB_GameOrigin.Location = new System.Drawing.Point(93, 299); - CB_GameOrigin.Margin = new System.Windows.Forms.Padding(0); - CB_GameOrigin.Name = "CB_GameOrigin"; - CB_GameOrigin.Size = new System.Drawing.Size(142, 23); - CB_GameOrigin.TabIndex = 97; - CB_GameOrigin.SelectedIndexChanged += ChangeGame; - // - // CB_IV - // - CB_IV.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_IV.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_IV.DropDownWidth = 85; - CB_IV.FormattingEnabled = true; - CB_IV.Items.AddRange(new object[] { "Any", "<= 90", "91-120", "121-150", "151-179", "180+", "== 186" }); - CB_IV.Location = new System.Drawing.Point(93, 138); - CB_IV.Margin = new System.Windows.Forms.Padding(0); - CB_IV.Name = "CB_IV"; - CB_IV.Size = new System.Drawing.Size(109, 23); - CB_IV.TabIndex = 100; - // // B_Search // B_Search.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; @@ -524,104 +248,6 @@ private void InitializeComponent() B_Search.UseVisualStyleBackColor = true; B_Search.Click += B_Search_Click; // - // CB_Level - // - CB_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Level.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_Level.DropDownWidth = 85; - CB_Level.FormattingEnabled = true; - CB_Level.Items.AddRange(new object[] { "Any", "==", ">=", "<=" }); - CB_Level.Location = new System.Drawing.Point(25, 0); - CB_Level.Margin = new System.Windows.Forms.Padding(0); - CB_Level.Name = "CB_Level"; - CB_Level.Size = new System.Drawing.Size(76, 23); - CB_Level.TabIndex = 103; - CB_Level.SelectedIndexChanged += ChangeLevel; - // - // L_Version - // - L_Version.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Version.AutoSize = true; - L_Version.Location = new System.Drawing.Point(24, 303); - L_Version.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Version.Name = "L_Version"; - L_Version.Size = new System.Drawing.Size(65, 15); - L_Version.TabIndex = 104; - L_Version.Text = "OT Version:"; - L_Version.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_Move1 - // - L_Move1.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Move1.AutoSize = true; - L_Move1.Location = new System.Drawing.Point(40, 211); - L_Move1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Move1.Name = "L_Move1"; - L_Move1.Size = new System.Drawing.Size(49, 15); - L_Move1.TabIndex = 105; - L_Move1.Text = "Move 1:"; - L_Move1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_Move2 - // - L_Move2.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Move2.AutoSize = true; - L_Move2.Location = new System.Drawing.Point(40, 234); - L_Move2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Move2.Name = "L_Move2"; - L_Move2.Size = new System.Drawing.Size(49, 15); - L_Move2.TabIndex = 106; - L_Move2.Text = "Move 2:"; - L_Move2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_Move3 - // - L_Move3.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Move3.AutoSize = true; - L_Move3.Location = new System.Drawing.Point(40, 257); - L_Move3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Move3.Name = "L_Move3"; - L_Move3.Size = new System.Drawing.Size(49, 15); - L_Move3.TabIndex = 107; - L_Move3.Text = "Move 3:"; - L_Move3.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_Move4 - // - L_Move4.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Move4.AutoSize = true; - L_Move4.Location = new System.Drawing.Point(40, 280); - L_Move4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Move4.Name = "L_Move4"; - L_Move4.Size = new System.Drawing.Size(49, 15); - L_Move4.TabIndex = 108; - L_Move4.Text = "Move 4:"; - L_Move4.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_Potential - // - L_Potential.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Potential.AutoSize = true; - L_Potential.Location = new System.Drawing.Point(19, 142); - L_Potential.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Potential.Name = "L_Potential"; - L_Potential.Size = new System.Drawing.Size(70, 15); - L_Potential.TabIndex = 109; - L_Potential.Text = "IV Potential:"; - L_Potential.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // L_EVTraining - // - L_EVTraining.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_EVTraining.AutoSize = true; - L_EVTraining.Location = new System.Drawing.Point(21, 165); - L_EVTraining.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_EVTraining.Name = "L_EVTraining"; - L_EVTraining.Size = new System.Drawing.Size(68, 15); - L_EVTraining.TabIndex = 110; - L_EVTraining.Text = "EV Training:"; - L_EVTraining.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // // B_Reset // B_Reset.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; @@ -644,31 +270,6 @@ private void InitializeComponent() L_Count.Text = "Count: {0}"; L_Count.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // L_Generation - // - L_Generation.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Generation.AutoSize = true; - L_Generation.Location = new System.Drawing.Point(21, 326); - L_Generation.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Generation.Name = "L_Generation"; - L_Generation.Size = new System.Drawing.Size(68, 15); - L_Generation.TabIndex = 116; - L_Generation.Text = "Generation:"; - L_Generation.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // CB_Generation - // - CB_Generation.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Generation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_Generation.FormattingEnabled = true; - CB_Generation.Items.AddRange(new object[] { "Any", "Gen 1 (RBY/GSC)", "Gen 2 (RBY/GSC)", "Gen 3 (RSE/FRLG/CXD)", "Gen 4 (DPPt/HGSS)", "Gen 5 (BW/B2W2)", "Gen 6 (XY/ORAS)", "Gen 7 (SM/USUM/LGPE)", "Gen 8 (SWSH/BDSP/LA)", "Gen 9 (SV)" }); - CB_Generation.Location = new System.Drawing.Point(93, 322); - CB_Generation.Margin = new System.Windows.Forms.Padding(0); - CB_Generation.Name = "CB_Generation"; - CB_Generation.Size = new System.Drawing.Size(142, 23); - CB_Generation.TabIndex = 115; - CB_Generation.SelectedIndexChanged += ChangeGeneration; - // // L_Viewed // L_Viewed.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left; @@ -682,202 +283,15 @@ private void InitializeComponent() L_Viewed.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; L_Viewed.MouseEnter += L_Viewed_MouseEnter; // - // FLP_Egg // - FLP_Egg.Anchor = System.Windows.Forms.AnchorStyles.Left; - FLP_Egg.AutoSize = true; - FLP_Egg.Controls.Add(CHK_IsEgg); - FLP_Egg.Controls.Add(L_ESV); - FLP_Egg.Controls.Add(MT_ESV); - FLP_Egg.Location = new System.Drawing.Point(93, 0); - FLP_Egg.Margin = new System.Windows.Forms.Padding(0); - FLP_Egg.Name = "FLP_Egg"; - FLP_Egg.Size = new System.Drawing.Size(132, 23); - FLP_Egg.TabIndex = 120; + // UC_EntitySearch // - // CHK_IsEgg - // - CHK_IsEgg.Anchor = System.Windows.Forms.AnchorStyles.Left; - CHK_IsEgg.AutoSize = true; - CHK_IsEgg.Checked = true; - CHK_IsEgg.CheckState = System.Windows.Forms.CheckState.Indeterminate; - CHK_IsEgg.Location = new System.Drawing.Point(0, 2); - CHK_IsEgg.Margin = new System.Windows.Forms.Padding(0); - CHK_IsEgg.Name = "CHK_IsEgg"; - CHK_IsEgg.Size = new System.Drawing.Size(46, 19); - CHK_IsEgg.TabIndex = 98; - CHK_IsEgg.Text = "Egg"; - CHK_IsEgg.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - CHK_IsEgg.ThreeState = true; - CHK_IsEgg.UseVisualStyleBackColor = true; - CHK_IsEgg.CheckStateChanged += ToggleESV; - // - // L_ESV - // - L_ESV.Anchor = System.Windows.Forms.AnchorStyles.Left; - L_ESV.Location = new System.Drawing.Point(46, 1); - L_ESV.Margin = new System.Windows.Forms.Padding(0); - L_ESV.Name = "L_ESV"; - L_ESV.Size = new System.Drawing.Size(50, 20); - L_ESV.TabIndex = 113; - L_ESV.Text = "ESV:"; - L_ESV.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - L_ESV.Visible = false; - // - // MT_ESV - // - MT_ESV.Anchor = System.Windows.Forms.AnchorStyles.Left; - MT_ESV.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - MT_ESV.Location = new System.Drawing.Point(96, 0); - MT_ESV.Margin = new System.Windows.Forms.Padding(0); - MT_ESV.Mask = "0000"; - MT_ESV.Name = "MT_ESV"; - MT_ESV.Size = new System.Drawing.Size(36, 23); - MT_ESV.TabIndex = 112; - MT_ESV.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - MT_ESV.Visible = false; - // - // CHK_Shiny - // - CHK_Shiny.Anchor = System.Windows.Forms.AnchorStyles.Right; - CHK_Shiny.AutoSize = true; - CHK_Shiny.Checked = true; - CHK_Shiny.CheckState = System.Windows.Forms.CheckState.Indeterminate; - CHK_Shiny.Location = new System.Drawing.Point(38, 2); - CHK_Shiny.Margin = new System.Windows.Forms.Padding(0); - CHK_Shiny.Name = "CHK_Shiny"; - CHK_Shiny.Size = new System.Drawing.Size(55, 19); - CHK_Shiny.TabIndex = 99; - CHK_Shiny.Text = "Shiny"; - CHK_Shiny.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - CHK_Shiny.ThreeState = true; - CHK_Shiny.UseVisualStyleBackColor = true; - // - // TLP_Filters - // - TLP_Filters.AutoScroll = true; - TLP_Filters.AutoScrollMargin = new System.Drawing.Size(3, 3); - TLP_Filters.AutoSize = true; - TLP_Filters.ColumnCount = 2; - TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - TLP_Filters.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - TLP_Filters.Controls.Add(FLP_Format, 1, 15); - TLP_Filters.Controls.Add(L_Format, 0, 15); - TLP_Filters.Controls.Add(FLP_Egg, 1, 0); - TLP_Filters.Controls.Add(CHK_Shiny, 0, 0); - TLP_Filters.Controls.Add(Label_Species, 0, 1); - TLP_Filters.Controls.Add(CB_Species, 1, 1); - TLP_Filters.Controls.Add(Label_Nature, 0, 2); - TLP_Filters.Controls.Add(CB_Nature, 1, 2); - TLP_Filters.Controls.Add(Label_HeldItem, 0, 3); - TLP_Filters.Controls.Add(CB_HeldItem, 1, 3); - TLP_Filters.Controls.Add(Label_Ability, 0, 4); - TLP_Filters.Controls.Add(CB_Ability, 1, 4); - TLP_Filters.Controls.Add(FLP_Level, 1, 5); - TLP_Filters.Controls.Add(Label_CurLevel, 0, 5); - TLP_Filters.Controls.Add(L_Potential, 0, 6); - TLP_Filters.Controls.Add(CB_IV, 1, 6); - TLP_Filters.Controls.Add(L_EVTraining, 0, 7); - TLP_Filters.Controls.Add(CB_EVTrain, 1, 7); - TLP_Filters.Controls.Add(Label_HiddenPowerPrefix, 0, 8); - TLP_Filters.Controls.Add(CB_HPType, 1, 8); - TLP_Filters.Controls.Add(L_Move1, 0, 9); - TLP_Filters.Controls.Add(CB_Move1, 1, 9); - TLP_Filters.Controls.Add(L_Move2, 0, 10); - TLP_Filters.Controls.Add(CB_Move2, 1, 10); - TLP_Filters.Controls.Add(L_Move3, 0, 11); - TLP_Filters.Controls.Add(CB_Move3, 1, 11); - TLP_Filters.Controls.Add(L_Move4, 0, 12); - TLP_Filters.Controls.Add(CB_Move4, 1, 12); - TLP_Filters.Controls.Add(L_Version, 0, 13); - TLP_Filters.Controls.Add(CB_GameOrigin, 1, 13); - TLP_Filters.Controls.Add(L_Generation, 0, 14); - TLP_Filters.Controls.Add(CB_Generation, 1, 14); - TLP_Filters.Dock = System.Windows.Forms.DockStyle.Fill; - TLP_Filters.Location = new System.Drawing.Point(4, 3); - TLP_Filters.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - TLP_Filters.Name = "TLP_Filters"; - TLP_Filters.RowCount = 17; - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.RowStyles.Add(new System.Windows.Forms.RowStyle()); - TLP_Filters.Size = new System.Drawing.Size(292, 369); - TLP_Filters.TabIndex = 118; - // - // FLP_Format - // - FLP_Format.AutoSize = true; - FLP_Format.Controls.Add(CB_FormatComparator); - FLP_Format.Controls.Add(CB_Format); - FLP_Format.Location = new System.Drawing.Point(93, 345); - FLP_Format.Margin = new System.Windows.Forms.Padding(0); - FLP_Format.Name = "FLP_Format"; - FLP_Format.Size = new System.Drawing.Size(141, 23); - FLP_Format.TabIndex = 124; - // - // CB_FormatComparator - // - CB_FormatComparator.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_FormatComparator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_FormatComparator.FormattingEnabled = true; - CB_FormatComparator.Items.AddRange(new object[] { "Any", "==", ">=", "<=" }); - CB_FormatComparator.Location = new System.Drawing.Point(0, 0); - CB_FormatComparator.Margin = new System.Windows.Forms.Padding(0); - CB_FormatComparator.Name = "CB_FormatComparator"; - CB_FormatComparator.Size = new System.Drawing.Size(62, 23); - CB_FormatComparator.TabIndex = 122; - CB_FormatComparator.SelectedIndexChanged += ChangeFormatFilter; - // - // CB_Format - // - CB_Format.Anchor = System.Windows.Forms.AnchorStyles.Left; - CB_Format.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - CB_Format.FormattingEnabled = true; - CB_Format.Items.AddRange(new object[] { "Any", ".pk9", ".pk8", ".pk7", ".pk6", ".pk5", ".pk4", ".pk3", ".pk2", ".pk1" }); - CB_Format.Location = new System.Drawing.Point(62, 0); - CB_Format.Margin = new System.Windows.Forms.Padding(0); - CB_Format.Name = "CB_Format"; - CB_Format.Size = new System.Drawing.Size(79, 23); - CB_Format.TabIndex = 121; - CB_Format.Visible = false; - // - // L_Format - // - L_Format.Anchor = System.Windows.Forms.AnchorStyles.Right; - L_Format.AutoSize = true; - L_Format.Location = new System.Drawing.Point(41, 349); - L_Format.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - L_Format.Name = "L_Format"; - L_Format.Size = new System.Drawing.Size(48, 15); - L_Format.TabIndex = 122; - L_Format.Text = "Format:"; - L_Format.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // FLP_Level - // - FLP_Level.Anchor = System.Windows.Forms.AnchorStyles.Left; - FLP_Level.AutoSize = true; - FLP_Level.Controls.Add(TB_Level); - FLP_Level.Controls.Add(CB_Level); - FLP_Level.Location = new System.Drawing.Point(93, 115); - FLP_Level.Margin = new System.Windows.Forms.Padding(0); - FLP_Level.Name = "FLP_Level"; - FLP_Level.Size = new System.Drawing.Size(101, 23); - FLP_Level.TabIndex = 119; + UC_EntitySearch.Dock = System.Windows.Forms.DockStyle.Fill; + UC_EntitySearch.Location = new System.Drawing.Point(4, 3); + UC_EntitySearch.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + UC_EntitySearch.Name = "UC_EntitySearch"; + UC_EntitySearch.Size = new System.Drawing.Size(292, 369); + UC_EntitySearch.TabIndex = 118; // // mnu // @@ -915,7 +329,7 @@ private void InitializeComponent() // // Tab_General // - Tab_General.Controls.Add(TLP_Filters); + Tab_General.Controls.Add(UC_EntitySearch); Tab_General.Location = new System.Drawing.Point(4, 24); Tab_General.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); Tab_General.Name = "Tab_General"; @@ -981,17 +395,9 @@ private void InitializeComponent() menuStrip1.ResumeLayout(false); menuStrip1.PerformLayout(); P_Results.ResumeLayout(false); - FLP_Egg.ResumeLayout(false); - FLP_Egg.PerformLayout(); - TLP_Filters.ResumeLayout(false); - TLP_Filters.PerformLayout(); - FLP_Format.ResumeLayout(false); - FLP_Level.ResumeLayout(false); - FLP_Level.PerformLayout(); mnu.ResumeLayout(false); TC_SearchSettings.ResumeLayout(false); Tab_General.ResumeLayout(false); - Tab_General.PerformLayout(); Tab_Advanced.ResumeLayout(false); ResumeLayout(false); PerformLayout(); @@ -1007,38 +413,9 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem Menu_OpenDB; private System.Windows.Forms.ToolStripMenuItem Menu_Report; private System.Windows.Forms.Panel P_Results; - private System.Windows.Forms.ComboBox CB_Ability; - private System.Windows.Forms.ComboBox CB_HeldItem; - private System.Windows.Forms.ComboBox CB_Nature; - public System.Windows.Forms.ComboBox CB_Species; - private System.Windows.Forms.ComboBox CB_Move4; - private System.Windows.Forms.ComboBox CB_Move3; - private System.Windows.Forms.ComboBox CB_Move2; - private System.Windows.Forms.ComboBox CB_Move1; - private System.Windows.Forms.MaskedTextBox TB_Level; - private System.Windows.Forms.Label Label_CurLevel; - private System.Windows.Forms.Label Label_HeldItem; - private System.Windows.Forms.Label Label_Ability; - private System.Windows.Forms.Label Label_Nature; - private System.Windows.Forms.Label Label_Species; - private System.Windows.Forms.ComboBox CB_EVTrain; - private System.Windows.Forms.ComboBox CB_HPType; - private System.Windows.Forms.Label Label_HiddenPowerPrefix; - private System.Windows.Forms.ComboBox CB_GameOrigin; - private System.Windows.Forms.ComboBox CB_IV; private System.Windows.Forms.Button B_Search; - private System.Windows.Forms.ComboBox CB_Level; - private System.Windows.Forms.Label L_Version; - private System.Windows.Forms.Label L_Move1; - private System.Windows.Forms.Label L_Move2; - private System.Windows.Forms.Label L_Move3; - private System.Windows.Forms.Label L_Move4; - private System.Windows.Forms.Label L_Potential; - private System.Windows.Forms.Label L_EVTraining; private System.Windows.Forms.Button B_Reset; private System.Windows.Forms.Label L_Count; - private System.Windows.Forms.Label L_Generation; - private System.Windows.Forms.ComboBox CB_Generation; private System.Windows.Forms.Label L_Viewed; private System.Windows.Forms.ToolStripMenuItem Menu_Export; private System.Windows.Forms.ToolStripMenuItem Menu_SearchSettings; @@ -1046,17 +423,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem Menu_SearchDatabase; private System.Windows.Forms.ToolStripMenuItem Menu_SearchLegal; private System.Windows.Forms.ToolStripMenuItem Menu_SearchIllegal; - private System.Windows.Forms.TableLayoutPanel TLP_Filters; - public System.Windows.Forms.CheckBox CHK_Shiny; - private System.Windows.Forms.MaskedTextBox MT_ESV; - private System.Windows.Forms.Label L_ESV; - public System.Windows.Forms.CheckBox CHK_IsEgg; - private System.Windows.Forms.FlowLayoutPanel FLP_Egg; - private System.Windows.Forms.FlowLayoutPanel FLP_Level; - private System.Windows.Forms.Label L_Format; - private System.Windows.Forms.FlowLayoutPanel FLP_Format; - private System.Windows.Forms.ComboBox CB_FormatComparator; - private System.Windows.Forms.ComboBox CB_Format; + private Controls.EntitySearchControl UC_EntitySearch; private System.Windows.Forms.ToolStripMenuItem Menu_SearchClones; private System.Windows.Forms.ToolStripMenuItem Menu_DeleteClones; private System.Windows.Forms.ToolStripMenuItem Menu_Import; diff --git a/PKHeX.WinForms/Subforms/SAV_Database.cs b/PKHeX.WinForms/Subforms/SAV_Database.cs index 70db4c0d9..ac13016e8 100644 --- a/PKHeX.WinForms/Subforms/SAV_Database.cs +++ b/PKHeX.WinForms/Subforms/SAV_Database.cs @@ -69,7 +69,9 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) PKME_Tabs = f1; // Preset Filters to only show PKM available for loaded save - CB_FormatComparator.SelectedIndex = 3; // <= + UC_EntitySearch.MaxFormat = MAXFORMAT; + UC_EntitySearch.SaveGeneration = SAV.Generation; + UC_EntitySearch.FormatComparatorSelectedIndex = 3; // <= var grid = DatabasePokeGrid; var smallWidth = grid.Width; @@ -128,7 +130,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) Counter = L_Count.Text; Viewed = L_Viewed.Text; L_Viewed.Text = string.Empty; // invisible for now - PopulateComboBoxes(); + UC_EntitySearch.PopulateComboBoxes(); // Load Data B_Search.Enabled = false; @@ -151,7 +153,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked) e.Cancel = true; }; - CB_Format.Items[0] = MsgAny; + UC_EntitySearch.SetFormatAnyText(MsgAny); CenterToParent(); FormClosing += (_, _) => ShowSet.Clear(); @@ -165,8 +167,7 @@ public SAV_Database(PKMEditor f1, SAVEditor saveditor) protected override void OnShown(EventArgs e) { base.OnShown(e); - foreach (var cb in TLP_Filters.Controls.OfType()) - cb.SelectedIndex = cb.SelectionLength = 0; + UC_EntitySearch.ResetComboBoxSelections(); } private void ClickView(object sender, EventArgs e) @@ -289,83 +290,9 @@ private bool GetShiftedIndex(ref int index) return index < Results.Count; } - private void PopulateComboBoxes() - { - // Set the Text - CB_HeldItem.InitializeBinding(); - CB_Species.InitializeBinding(); - CB_Ability.InitializeBinding(); - CB_Nature.InitializeBinding(); - CB_GameOrigin.InitializeBinding(); - CB_HPType.InitializeBinding(); - - var comboAny = new ComboItem(MsgAny, -1); - - var filtered = GameInfo.FilteredSources; - var source = filtered.Source; - var species = new List(source.SpeciesDataSource) - { - [0] = comboAny // Replace (None) with "Any" - }; - CB_Species.DataSource = species; - - var items = new List(filtered.Items); - items.Insert(0, comboAny); - CB_HeldItem.DataSource = items; - - var natures = new List(source.NatureDataSource); - natures.Insert(0, comboAny); - CB_Nature.DataSource = natures; - - var abilities = new List(source.AbilityDataSource); - abilities.Insert(0, comboAny); - CB_Ability.DataSource = abilities; - - var versions = new List(source.VersionDataSource); - versions.Insert(0, comboAny); - versions.RemoveAt(versions.Count - 1); // None - CB_GameOrigin.DataSource = versions; - - var hptypes = source.Strings.HiddenPowerTypes; - var types = Util.GetCBList(hptypes); - types.Insert(0, comboAny); - CB_HPType.DataSource = types; - - // Set the Move ComboBoxes too. - var moves = new List(filtered.Moves); - moves.RemoveAt(0); - moves.Insert(0, comboAny); - { - foreach (ComboBox cb in new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }) - { - cb.InitializeBinding(); - cb.DataSource = new BindingSource(moves, string.Empty); - } - } - } - private void ResetFilters(object sender, EventArgs e) { - CHK_Shiny.Checked = CHK_IsEgg.Checked = true; - CHK_Shiny.CheckState = CHK_IsEgg.CheckState = CheckState.Indeterminate; - MT_ESV.Text = string.Empty; - CB_HeldItem.SelectedIndex = 0; - CB_Species.SelectedIndex = 0; - CB_Ability.SelectedIndex = 0; - CB_Nature.SelectedIndex = 0; - CB_HPType.SelectedIndex = 0; - - CB_Level.SelectedIndex = 0; - TB_Level.Text = string.Empty; - CB_EVTrain.SelectedIndex = 0; - CB_IV.SelectedIndex = 0; - - CB_Move1.SelectedIndex = CB_Move2.SelectedIndex = CB_Move3.SelectedIndex = CB_Move4.SelectedIndex = 0; - - CB_GameOrigin.SelectedIndex = 0; - CB_Generation.SelectedIndex = 0; - - MT_ESV.Visible = L_ESV.Visible = false; + UC_EntitySearch.ResetFilters(); RTB_Instructions.Clear(); if (sender != this) @@ -561,50 +488,7 @@ private IEnumerable SearchDatabase() private SearchSettings GetSearchSettings() { - var settings = new SearchSettings - { - Format = (byte)(MAXFORMAT - CB_Format.SelectedIndex + 1), // 0->(n-1) => 1->n - SearchFormat = (SearchComparison)CB_FormatComparator.SelectedIndex, - Generation = (byte)CB_Generation.SelectedIndex, - - Version = (GameVersion)WinFormsUtil.GetIndex(CB_GameOrigin), - HiddenPowerType = WinFormsUtil.GetIndex(CB_HPType), - - Species = GetU16(CB_Species), - Ability = WinFormsUtil.GetIndex(CB_Ability), - Nature = (Nature)WinFormsUtil.GetIndex(CB_Nature), - Item = WinFormsUtil.GetIndex(CB_HeldItem), - - BatchInstructions = RTB_Instructions.Text, - - Level = byte.TryParse(TB_Level.Text, out var lvl) ? lvl : null, - SearchLevel = (SearchComparison)CB_Level.SelectedIndex, - EVType = CB_EVTrain.SelectedIndex, - IVType = CB_IV.SelectedIndex, - }; - - static ushort GetU16(ListControl cb) - { - var val = WinFormsUtil.GetIndex(cb); - if (val <= 0) - return 0; - return (ushort)val; - } - - settings.AddMove(GetU16(CB_Move1)); - settings.AddMove(GetU16(CB_Move2)); - settings.AddMove(GetU16(CB_Move3)); - settings.AddMove(GetU16(CB_Move4)); - - if (CHK_Shiny.CheckState != CheckState.Indeterminate) - settings.SearchShiny = CHK_Shiny.CheckState == CheckState.Checked; - - if (CHK_IsEgg.CheckState != CheckState.Indeterminate) - { - settings.SearchEgg = CHK_IsEgg.CheckState == CheckState.Checked; - if (int.TryParse(MT_ESV.Text, out int esv)) - settings.ESV = esv; - } + var settings = UC_EntitySearch.CreateSearchSettings(RTB_Instructions.Text); if (Menu_SearchLegal.Checked != Menu_SearchIllegal.Checked) settings.SearchLegal = Menu_SearchLegal.Checked; @@ -702,26 +586,6 @@ private void FillPKXBoxes(int start) } // Misc Update Methods - private void ToggleESV(object sender, EventArgs e) => L_ESV.Visible = MT_ESV.Visible = CHK_IsEgg.CheckState == CheckState.Checked; - - private void ChangeLevel(object sender, EventArgs e) - { - if (CB_Level.SelectedIndex == 0) - TB_Level.Text = string.Empty; - } - - private void ChangeGame(object sender, EventArgs e) - { - if (CB_GameOrigin.SelectedIndex != 0) - CB_Generation.SelectedIndex = 0; - } - - private void ChangeGeneration(object sender, EventArgs e) - { - if (CB_Generation.SelectedIndex != 0) - CB_GameOrigin.SelectedIndex = 0; - } - private void Menu_Exit_Click(object sender, EventArgs e) => Close(); protected override void OnMouseWheel(MouseEventArgs e) @@ -736,21 +600,6 @@ protected override void OnMouseWheel(MouseEventArgs e) ShowSet.Clear(); } - private void ChangeFormatFilter(object sender, EventArgs e) - { - if (CB_FormatComparator.SelectedIndex == 0) - { - CB_Format.Visible = false; // !any - CB_Format.SelectedIndex = 0; - } - else - { - CB_Format.Visible = true; - int index = MAXFORMAT - SAV.Generation + 1; - CB_Format.SelectedIndex = index < CB_Format.Items.Count ? index : 0; // SAV generation (offset by 1 for "Any") - } - } - private void Menu_DeleteClones_Click(object sender, EventArgs e) { var dr = WinFormsUtil.Prompt(MessageBoxButtons.YesNo,