2019-03-18 21:34:21 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
2016-07-09 15:34:38 -07:00
|
|
|
|
{
|
2017-10-23 23:12:58 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Key Value pair for a displayed <see cref="string"/> and underlying <see cref="int"/> value.
|
|
|
|
|
/// </summary>
|
2017-06-17 18:37:19 -07:00
|
|
|
|
public struct ComboItem
|
2016-07-09 15:34:38 -07:00
|
|
|
|
{
|
|
|
|
|
public string Text { get; set; }
|
|
|
|
|
public int Value { get; set; }
|
|
|
|
|
}
|
2019-03-18 21:34:21 -07:00
|
|
|
|
|
|
|
|
|
public static class ComboItemExtensions
|
|
|
|
|
{
|
|
|
|
|
public static string[] GetArray(this IReadOnlyList<ComboItem> list)
|
|
|
|
|
{
|
|
|
|
|
var max = list[list.Count - 1].Value;
|
|
|
|
|
return GetArray(list, max);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string[] GetArray(this IEnumerable<ComboItem> list, int max)
|
|
|
|
|
{
|
|
|
|
|
var arr = new string[max + 1];
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
arr[item.Value] = item.Text;
|
|
|
|
|
return arr;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-07-09 15:34:38 -07:00
|
|
|
|
}
|