Use tuples and ComboItem, not anonymous class

Little more explicit
This commit is contained in:
Kurt 2022-05-06 15:43:51 -07:00
parent 9deafa851a
commit be9c947dd6
4 changed files with 19 additions and 10 deletions

View file

@ -45,7 +45,10 @@ namespace PKHeX.Core
this[i] = value[i];
}
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => GetAllEntities().Select((z, i) => new {Index = i, Entry = z}).Where(z => z.Entry.Species > 0).Select(z => z.Entry.Dump(speciesNames, z.Index));
public IEnumerable<string> DumpAll(IReadOnlyList<string> speciesNames) => GetAllEntities()
.Select((z, i) => (Entry: z, Index: i))
.Where(z => z.Entry.Species > 0)
.Select(z => z.Entry.Dump(speciesNames, z.Index));
public IEnumerator<GP1> GetEnumerator() => (IEnumerator<GP1>)GetAllEntities().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetAllEntities().GetEnumerator();

View file

@ -315,7 +315,7 @@ namespace PKHeX.WinForms
}
else
{
PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } };
PrevRegions[index].DataSource = new[] { new ComboItem("", 0) };
PrevRegions[index].Enabled = false;
PrevRegions[index].SelectedValue = 0;
}
@ -343,7 +343,7 @@ namespace PKHeX.WinForms
PrevCountries[index].SelectedValue = 0;
PrevRegions[index].InitializeBinding();
PrevRegions[index].DataSource = new[] { new { Text = "", Value = 0 } };
PrevRegions[index].DataSource = new[] { new ComboItem("", 0) };
PrevRegions[index].SelectedValue = 0;
}

View file

@ -1,5 +1,6 @@
#if DEBUG
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
@ -123,9 +124,15 @@ namespace PKHeX.WinForms
{
LocalizationUtil.SetLocalization(t, lang);
var entries = LocalizationUtil.GetLocalization(t);
var export = entries.Select(z => new {Variable = z.Split('=')[0], Line = z})
.OrderBy(z => z.Variable) // sort by length (V1 = 2, V100 = 4)
.Select(z => z.Line); // sorted lines
IEnumerable<string> export = entries.OrderBy(GetName); // sorted lines
static string GetName(string line)
{
var index = line.IndexOf('=');
if (index == -1)
return line;
return line[..index];
}
if (!sorted)
export = entries;

View file

@ -173,12 +173,11 @@ namespace PKHeX.WinForms
public static void DumpAll(params string[] banlist)
{
var results = Context.Select(z => new {Lang = z.Key, Lines = z.Value.Write()});
foreach (var c in results)
foreach (var c in Context)
{
var lang = c.Lang;
var lang = c.Key;
var fn = GetTranslationFileNameExternal(lang);
var lines = c.Lines;
var lines = c.Value.Write();
var result = lines.Where(z => !banlist.Any(z.Contains));
File.WriteAllLines(fn, result);
}