diff --git a/PKHeX.WinForms/Subforms/Misc/PKMPreview.cs b/PKHeX.Core/Editing/PKM/PKMSummary.cs similarity index 87% rename from PKHeX.WinForms/Subforms/Misc/PKMPreview.cs rename to PKHeX.Core/Editing/PKM/PKMSummary.cs index 4b266e2d3..eeefe34ff 100644 --- a/PKHeX.WinForms/Subforms/Misc/PKMPreview.cs +++ b/PKHeX.Core/Editing/PKM/PKMSummary.cs @@ -1,19 +1,23 @@ using System.Collections.Generic; -using System.Drawing; -using PKHeX.Core; -namespace PKHeX.WinForms +namespace PKHeX.Core { - public class PKMPreview + /// + /// Bindable summary object that can fetch strings that summarize a . + /// + public class PKMSummary { - private readonly PKM pkm; + private static readonly IReadOnlyList GenderSymbols = GameInfo.GenderSymbolASCII; + + private readonly GameStrings Strings; private readonly ushort[] Stats; + protected readonly PKM pkm; // protected for children generating extra properties + public string Position => pkm.Identifier; - public Image Sprite => pkm.Sprite(); public string Nickname => pkm.Nickname; public string Species => Get(Strings.specieslist, pkm.Species); public string Nature => Get(Strings.natures, pkm.Nature); - public string Gender => Get(Main.GenderSymbols, pkm.Gender); + public string Gender => Get(GenderSymbols, pkm.Gender); public string ESV => pkm.PSV.ToString("0000"); public string HP_Type => Get(Strings.types, pkm.HPType + 1); public string Ability => Get(Strings.abilitylist, pkm.Ability); @@ -107,15 +111,19 @@ public class PKMPreview #endregion - private readonly GameStrings Strings; - - public PKMPreview(PKM p, GameStrings strings) + protected PKMSummary(PKM p, GameStrings strings) { pkm = p; Strings = strings; Stats = pkm.GetStats(pkm.PersonalInfo); } - private static string Get(IReadOnlyList arr, int val) => arr?.Count > val && val >= 0 ? arr[val] : null; + /// + /// Safely fetches the string from the array. + /// + /// Array of strings + /// Index to fetch + /// Null if array is null + private static string Get(IReadOnlyList arr, int val) => (uint)val < arr?.Count ? arr[val] : null; } } \ No newline at end of file diff --git a/PKHeX.WinForms/PKHeX.WinForms.csproj b/PKHeX.WinForms/PKHeX.WinForms.csproj index 992cb3f34..3c98bef11 100644 --- a/PKHeX.WinForms/PKHeX.WinForms.csproj +++ b/PKHeX.WinForms/PKHeX.WinForms.csproj @@ -308,7 +308,7 @@ True Resources.resx - + UserControl diff --git a/PKHeX.WinForms/Subforms/Misc/PKMSummaryImage.cs b/PKHeX.WinForms/Subforms/Misc/PKMSummaryImage.cs new file mode 100644 index 000000000..dd8cfb642 --- /dev/null +++ b/PKHeX.WinForms/Subforms/Misc/PKMSummaryImage.cs @@ -0,0 +1,17 @@ +using System.Drawing; +using PKHeX.Core; + +namespace PKHeX.WinForms +{ + /// + /// Bindable summary object that can fetch sprite and strings that summarize a . + /// + public class PKMSummaryImage : PKMSummary + { + public Image Sprite => pkm.Sprite(); + + public PKMSummaryImage(PKM p, GameStrings strings) : base(p, strings) + { + } + } +} \ No newline at end of file diff --git a/PKHeX.WinForms/Subforms/ReportGrid.cs b/PKHeX.WinForms/Subforms/ReportGrid.cs index 7964ecb2f..c16b3faac 100644 --- a/PKHeX.WinForms/Subforms/ReportGrid.cs +++ b/PKHeX.WinForms/Subforms/ReportGrid.cs @@ -54,12 +54,12 @@ public void PopulateData(IList Data) { SuspendLayout(); BoxBar.Step = 1; - var PL = new PokemonList(); + var PL = new PokemonList(); var strings = GameInfo.Strings; foreach (PKM pkm in Data.Where(pkm => pkm.ChecksumValid && pkm.Species != 0)) { pkm.Stat_Level = Experience.GetLevel(pkm.EXP, pkm.Species, pkm.AltForm); // recalc Level - PL.Add(new PKMPreview(pkm, strings)); + PL.Add(new PKMSummaryImage(pkm, strings)); BoxBar.PerformStep(); }