Windows.UI.Color considered harmful (#196)

_targets #192_

Adds our own struct to the API for passing colors around. This is lifted straight out of the Terminal, which had to deal with this quite a lot. 

Since this color is a struct (so that it trivially marshals across the ABI), it can't be _null_. So we also added `OptionalColor`, which is explicitly "Maybe a color, maybe not". We were bit enough times by trying to have a special secret `INVALID_COLOR` value that it ultimately made sense just to put another bool in there. 

While I'm touching the SDK and breaking everyone, I figured I'd also do the `s/Loading/IsLoading/g` thing now too. 

---------

Co-authored-by: Mike Griese <zadjii@gmail.com>
This commit is contained in:
Mike Griese
2024-12-09 15:05:58 -06:00
committed by GitHub
parent 8d8c8c6ab7
commit a3ea44977b
19 changed files with 564 additions and 515 deletions

View File

@@ -13,7 +13,6 @@ using HackerNewsExtension.Commands;
using HackerNewsExtension.Data;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Windows.UI;
namespace HackerNewsExtension;
@@ -23,8 +22,8 @@ internal sealed partial class HackerNewsPage : ListPage
{
Icon = new("https://news.ycombinator.com/favicon.ico");
Name = "Hacker News";
AccentColor = Color.FromArgb(255, 255, 102, 0);
Loading = true;
AccentColor = ColorHelpers.FromRgb(255, 102, 0);
IsLoading = true;
ShowDetails = true;
}
@@ -54,7 +53,7 @@ internal sealed partial class HackerNewsPage : ListPage
{
try
{
Loading = true;
IsLoading = true;
var t = DoGetItems();
t.ConfigureAwait(false);
return t.Result;
@@ -80,7 +79,7 @@ internal sealed partial class HackerNewsPage : ListPage
private async Task<IListItem[]> DoGetItems()
{
var items = await GetHackerNewsTopPosts();
this.Loading = false;
IsLoading = false;
var s = items.Select((post) => new ListItem(new LinkCommand(post))
{
Title = post.Title,

View File

@@ -14,7 +14,6 @@ using System.Threading.Tasks;
using HtmlAgilityPack;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Windows.UI;
namespace MastodonExtension;
@@ -31,11 +30,11 @@ internal sealed partial class MastodonExtensionPage : ListPage
Icon = new("https://mastodon.social/packs/media/icons/android-chrome-36x36-4c61fdb42936428af85afdbf8c6a45a8.png");
Name = "Mastodon";
ShowDetails = true;
HasMore = true;
Loading = true;
HasMoreItems = true;
IsLoading = true;
// #6364ff
AccentColor = Color.FromArgb(255, 99, 100, 255);
AccentColor = ColorHelpers.FromRgb(99, 100, 255);
}
private void AddPosts(List<MastodonStatus> posts)
@@ -91,7 +90,7 @@ internal sealed partial class MastodonExtensionPage : ListPage
public override void LoadMore()
{
this.Loading = true;
this.IsLoading = true;
ExtensionHost.LogMessage(new LogMessage() { Message = $"Loading 20 posts, starting with {_items.Count}..." });
var postsAsync = FetchExplorePage(20, this._items.Count);
postsAsync.ContinueWith((res) =>
@@ -100,7 +99,7 @@ internal sealed partial class MastodonExtensionPage : ListPage
this.AddPosts(posts);
ExtensionHost.LogMessage(new LogMessage() { Message = $"... got {posts.Count} new posts" });
this.Loading = false;
this.IsLoading = false;
this.RaiseItemsChanged(this._items.Count);
}).ConfigureAwait(false);
}
@@ -127,7 +126,7 @@ internal sealed partial class MastodonExtensionPage : ListPage
Console.WriteLine($"An error occurred: {e.Message}");
}
Loading = false;
IsLoading = false;
return statuses;
}

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Windows.UI;
namespace Microsoft.CmdPal.Ext.Apps.Programs;
@@ -20,9 +19,8 @@ public sealed partial class AllAppsPage : ListPage
this.Name = "All Apps";
this.Icon = new("\ue71d");
this.ShowDetails = true;
this.Loading = true;
this.IsLoading = true;
this.PlaceholderText = "Search installed apps...";
this.AccentColor = Color.FromArgb(255, 255, 102, 0);
}
public override IListItem[] GetItems()
@@ -30,7 +28,7 @@ public sealed partial class AllAppsPage : ListPage
if (this.allAppsSection == null || allAppsSection.Length == 0)
{
var apps = GetPrograms();
this.Loading = false;
this.IsLoading = false;
this.allAppsSection = apps
.Select((app) => new AppListItem(app))
.ToArray();

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Windows.UI;
namespace PokedexExtension;
@@ -43,403 +42,403 @@ internal sealed partial class PokemonPage : NoOpCommand
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")]
internal sealed partial class PokedexExtensionPage : ListPage
{
private readonly List<Pokemon> _kanto = new()
{
new Pokemon(1, "Bulbasaur", new List<string> { "Grass", "Poison" }),
new Pokemon(2, "Ivysaur", new List<string> { "Grass", "Poison" }),
new Pokemon(3, "Venusaur", new List<string> { "Grass", "Poison" }),
new Pokemon(4, "Charmander", new List<string> { "Fire" }),
new Pokemon(5, "Charmeleon", new List<string> { "Fire" }),
new Pokemon(6, "Charizard", new List<string> { "Fire", "Flying" }),
new Pokemon(7, "Squirtle", new List<string> { "Water" }),
new Pokemon(8, "Wartortle", new List<string> { "Water" }),
new Pokemon(9, "Blastoise", new List<string> { "Water" }),
new Pokemon(10, "Caterpie", new List<string> { "Bug" }),
new Pokemon(11, "Metapod", new List<string> { "Bug" }),
new Pokemon(12, "Butterfree", new List<string> { "Bug", "Flying" }),
new Pokemon(13, "Weedle", new List<string> { "Bug", "Poison" }),
new Pokemon(14, "Kakuna", new List<string> { "Bug", "Poison" }),
new Pokemon(15, "Beedrill", new List<string> { "Bug", "Poison" }),
new Pokemon(16, "Pidgey", new List<string> { "Normal", "Flying" }),
new Pokemon(17, "Pidgeotto", new List<string> { "Normal", "Flying" }),
new Pokemon(18, "Pidgeot", new List<string> { "Normal", "Flying" }),
new Pokemon(19, "Rattata", new List<string> { "Normal" }),
new Pokemon(20, "Raticate", new List<string> { "Normal" }),
new Pokemon(21, "Spearow", new List<string> { "Normal", "Flying" }),
new Pokemon(22, "Fearow", new List<string> { "Normal", "Flying" }),
new Pokemon(23, "Ekans", new List<string> { "Poison" }),
new Pokemon(24, "Arbok", new List<string> { "Poison" }),
new Pokemon(25, "Pikachu", new List<string> { "Electric" }),
new Pokemon(26, "Raichu", new List<string> { "Electric" }),
new Pokemon(27, "Sandshrew", new List<string> { "Ground" }),
new Pokemon(28, "Sandslash", new List<string> { "Ground" }),
new Pokemon(29, "Nidoran♀", new List<string> { "Poison" }),
new Pokemon(30, "Nidorina", new List<string> { "Poison" }),
new Pokemon(31, "Nidoqueen", new List<string> { "Poison", "Ground" }),
new Pokemon(32, "Nidoran♂", new List<string> { "Poison" }),
new Pokemon(33, "Nidorino", new List<string> { "Poison" }),
new Pokemon(34, "Nidoking", new List<string> { "Poison", "Ground" }),
new Pokemon(35, "Clefairy", new List<string> { "Fairy" }),
new Pokemon(36, "Clefable", new List<string> { "Fairy" }),
new Pokemon(37, "Vulpix", new List<string> { "Fire" }),
new Pokemon(38, "Ninetales", new List<string> { "Fire" }),
new Pokemon(39, "Jigglypuff", new List<string> { "Normal", "Fairy" }),
new Pokemon(40, "Wigglytuff", new List<string> { "Normal", "Fairy" }),
new Pokemon(41, "Zubat", new List<string> { "Poison", "Flying" }),
new Pokemon(42, "Golbat", new List<string> { "Poison", "Flying" }),
new Pokemon(43, "Oddish", new List<string> { "Grass", "Poison" }),
new Pokemon(44, "Gloom", new List<string> { "Grass", "Poison" }),
new Pokemon(45, "Vileplume", new List<string> { "Grass", "Poison" }),
new Pokemon(46, "Paras", new List<string> { "Bug", "Grass" }),
new Pokemon(47, "Parasect", new List<string> { "Bug", "Grass" }),
new Pokemon(48, "Venonat", new List<string> { "Bug", "Poison" }),
new Pokemon(49, "Venomoth", new List<string> { "Bug", "Poison" }),
new Pokemon(50, "Diglett", new List<string> { "Ground" }),
new Pokemon(51, "Dugtrio", new List<string> { "Ground" }),
new Pokemon(52, "Meowth", new List<string> { "Normal" }),
new Pokemon(53, "Persian", new List<string> { "Normal" }),
new Pokemon(54, "Psyduck", new List<string> { "Water" }),
new Pokemon(55, "Golduck", new List<string> { "Water" }),
new Pokemon(56, "Mankey", new List<string> { "Fighting" }),
new Pokemon(57, "Primeape", new List<string> { "Fighting" }),
new Pokemon(58, "Growlithe", new List<string> { "Fire" }),
new Pokemon(59, "Arcanine", new List<string> { "Fire" }),
new Pokemon(60, "Poliwag", new List<string> { "Water" }),
new Pokemon(61, "Poliwhirl", new List<string> { "Water" }),
new Pokemon(62, "Poliwrath", new List<string> { "Water", "Fighting" }),
new Pokemon(63, "Abra", new List<string> { "Psychic" }),
new Pokemon(64, "Kadabra", new List<string> { "Psychic" }),
new Pokemon(65, "Alakazam", new List<string> { "Psychic" }),
new Pokemon(66, "Machop", new List<string> { "Fighting" }),
new Pokemon(67, "Machoke", new List<string> { "Fighting" }),
new Pokemon(68, "Machamp", new List<string> { "Fighting" }),
new Pokemon(69, "Bellsprout", new List<string> { "Grass", "Poison" }),
new Pokemon(70, "Weepinbell", new List<string> { "Grass", "Poison" }),
new Pokemon(71, "Victreebel", new List<string> { "Grass", "Poison" }),
new Pokemon(72, "Tentacool", new List<string> { "Water", "Poison" }),
new Pokemon(73, "Tentacruel", new List<string> { "Water", "Poison" }),
new Pokemon(74, "Geodude", new List<string> { "Rock", "Ground" }),
new Pokemon(75, "Graveler", new List<string> { "Rock", "Ground" }),
new Pokemon(76, "Golem", new List<string> { "Rock", "Ground" }),
new Pokemon(77, "Ponyta", new List<string> { "Fire" }),
new Pokemon(78, "Rapidash", new List<string> { "Fire" }),
new Pokemon(79, "Slowpoke", new List<string> { "Water", "Psychic" }),
new Pokemon(80, "Slowbro", new List<string> { "Water", "Psychic" }),
new Pokemon(81, "Magnemite", new List<string> { "Electric", "Steel" }),
new Pokemon(82, "Magneton", new List<string> { "Electric", "Steel" }),
new Pokemon(83, "Farfetch'd", new List<string> { "Normal", "Flying" }),
new Pokemon(84, "Doduo", new List<string> { "Normal", "Flying" }),
new Pokemon(85, "Dodrio", new List<string> { "Normal", "Flying" }),
new Pokemon(86, "Seel", new List<string> { "Water" }),
new Pokemon(87, "Dewgong", new List<string> { "Water", "Ice" }),
new Pokemon(88, "Grimer", new List<string> { "Poison" }),
new Pokemon(89, "Muk", new List<string> { "Poison" }),
new Pokemon(90, "Shellder", new List<string> { "Water" }),
new Pokemon(91, "Cloyster", new List<string> { "Water", "Ice" }),
new Pokemon(92, "Gastly", new List<string> { "Ghost", "Poison" }),
new Pokemon(93, "Haunter", new List<string> { "Ghost", "Poison" }),
new Pokemon(94, "Gengar", new List<string> { "Ghost", "Poison" }),
new Pokemon(95, "Onix", new List<string> { "Rock", "Ground" }),
new Pokemon(96, "Drowzee", new List<string> { "Psychic" }),
new Pokemon(97, "Hypno", new List<string> { "Psychic" }),
new Pokemon(98, "Krabby", new List<string> { "Water" }),
new Pokemon(99, "Kingler", new List<string> { "Water" }),
new Pokemon(100, "Voltorb", new List<string> { "Electric" }),
new Pokemon(101, "Electrode", new List<string> { "Electric" }),
new Pokemon(102, "Exeggcute", new List<string> { "Grass", "Psychic" }),
new Pokemon(103, "Exeggutor", new List<string> { "Grass", "Psychic" }),
new Pokemon(104, "Cubone", new List<string> { "Ground" }),
new Pokemon(105, "Marowak", new List<string> { "Ground" }),
new Pokemon(106, "Hitmonlee", new List<string> { "Fighting" }),
new Pokemon(107, "Hitmonchan", new List<string> { "Fighting" }),
new Pokemon(108, "Lickitung", new List<string> { "Normal" }),
new Pokemon(109, "Koffing", new List<string> { "Poison" }),
new Pokemon(110, "Weezing", new List<string> { "Poison" }),
new Pokemon(111, "Rhyhorn", new List<string> { "Ground", "Rock" }),
new Pokemon(112, "Rhydon", new List<string> { "Ground", "Rock" }),
new Pokemon(113, "Chansey", new List<string> { "Normal" }),
new Pokemon(114, "Tangela", new List<string> { "Grass" }),
new Pokemon(115, "Kangaskhan", new List<string> { "Normal" }),
new Pokemon(116, "Horsea", new List<string> { "Water" }),
new Pokemon(117, "Seadra", new List<string> { "Water" }),
new Pokemon(118, "Goldeen", new List<string> { "Water" }),
new Pokemon(119, "Seaking", new List<string> { "Water" }),
new Pokemon(120, "Staryu", new List<string> { "Water" }),
new Pokemon(121, "Starmie", new List<string> { "Water", "Psychic" }),
new Pokemon(122, "Mr. Mime", new List<string> { "Psychic", "Fairy" }),
new Pokemon(123, "Scyther", new List<string> { "Bug", "Flying" }),
new Pokemon(124, "Jynx", new List<string> { "Ice", "Psychic" }),
new Pokemon(125, "Electabuzz", new List<string> { "Electric" }),
new Pokemon(126, "Magmar", new List<string> { "Fire" }),
new Pokemon(127, "Pinsir", new List<string> { "Bug" }),
new Pokemon(128, "Tauros", new List<string> { "Normal" }),
new Pokemon(129, "Magikarp", new List<string> { "Water" }),
new Pokemon(130, "Gyarados", new List<string> { "Water", "Flying" }),
new Pokemon(131, "Lapras", new List<string> { "Water", "Ice" }),
new Pokemon(132, "Ditto", new List<string> { "Normal" }),
new Pokemon(133, "Eevee", new List<string> { "Normal" }),
new Pokemon(134, "Vaporeon", new List<string> { "Water" }),
new Pokemon(135, "Jolteon", new List<string> { "Electric" }),
new Pokemon(136, "Flareon", new List<string> { "Fire" }),
new Pokemon(137, "Porygon", new List<string> { "Normal" }),
new Pokemon(138, "Omanyte", new List<string> { "Rock", "Water" }),
new Pokemon(139, "Omastar", new List<string> { "Rock", "Water" }),
new Pokemon(140, "Kabuto", new List<string> { "Rock", "Water" }),
new Pokemon(141, "Kabutops", new List<string> { "Rock", "Water" }),
new Pokemon(142, "Aerodactyl", new List<string> { "Rock", "Flying" }),
new Pokemon(143, "Snorlax", new List<string> { "Normal" }),
new Pokemon(144, "Articuno", new List<string> { "Ice", "Flying" }),
new Pokemon(145, "Zapdos", new List<string> { "Electric", "Flying" }),
new Pokemon(146, "Moltres", new List<string> { "Fire", "Flying" }),
new Pokemon(147, "Dratini", new List<string> { "Dragon" }),
new Pokemon(148, "Dragonair", new List<string> { "Dragon" }),
new Pokemon(149, "Dragonite", new List<string> { "Dragon", "Flying" }),
new Pokemon(150, "Mewtwo", new List<string> { "Psychic" }),
new Pokemon(151, "Mew", new List<string> { "Psychic" }),
};
private readonly List<Pokemon> _kanto =
[
new Pokemon(1, "Bulbasaur", ["Grass", "Poison"]),
new Pokemon(2, "Ivysaur", ["Grass", "Poison"]),
new Pokemon(3, "Venusaur", ["Grass", "Poison"]),
new Pokemon(4, "Charmander", ["Fire"]),
new Pokemon(5, "Charmeleon", ["Fire"]),
new Pokemon(6, "Charizard", ["Fire", "Flying"]),
new Pokemon(7, "Squirtle", ["Water"]),
new Pokemon(8, "Wartortle", ["Water"]),
new Pokemon(9, "Blastoise", ["Water"]),
new Pokemon(10, "Caterpie", ["Bug"]),
new Pokemon(11, "Metapod", ["Bug"]),
new Pokemon(12, "Butterfree", ["Bug", "Flying"]),
new Pokemon(13, "Weedle", ["Bug", "Poison"]),
new Pokemon(14, "Kakuna", ["Bug", "Poison"]),
new Pokemon(15, "Beedrill", ["Bug", "Poison"]),
new Pokemon(16, "Pidgey", ["Normal", "Flying"]),
new Pokemon(17, "Pidgeotto", ["Normal", "Flying"]),
new Pokemon(18, "Pidgeot", ["Normal", "Flying"]),
new Pokemon(19, "Rattata", ["Normal"]),
new Pokemon(20, "Raticate", ["Normal"]),
new Pokemon(21, "Spearow", ["Normal", "Flying"]),
new Pokemon(22, "Fearow", ["Normal", "Flying"]),
new Pokemon(23, "Ekans", ["Poison"]),
new Pokemon(24, "Arbok", ["Poison"]),
new Pokemon(25, "Pikachu", ["Electric"]),
new Pokemon(26, "Raichu", ["Electric"]),
new Pokemon(27, "Sandshrew", ["Ground"]),
new Pokemon(28, "Sandslash", ["Ground"]),
new Pokemon(29, "Nidoran♀", ["Poison"]),
new Pokemon(30, "Nidorina", ["Poison"]),
new Pokemon(31, "Nidoqueen", ["Poison", "Ground"]),
new Pokemon(32, "Nidoran♂", ["Poison"]),
new Pokemon(33, "Nidorino", ["Poison"]),
new Pokemon(34, "Nidoking", ["Poison", "Ground"]),
new Pokemon(35, "Clefairy", ["Fairy"]),
new Pokemon(36, "Clefable", ["Fairy"]),
new Pokemon(37, "Vulpix", ["Fire"]),
new Pokemon(38, "Ninetales", ["Fire"]),
new Pokemon(39, "Jigglypuff", ["Normal", "Fairy"]),
new Pokemon(40, "Wigglytuff", ["Normal", "Fairy"]),
new Pokemon(41, "Zubat", ["Poison", "Flying"]),
new Pokemon(42, "Golbat", ["Poison", "Flying"]),
new Pokemon(43, "Oddish", ["Grass", "Poison"]),
new Pokemon(44, "Gloom", ["Grass", "Poison"]),
new Pokemon(45, "Vileplume", ["Grass", "Poison"]),
new Pokemon(46, "Paras", ["Bug", "Grass"]),
new Pokemon(47, "Parasect", ["Bug", "Grass"]),
new Pokemon(48, "Venonat", ["Bug", "Poison"]),
new Pokemon(49, "Venomoth", ["Bug", "Poison"]),
new Pokemon(50, "Diglett", ["Ground"]),
new Pokemon(51, "Dugtrio", ["Ground"]),
new Pokemon(52, "Meowth", ["Normal"]),
new Pokemon(53, "Persian", ["Normal"]),
new Pokemon(54, "Psyduck", ["Water"]),
new Pokemon(55, "Golduck", ["Water"]),
new Pokemon(56, "Mankey", ["Fighting"]),
new Pokemon(57, "Primeape", ["Fighting"]),
new Pokemon(58, "Growlithe", ["Fire"]),
new Pokemon(59, "Arcanine", ["Fire"]),
new Pokemon(60, "Poliwag", ["Water"]),
new Pokemon(61, "Poliwhirl", ["Water"]),
new Pokemon(62, "Poliwrath", ["Water", "Fighting"]),
new Pokemon(63, "Abra", ["Psychic"]),
new Pokemon(64, "Kadabra", ["Psychic"]),
new Pokemon(65, "Alakazam", ["Psychic"]),
new Pokemon(66, "Machop", ["Fighting"]),
new Pokemon(67, "Machoke", ["Fighting"]),
new Pokemon(68, "Machamp", ["Fighting"]),
new Pokemon(69, "Bellsprout", ["Grass", "Poison"]),
new Pokemon(70, "Weepinbell", ["Grass", "Poison"]),
new Pokemon(71, "Victreebel", ["Grass", "Poison"]),
new Pokemon(72, "Tentacool", ["Water", "Poison"]),
new Pokemon(73, "Tentacruel", ["Water", "Poison"]),
new Pokemon(74, "Geodude", ["Rock", "Ground"]),
new Pokemon(75, "Graveler", ["Rock", "Ground"]),
new Pokemon(76, "Golem", ["Rock", "Ground"]),
new Pokemon(77, "Ponyta", ["Fire"]),
new Pokemon(78, "Rapidash", ["Fire"]),
new Pokemon(79, "Slowpoke", ["Water", "Psychic"]),
new Pokemon(80, "Slowbro", ["Water", "Psychic"]),
new Pokemon(81, "Magnemite", ["Electric", "Steel"]),
new Pokemon(82, "Magneton", ["Electric", "Steel"]),
new Pokemon(83, "Farfetch'd", ["Normal", "Flying"]),
new Pokemon(84, "Doduo", ["Normal", "Flying"]),
new Pokemon(85, "Dodrio", ["Normal", "Flying"]),
new Pokemon(86, "Seel", ["Water"]),
new Pokemon(87, "Dewgong", ["Water", "Ice"]),
new Pokemon(88, "Grimer", ["Poison"]),
new Pokemon(89, "Muk", ["Poison"]),
new Pokemon(90, "Shellder", ["Water"]),
new Pokemon(91, "Cloyster", ["Water", "Ice"]),
new Pokemon(92, "Gastly", ["Ghost", "Poison"]),
new Pokemon(93, "Haunter", ["Ghost", "Poison"]),
new Pokemon(94, "Gengar", ["Ghost", "Poison"]),
new Pokemon(95, "Onix", ["Rock", "Ground"]),
new Pokemon(96, "Drowzee", ["Psychic"]),
new Pokemon(97, "Hypno", ["Psychic"]),
new Pokemon(98, "Krabby", ["Water"]),
new Pokemon(99, "Kingler", ["Water"]),
new Pokemon(100, "Voltorb", ["Electric"]),
new Pokemon(101, "Electrode", ["Electric"]),
new Pokemon(102, "Exeggcute", ["Grass", "Psychic"]),
new Pokemon(103, "Exeggutor", ["Grass", "Psychic"]),
new Pokemon(104, "Cubone", ["Ground"]),
new Pokemon(105, "Marowak", ["Ground"]),
new Pokemon(106, "Hitmonlee", ["Fighting"]),
new Pokemon(107, "Hitmonchan", ["Fighting"]),
new Pokemon(108, "Lickitung", ["Normal"]),
new Pokemon(109, "Koffing", ["Poison"]),
new Pokemon(110, "Weezing", ["Poison"]),
new Pokemon(111, "Rhyhorn", ["Ground", "Rock"]),
new Pokemon(112, "Rhydon", ["Ground", "Rock"]),
new Pokemon(113, "Chansey", ["Normal"]),
new Pokemon(114, "Tangela", ["Grass"]),
new Pokemon(115, "Kangaskhan", ["Normal"]),
new Pokemon(116, "Horsea", ["Water"]),
new Pokemon(117, "Seadra", ["Water"]),
new Pokemon(118, "Goldeen", ["Water"]),
new Pokemon(119, "Seaking", ["Water"]),
new Pokemon(120, "Staryu", ["Water"]),
new Pokemon(121, "Starmie", ["Water", "Psychic"]),
new Pokemon(122, "Mr. Mime", ["Psychic", "Fairy"]),
new Pokemon(123, "Scyther", ["Bug", "Flying"]),
new Pokemon(124, "Jynx", ["Ice", "Psychic"]),
new Pokemon(125, "Electabuzz", ["Electric"]),
new Pokemon(126, "Magmar", ["Fire"]),
new Pokemon(127, "Pinsir", ["Bug"]),
new Pokemon(128, "Tauros", ["Normal"]),
new Pokemon(129, "Magikarp", ["Water"]),
new Pokemon(130, "Gyarados", ["Water", "Flying"]),
new Pokemon(131, "Lapras", ["Water", "Ice"]),
new Pokemon(132, "Ditto", ["Normal"]),
new Pokemon(133, "Eevee", ["Normal"]),
new Pokemon(134, "Vaporeon", ["Water"]),
new Pokemon(135, "Jolteon", ["Electric"]),
new Pokemon(136, "Flareon", ["Fire"]),
new Pokemon(137, "Porygon", ["Normal"]),
new Pokemon(138, "Omanyte", ["Rock", "Water"]),
new Pokemon(139, "Omastar", ["Rock", "Water"]),
new Pokemon(140, "Kabuto", ["Rock", "Water"]),
new Pokemon(141, "Kabutops", ["Rock", "Water"]),
new Pokemon(142, "Aerodactyl", ["Rock", "Flying"]),
new Pokemon(143, "Snorlax", ["Normal"]),
new Pokemon(144, "Articuno", ["Ice", "Flying"]),
new Pokemon(145, "Zapdos", ["Electric", "Flying"]),
new Pokemon(146, "Moltres", ["Fire", "Flying"]),
new Pokemon(147, "Dratini", ["Dragon"]),
new Pokemon(148, "Dragonair", ["Dragon"]),
new Pokemon(149, "Dragonite", ["Dragon", "Flying"]),
new Pokemon(150, "Mewtwo", ["Psychic"]),
new Pokemon(151, "Mew", ["Psychic"]),
];
private readonly List<Pokemon> _johto = new()
{
new Pokemon(152, "Chikorita", new List<string> { "Grass" }),
new Pokemon(153, "Bayleef", new List<string> { "Grass" }),
new Pokemon(154, "Meganium", new List<string> { "Grass" }),
new Pokemon(155, "Cyndaquil", new List<string> { "Fire" }),
new Pokemon(156, "Quilava", new List<string> { "Fire" }),
new Pokemon(157, "Typhlosion", new List<string> { "Fire" }),
new Pokemon(158, "Totodile", new List<string> { "Water" }),
new Pokemon(159, "Croconaw", new List<string> { "Water" }),
new Pokemon(160, "Feraligatr", new List<string> { "Water" }),
new Pokemon(161, "Sentret", new List<string> { "Normal" }),
new Pokemon(162, "Furret", new List<string> { "Normal" }),
new Pokemon(163, "Hoothoot", new List<string> { "Normal", "Flying" }),
new Pokemon(164, "Noctowl", new List<string> { "Normal", "Flying" }),
new Pokemon(165, "Ledyba", new List<string> { "Bug", "Flying" }),
new Pokemon(166, "Ledian", new List<string> { "Bug", "Flying" }),
new Pokemon(167, "Spinarak", new List<string> { "Bug", "Poison" }),
new Pokemon(168, "Ariados", new List<string> { "Bug", "Poison" }),
new Pokemon(169, "Crobat", new List<string> { "Poison", "Flying" }),
new Pokemon(170, "Chinchou", new List<string> { "Water", "Electric" }),
new Pokemon(171, "Lanturn", new List<string> { "Water", "Electric" }),
new Pokemon(172, "Pichu", new List<string> { "Electric" }),
new Pokemon(173, "Cleffa", new List<string> { "Fairy" }),
new Pokemon(174, "Igglybuff", new List<string> { "Normal", "Fairy" }),
new Pokemon(175, "Togepi", new List<string> { "Fairy" }),
new Pokemon(176, "Togetic", new List<string> { "Fairy", "Flying" }),
new Pokemon(177, "Natu", new List<string> { "Psychic", "Flying" }),
new Pokemon(178, "Xatu", new List<string> { "Psychic", "Flying" }),
new Pokemon(179, "Mareep", new List<string> { "Electric" }),
new Pokemon(180, "Flaaffy", new List<string> { "Electric" }),
new Pokemon(181, "Ampharos", new List<string> { "Electric" }),
new Pokemon(182, "Bellossom", new List<string> { "Grass" }),
new Pokemon(183, "Marill", new List<string> { "Water", "Fairy" }),
new Pokemon(184, "Azumarill", new List<string> { "Water", "Fairy" }),
new Pokemon(185, "Sudowoodo", new List<string> { "Rock" }),
new Pokemon(186, "Politoed", new List<string> { "Water" }),
new Pokemon(187, "Hoppip", new List<string> { "Grass", "Flying" }),
new Pokemon(188, "Skiploom", new List<string> { "Grass", "Flying" }),
new Pokemon(189, "Jumpluff", new List<string> { "Grass", "Flying" }),
new Pokemon(190, "Aipom", new List<string> { "Normal" }),
new Pokemon(191, "Sunkern", new List<string> { "Grass" }),
new Pokemon(192, "Sunflora", new List<string> { "Grass" }),
new Pokemon(193, "Yanma", new List<string> { "Bug", "Flying" }),
new Pokemon(194, "Wooper", new List<string> { "Water", "Ground" }),
new Pokemon(195, "Quagsire", new List<string> { "Water", "Ground" }),
new Pokemon(196, "Espeon", new List<string> { "Psychic" }),
new Pokemon(197, "Umbreon", new List<string> { "Dark" }),
new Pokemon(198, "Murkrow", new List<string> { "Dark", "Flying" }),
new Pokemon(199, "Slowking", new List<string> { "Water", "Psychic" }),
new Pokemon(200, "Misdreavus", new List<string> { "Ghost" }),
new Pokemon(201, "Unown", new List<string> { "Psychic" }),
new Pokemon(202, "Wobbuffet", new List<string> { "Psychic" }),
new Pokemon(203, "Girafarig", new List<string> { "Normal", "Psychic" }),
new Pokemon(204, "Pineco", new List<string> { "Bug" }),
new Pokemon(205, "Forretress", new List<string> { "Bug", "Steel" }),
new Pokemon(206, "Dunsparce", new List<string> { "Normal" }),
new Pokemon(207, "Gligar", new List<string> { "Ground", "Flying" }),
new Pokemon(208, "Steelix", new List<string> { "Steel", "Ground" }),
new Pokemon(209, "Snubbull", new List<string> { "Fairy" }),
new Pokemon(210, "Granbull", new List<string> { "Fairy" }),
new Pokemon(211, "Qwilfish", new List<string> { "Water", "Poison" }),
new Pokemon(212, "Scizor", new List<string> { "Bug", "Steel" }),
new Pokemon(213, "Shuckle", new List<string> { "Bug", "Rock" }),
new Pokemon(214, "Heracross", new List<string> { "Bug", "Fighting" }),
new Pokemon(215, "Sneasel", new List<string> { "Dark", "Ice" }),
new Pokemon(216, "Teddiursa", new List<string> { "Normal" }),
new Pokemon(217, "Ursaring", new List<string> { "Normal" }),
new Pokemon(218, "Slugma", new List<string> { "Fire" }),
new Pokemon(219, "Magcargo", new List<string> { "Fire", "Rock" }),
new Pokemon(220, "Swinub", new List<string> { "Ice", "Ground" }),
new Pokemon(221, "Piloswine", new List<string> { "Ice", "Ground" }),
new Pokemon(222, "Corsola", new List<string> { "Water", "Rock" }),
new Pokemon(223, "Remoraid", new List<string> { "Water" }),
new Pokemon(224, "Octillery", new List<string> { "Water" }),
new Pokemon(225, "Delibird", new List<string> { "Ice", "Flying" }),
new Pokemon(226, "Mantine", new List<string> { "Water", "Flying" }),
new Pokemon(227, "Skarmory", new List<string> { "Steel", "Flying" }),
new Pokemon(228, "Houndour", new List<string> { "Dark", "Fire" }),
new Pokemon(229, "Houndoom", new List<string> { "Dark", "Fire" }),
new Pokemon(230, "Kingdra", new List<string> { "Water", "Dragon" }),
new Pokemon(231, "Phanpy", new List<string> { "Ground" }),
new Pokemon(232, "Donphan", new List<string> { "Ground" }),
new Pokemon(233, "Porygon2", new List<string> { "Normal" }),
new Pokemon(234, "Stantler", new List<string> { "Normal" }),
new Pokemon(235, "Smeargle", new List<string> { "Normal" }),
new Pokemon(236, "Tyrogue", new List<string> { "Fighting" }),
new Pokemon(237, "Hitmontop", new List<string> { "Fighting" }),
new Pokemon(238, "Smoochum", new List<string> { "Ice", "Psychic" }),
new Pokemon(239, "Elekid", new List<string> { "Electric" }),
new Pokemon(240, "Magby", new List<string> { "Fire" }),
new Pokemon(241, "Miltank", new List<string> { "Normal" }),
new Pokemon(242, "Blissey", new List<string> { "Normal" }),
new Pokemon(243, "Raikou", new List<string> { "Electric" }),
new Pokemon(244, "Entei", new List<string> { "Fire" }),
new Pokemon(245, "Suicune", new List<string> { "Water" }),
new Pokemon(246, "Larvitar", new List<string> { "Rock", "Ground" }),
new Pokemon(247, "Pupitar", new List<string> { "Rock", "Ground" }),
new Pokemon(248, "Tyranitar", new List<string> { "Rock", "Dark" }),
new Pokemon(249, "Lugia", new List<string> { "Psychic", "Flying" }),
new Pokemon(250, "Ho-Oh", new List<string> { "Fire", "Flying" }),
new Pokemon(251, "Celebi", new List<string> { "Psychic", "Grass" }),
};
private readonly List<Pokemon> _johto =
[
new Pokemon(152, "Chikorita", ["Grass"]),
new Pokemon(153, "Bayleef", ["Grass"]),
new Pokemon(154, "Meganium", ["Grass"]),
new Pokemon(155, "Cyndaquil", ["Fire"]),
new Pokemon(156, "Quilava", ["Fire"]),
new Pokemon(157, "Typhlosion", ["Fire"]),
new Pokemon(158, "Totodile", ["Water"]),
new Pokemon(159, "Croconaw", ["Water"]),
new Pokemon(160, "Feraligatr", ["Water"]),
new Pokemon(161, "Sentret", ["Normal"]),
new Pokemon(162, "Furret", ["Normal"]),
new Pokemon(163, "Hoothoot", ["Normal", "Flying"]),
new Pokemon(164, "Noctowl", ["Normal", "Flying"]),
new Pokemon(165, "Ledyba", ["Bug", "Flying"]),
new Pokemon(166, "Ledian", ["Bug", "Flying"]),
new Pokemon(167, "Spinarak", ["Bug", "Poison"]),
new Pokemon(168, "Ariados", ["Bug", "Poison"]),
new Pokemon(169, "Crobat", ["Poison", "Flying"]),
new Pokemon(170, "Chinchou", ["Water", "Electric"]),
new Pokemon(171, "Lanturn", ["Water", "Electric"]),
new Pokemon(172, "Pichu", ["Electric"]),
new Pokemon(173, "Cleffa", ["Fairy"]),
new Pokemon(174, "Igglybuff", ["Normal", "Fairy"]),
new Pokemon(175, "Togepi", ["Fairy"]),
new Pokemon(176, "Togetic", ["Fairy", "Flying"]),
new Pokemon(177, "Natu", ["Psychic", "Flying"]),
new Pokemon(178, "Xatu", ["Psychic", "Flying"]),
new Pokemon(179, "Mareep", ["Electric"]),
new Pokemon(180, "Flaaffy", ["Electric"]),
new Pokemon(181, "Ampharos", ["Electric"]),
new Pokemon(182, "Bellossom", ["Grass"]),
new Pokemon(183, "Marill", ["Water", "Fairy"]),
new Pokemon(184, "Azumarill", ["Water", "Fairy"]),
new Pokemon(185, "Sudowoodo", ["Rock"]),
new Pokemon(186, "Politoed", ["Water"]),
new Pokemon(187, "Hoppip", ["Grass", "Flying"]),
new Pokemon(188, "Skiploom", ["Grass", "Flying"]),
new Pokemon(189, "Jumpluff", ["Grass", "Flying"]),
new Pokemon(190, "Aipom", ["Normal"]),
new Pokemon(191, "Sunkern", ["Grass"]),
new Pokemon(192, "Sunflora", ["Grass"]),
new Pokemon(193, "Yanma", ["Bug", "Flying"]),
new Pokemon(194, "Wooper", ["Water", "Ground"]),
new Pokemon(195, "Quagsire", ["Water", "Ground"]),
new Pokemon(196, "Espeon", ["Psychic"]),
new Pokemon(197, "Umbreon", ["Dark"]),
new Pokemon(198, "Murkrow", ["Dark", "Flying"]),
new Pokemon(199, "Slowking", ["Water", "Psychic"]),
new Pokemon(200, "Misdreavus", ["Ghost"]),
new Pokemon(201, "Unown", ["Psychic"]),
new Pokemon(202, "Wobbuffet", ["Psychic"]),
new Pokemon(203, "Girafarig", ["Normal", "Psychic"]),
new Pokemon(204, "Pineco", ["Bug"]),
new Pokemon(205, "Forretress", ["Bug", "Steel"]),
new Pokemon(206, "Dunsparce", ["Normal"]),
new Pokemon(207, "Gligar", ["Ground", "Flying"]),
new Pokemon(208, "Steelix", ["Steel", "Ground"]),
new Pokemon(209, "Snubbull", ["Fairy"]),
new Pokemon(210, "Granbull", ["Fairy"]),
new Pokemon(211, "Qwilfish", ["Water", "Poison"]),
new Pokemon(212, "Scizor", ["Bug", "Steel"]),
new Pokemon(213, "Shuckle", ["Bug", "Rock"]),
new Pokemon(214, "Heracross", ["Bug", "Fighting"]),
new Pokemon(215, "Sneasel", ["Dark", "Ice"]),
new Pokemon(216, "Teddiursa", ["Normal"]),
new Pokemon(217, "Ursaring", ["Normal"]),
new Pokemon(218, "Slugma", ["Fire"]),
new Pokemon(219, "Magcargo", ["Fire", "Rock"]),
new Pokemon(220, "Swinub", ["Ice", "Ground"]),
new Pokemon(221, "Piloswine", ["Ice", "Ground"]),
new Pokemon(222, "Corsola", ["Water", "Rock"]),
new Pokemon(223, "Remoraid", ["Water"]),
new Pokemon(224, "Octillery", ["Water"]),
new Pokemon(225, "Delibird", ["Ice", "Flying"]),
new Pokemon(226, "Mantine", ["Water", "Flying"]),
new Pokemon(227, "Skarmory", ["Steel", "Flying"]),
new Pokemon(228, "Houndour", ["Dark", "Fire"]),
new Pokemon(229, "Houndoom", ["Dark", "Fire"]),
new Pokemon(230, "Kingdra", ["Water", "Dragon"]),
new Pokemon(231, "Phanpy", ["Ground"]),
new Pokemon(232, "Donphan", ["Ground"]),
new Pokemon(233, "Porygon2", ["Normal"]),
new Pokemon(234, "Stantler", ["Normal"]),
new Pokemon(235, "Smeargle", ["Normal"]),
new Pokemon(236, "Tyrogue", ["Fighting"]),
new Pokemon(237, "Hitmontop", ["Fighting"]),
new Pokemon(238, "Smoochum", ["Ice", "Psychic"]),
new Pokemon(239, "Elekid", ["Electric"]),
new Pokemon(240, "Magby", ["Fire"]),
new Pokemon(241, "Miltank", ["Normal"]),
new Pokemon(242, "Blissey", ["Normal"]),
new Pokemon(243, "Raikou", ["Electric"]),
new Pokemon(244, "Entei", ["Fire"]),
new Pokemon(245, "Suicune", ["Water"]),
new Pokemon(246, "Larvitar", ["Rock", "Ground"]),
new Pokemon(247, "Pupitar", ["Rock", "Ground"]),
new Pokemon(248, "Tyranitar", ["Rock", "Dark"]),
new Pokemon(249, "Lugia", ["Psychic", "Flying"]),
new Pokemon(250, "Ho-Oh", ["Fire", "Flying"]),
new Pokemon(251, "Celebi", ["Psychic", "Grass"]),
];
private readonly List<Pokemon> _hoenn = new()
{
new Pokemon(252, "Treecko", new List<string> { "Grass" }),
new Pokemon(253, "Grovyle", new List<string> { "Grass" }),
new Pokemon(254, "Sceptile", new List<string> { "Grass" }),
new Pokemon(255, "Torchic", new List<string> { "Fire" }),
new Pokemon(256, "Combusken", new List<string> { "Fire", "Fighting" }),
new Pokemon(257, "Blaziken", new List<string> { "Fire", "Fighting" }),
new Pokemon(258, "Mudkip", new List<string> { "Water" }),
new Pokemon(259, "Marshtomp", new List<string> { "Water", "Ground" }),
new Pokemon(260, "Swampert", new List<string> { "Water", "Ground" }),
new Pokemon(261, "Poochyena", new List<string> { "Dark" }),
new Pokemon(262, "Mightyena", new List<string> { "Dark" }),
new Pokemon(263, "Zigzagoon", new List<string> { "Normal" }),
new Pokemon(264, "Linoone", new List<string> { "Normal" }),
new Pokemon(265, "Wurmple", new List<string> { "Bug" }),
new Pokemon(266, "Silcoon", new List<string> { "Bug" }),
new Pokemon(267, "Beautifly", new List<string> { "Bug", "Flying" }),
new Pokemon(268, "Cascoon", new List<string> { "Bug" }),
new Pokemon(269, "Dustox", new List<string> { "Bug", "Poison" }),
new Pokemon(270, "Lotad", new List<string> { "Water", "Grass" }),
new Pokemon(271, "Lombre", new List<string> { "Water", "Grass" }),
new Pokemon(272, "Ludicolo", new List<string> { "Water", "Grass" }),
new Pokemon(273, "Seedot", new List<string> { "Grass" }),
new Pokemon(274, "Nuzleaf", new List<string> { "Grass", "Dark" }),
new Pokemon(275, "Shiftry", new List<string> { "Grass", "Dark" }),
new Pokemon(276, "Taillow", new List<string> { "Normal", "Flying" }),
new Pokemon(277, "Swellow", new List<string> { "Normal", "Flying" }),
new Pokemon(278, "Wingull", new List<string> { "Water", "Flying" }),
new Pokemon(279, "Pelipper", new List<string> { "Water", "Flying" }),
new Pokemon(280, "Ralts", new List<string> { "Psychic", "Fairy" }),
new Pokemon(281, "Kirlia", new List<string> { "Psychic", "Fairy" }),
new Pokemon(282, "Gardevoir", new List<string> { "Psychic", "Fairy" }),
new Pokemon(283, "Surskit", new List<string> { "Bug", "Water" }),
new Pokemon(284, "Masquerain", new List<string> { "Bug", "Flying" }),
new Pokemon(285, "Shroomish", new List<string> { "Grass" }),
new Pokemon(286, "Breloom", new List<string> { "Grass", "Fighting" }),
new Pokemon(287, "Slakoth", new List<string> { "Normal" }),
new Pokemon(288, "Vigoroth", new List<string> { "Normal" }),
new Pokemon(289, "Slaking", new List<string> { "Normal" }),
new Pokemon(290, "Nincada", new List<string> { "Bug", "Ground" }),
new Pokemon(291, "Ninjask", new List<string> { "Bug", "Flying" }),
new Pokemon(292, "Shedinja", new List<string> { "Bug", "Ghost" }),
new Pokemon(293, "Whismur", new List<string> { "Normal" }),
new Pokemon(294, "Loudred", new List<string> { "Normal" }),
new Pokemon(295, "Exploud", new List<string> { "Normal" }),
new Pokemon(296, "Makuhita", new List<string> { "Fighting" }),
new Pokemon(297, "Hariyama", new List<string> { "Fighting" }),
new Pokemon(298, "Azurill", new List<string> { "Normal", "Fairy" }),
new Pokemon(299, "Nosepass", new List<string> { "Rock" }),
new Pokemon(300, "Skitty", new List<string> { "Normal" }),
new Pokemon(301, "Delcatty", new List<string> { "Normal" }),
new Pokemon(302, "Sableye", new List<string> { "Dark", "Ghost" }),
new Pokemon(303, "Mawile", new List<string> { "Steel", "Fairy" }),
new Pokemon(304, "Aron", new List<string> { "Steel", "Rock" }),
new Pokemon(305, "Lairon", new List<string> { "Steel", "Rock" }),
new Pokemon(306, "Aggron", new List<string> { "Steel", "Rock" }),
new Pokemon(307, "Meditite", new List<string> { "Fighting", "Psychic" }),
new Pokemon(308, "Medicham", new List<string> { "Fighting", "Psychic" }),
new Pokemon(309, "Electrike", new List<string> { "Electric" }),
new Pokemon(310, "Manectric", new List<string> { "Electric" }),
new Pokemon(311, "Plusle", new List<string> { "Electric" }),
new Pokemon(312, "Minun", new List<string> { "Electric" }),
new Pokemon(313, "Volbeat", new List<string> { "Bug" }),
new Pokemon(314, "Illumise", new List<string> { "Bug" }),
new Pokemon(315, "Roselia", new List<string> { "Grass", "Poison" }),
new Pokemon(316, "Gulpin", new List<string> { "Poison" }),
new Pokemon(317, "Swalot", new List<string> { "Poison" }),
new Pokemon(318, "Carvanha", new List<string> { "Water", "Dark" }),
new Pokemon(319, "Sharpedo", new List<string> { "Water", "Dark" }),
new Pokemon(320, "Wailmer", new List<string> { "Water" }),
new Pokemon(321, "Wailord", new List<string> { "Water" }),
new Pokemon(322, "Numel", new List<string> { "Fire", "Ground" }),
new Pokemon(323, "Camerupt", new List<string> { "Fire", "Ground" }),
new Pokemon(324, "Torkoal", new List<string> { "Fire" }),
new Pokemon(325, "Spoink", new List<string> { "Psychic" }),
new Pokemon(326, "Grumpig", new List<string> { "Psychic" }),
new Pokemon(327, "Spinda", new List<string> { "Normal" }),
new Pokemon(328, "Trapinch", new List<string> { "Ground" }),
new Pokemon(329, "Vibrava", new List<string> { "Ground", "Dragon" }),
new Pokemon(330, "Flygon", new List<string> { "Ground", "Dragon" }),
new Pokemon(331, "Cacnea", new List<string> { "Grass" }),
new Pokemon(332, "Cacturne", new List<string> { "Grass", "Dark" }),
new Pokemon(333, "Swablu", new List<string> { "Normal", "Flying" }),
new Pokemon(334, "Altaria", new List<string> { "Dragon", "Flying" }),
new Pokemon(335, "Zangoose", new List<string> { "Normal" }),
new Pokemon(336, "Seviper", new List<string> { "Poison" }),
new Pokemon(337, "Lunatone", new List<string> { "Rock", "Psychic" }),
new Pokemon(338, "Solrock", new List<string> { "Rock", "Psychic" }),
new Pokemon(339, "Barboach", new List<string> { "Water", "Ground" }),
new Pokemon(340, "Whiscash", new List<string> { "Water", "Ground" }),
new Pokemon(341, "Corphish", new List<string> { "Water" }),
new Pokemon(342, "Crawdaunt", new List<string> { "Water", "Dark" }),
new Pokemon(343, "Baltoy", new List<string> { "Ground", "Psychic" }),
new Pokemon(344, "Claydol", new List<string> { "Ground", "Psychic" }),
new Pokemon(345, "Lileep", new List<string> { "Rock", "Grass" }),
new Pokemon(346, "Cradily", new List<string> { "Rock", "Grass" }),
new Pokemon(347, "Anorith", new List<string> { "Rock", "Bug" }),
new Pokemon(348, "Armaldo", new List<string> { "Rock", "Bug" }),
new Pokemon(349, "Feebas", new List<string> { "Water" }),
new Pokemon(350, "Milotic", new List<string> { "Water" }),
new Pokemon(351, "Castform", new List<string> { "Normal" }),
new Pokemon(352, "Kecleon", new List<string> { "Normal" }),
new Pokemon(353, "Shuppet", new List<string> { "Ghost" }),
new Pokemon(354, "Banette", new List<string> { "Ghost" }),
new Pokemon(355, "Duskull", new List<string> { "Ghost" }),
new Pokemon(356, "Dusclops", new List<string> { "Ghost" }),
new Pokemon(357, "Tropius", new List<string> { "Grass", "Flying" }),
new Pokemon(358, "Chimecho", new List<string> { "Psychic" }),
new Pokemon(359, "Absol", new List<string> { "Dark" }),
new Pokemon(360, "Wynaut", new List<string> { "Psychic" }),
new Pokemon(361, "Snorunt", new List<string> { "Ice" }),
new Pokemon(362, "Glalie", new List<string> { "Ice" }),
new Pokemon(363, "Spheal", new List<string> { "Ice", "Water" }),
new Pokemon(364, "Sealeo", new List<string> { "Ice", "Water" }),
new Pokemon(365, "Walrein", new List<string> { "Ice", "Water" }),
new Pokemon(366, "Clamperl", new List<string> { "Water" }),
new Pokemon(367, "Huntail", new List<string> { "Water" }),
new Pokemon(368, "Gorebyss", new List<string> { "Water" }),
new Pokemon(369, "Relicanth", new List<string> { "Water", "Rock" }),
new Pokemon(370, "Luvdisc", new List<string> { "Water" }),
new Pokemon(371, "Bagon", new List<string> { "Dragon" }),
new Pokemon(372, "Shelgon", new List<string> { "Dragon" }),
new Pokemon(373, "Salamence", new List<string> { "Dragon", "Flying" }),
new Pokemon(374, "Beldum", new List<string> { "Steel", "Psychic" }),
new Pokemon(375, "Metang", new List<string> { "Steel", "Psychic" }),
new Pokemon(376, "Metagross", new List<string> { "Steel", "Psychic" }),
new Pokemon(377, "Regirock", new List<string> { "Rock" }),
new Pokemon(378, "Regice", new List<string> { "Ice" }),
new Pokemon(379, "Registeel", new List<string> { "Steel" }),
new Pokemon(380, "Latias", new List<string> { "Dragon", "Psychic" }),
new Pokemon(381, "Latios", new List<string> { "Dragon", "Psychic" }),
new Pokemon(382, "Kyogre", new List<string> { "Water" }),
new Pokemon(383, "Groudon", new List<string> { "Ground" }),
new Pokemon(384, "Rayquaza", new List<string> { "Dragon", "Flying" }),
new Pokemon(385, "Jirachi", new List<string> { "Steel", "Psychic" }),
new Pokemon(386, "Deoxys", new List<string> { "Psychic" }),
};
private readonly List<Pokemon> _hoenn =
[
new Pokemon(252, "Treecko", ["Grass"]),
new Pokemon(253, "Grovyle", ["Grass"]),
new Pokemon(254, "Sceptile", ["Grass"]),
new Pokemon(255, "Torchic", ["Fire"]),
new Pokemon(256, "Combusken", ["Fire", "Fighting"]),
new Pokemon(257, "Blaziken", ["Fire", "Fighting"]),
new Pokemon(258, "Mudkip", ["Water"]),
new Pokemon(259, "Marshtomp", ["Water", "Ground"]),
new Pokemon(260, "Swampert", ["Water", "Ground"]),
new Pokemon(261, "Poochyena", ["Dark"]),
new Pokemon(262, "Mightyena", ["Dark"]),
new Pokemon(263, "Zigzagoon", ["Normal"]),
new Pokemon(264, "Linoone", ["Normal"]),
new Pokemon(265, "Wurmple", ["Bug"]),
new Pokemon(266, "Silcoon", ["Bug"]),
new Pokemon(267, "Beautifly", ["Bug", "Flying"]),
new Pokemon(268, "Cascoon", ["Bug"]),
new Pokemon(269, "Dustox", ["Bug", "Poison"]),
new Pokemon(270, "Lotad", ["Water", "Grass"]),
new Pokemon(271, "Lombre", ["Water", "Grass"]),
new Pokemon(272, "Ludicolo", ["Water", "Grass"]),
new Pokemon(273, "Seedot", ["Grass"]),
new Pokemon(274, "Nuzleaf", ["Grass", "Dark"]),
new Pokemon(275, "Shiftry", ["Grass", "Dark"]),
new Pokemon(276, "Taillow", ["Normal", "Flying"]),
new Pokemon(277, "Swellow", ["Normal", "Flying"]),
new Pokemon(278, "Wingull", ["Water", "Flying"]),
new Pokemon(279, "Pelipper", ["Water", "Flying"]),
new Pokemon(280, "Ralts", ["Psychic", "Fairy"]),
new Pokemon(281, "Kirlia", ["Psychic", "Fairy"]),
new Pokemon(282, "Gardevoir", ["Psychic", "Fairy"]),
new Pokemon(283, "Surskit", ["Bug", "Water"]),
new Pokemon(284, "Masquerain", ["Bug", "Flying"]),
new Pokemon(285, "Shroomish", ["Grass"]),
new Pokemon(286, "Breloom", ["Grass", "Fighting"]),
new Pokemon(287, "Slakoth", ["Normal"]),
new Pokemon(288, "Vigoroth", ["Normal"]),
new Pokemon(289, "Slaking", ["Normal"]),
new Pokemon(290, "Nincada", ["Bug", "Ground"]),
new Pokemon(291, "Ninjask", ["Bug", "Flying"]),
new Pokemon(292, "Shedinja", ["Bug", "Ghost"]),
new Pokemon(293, "Whismur", ["Normal"]),
new Pokemon(294, "Loudred", ["Normal"]),
new Pokemon(295, "Exploud", ["Normal"]),
new Pokemon(296, "Makuhita", ["Fighting"]),
new Pokemon(297, "Hariyama", ["Fighting"]),
new Pokemon(298, "Azurill", ["Normal", "Fairy"]),
new Pokemon(299, "Nosepass", ["Rock"]),
new Pokemon(300, "Skitty", ["Normal"]),
new Pokemon(301, "Delcatty", ["Normal"]),
new Pokemon(302, "Sableye", ["Dark", "Ghost"]),
new Pokemon(303, "Mawile", ["Steel", "Fairy"]),
new Pokemon(304, "Aron", ["Steel", "Rock"]),
new Pokemon(305, "Lairon", ["Steel", "Rock"]),
new Pokemon(306, "Aggron", ["Steel", "Rock"]),
new Pokemon(307, "Meditite", ["Fighting", "Psychic"]),
new Pokemon(308, "Medicham", ["Fighting", "Psychic"]),
new Pokemon(309, "Electrike", ["Electric"]),
new Pokemon(310, "Manectric", ["Electric"]),
new Pokemon(311, "Plusle", ["Electric"]),
new Pokemon(312, "Minun", ["Electric"]),
new Pokemon(313, "Volbeat", ["Bug"]),
new Pokemon(314, "Illumise", ["Bug"]),
new Pokemon(315, "Roselia", ["Grass", "Poison"]),
new Pokemon(316, "Gulpin", ["Poison"]),
new Pokemon(317, "Swalot", ["Poison"]),
new Pokemon(318, "Carvanha", ["Water", "Dark"]),
new Pokemon(319, "Sharpedo", ["Water", "Dark"]),
new Pokemon(320, "Wailmer", ["Water"]),
new Pokemon(321, "Wailord", ["Water"]),
new Pokemon(322, "Numel", ["Fire", "Ground"]),
new Pokemon(323, "Camerupt", ["Fire", "Ground"]),
new Pokemon(324, "Torkoal", ["Fire"]),
new Pokemon(325, "Spoink", ["Psychic"]),
new Pokemon(326, "Grumpig", ["Psychic"]),
new Pokemon(327, "Spinda", ["Normal"]),
new Pokemon(328, "Trapinch", ["Ground"]),
new Pokemon(329, "Vibrava", ["Ground", "Dragon"]),
new Pokemon(330, "Flygon", ["Ground", "Dragon"]),
new Pokemon(331, "Cacnea", ["Grass"]),
new Pokemon(332, "Cacturne", ["Grass", "Dark"]),
new Pokemon(333, "Swablu", ["Normal", "Flying"]),
new Pokemon(334, "Altaria", ["Dragon", "Flying"]),
new Pokemon(335, "Zangoose", ["Normal"]),
new Pokemon(336, "Seviper", ["Poison"]),
new Pokemon(337, "Lunatone", ["Rock", "Psychic"]),
new Pokemon(338, "Solrock", ["Rock", "Psychic"]),
new Pokemon(339, "Barboach", ["Water", "Ground"]),
new Pokemon(340, "Whiscash", ["Water", "Ground"]),
new Pokemon(341, "Corphish", ["Water"]),
new Pokemon(342, "Crawdaunt", ["Water", "Dark"]),
new Pokemon(343, "Baltoy", ["Ground", "Psychic"]),
new Pokemon(344, "Claydol", ["Ground", "Psychic"]),
new Pokemon(345, "Lileep", ["Rock", "Grass"]),
new Pokemon(346, "Cradily", ["Rock", "Grass"]),
new Pokemon(347, "Anorith", ["Rock", "Bug"]),
new Pokemon(348, "Armaldo", ["Rock", "Bug"]),
new Pokemon(349, "Feebas", ["Water"]),
new Pokemon(350, "Milotic", ["Water"]),
new Pokemon(351, "Castform", ["Normal"]),
new Pokemon(352, "Kecleon", ["Normal"]),
new Pokemon(353, "Shuppet", ["Ghost"]),
new Pokemon(354, "Banette", ["Ghost"]),
new Pokemon(355, "Duskull", ["Ghost"]),
new Pokemon(356, "Dusclops", ["Ghost"]),
new Pokemon(357, "Tropius", ["Grass", "Flying"]),
new Pokemon(358, "Chimecho", ["Psychic"]),
new Pokemon(359, "Absol", ["Dark"]),
new Pokemon(360, "Wynaut", ["Psychic"]),
new Pokemon(361, "Snorunt", ["Ice"]),
new Pokemon(362, "Glalie", ["Ice"]),
new Pokemon(363, "Spheal", ["Ice", "Water"]),
new Pokemon(364, "Sealeo", ["Ice", "Water"]),
new Pokemon(365, "Walrein", ["Ice", "Water"]),
new Pokemon(366, "Clamperl", ["Water"]),
new Pokemon(367, "Huntail", ["Water"]),
new Pokemon(368, "Gorebyss", ["Water"]),
new Pokemon(369, "Relicanth", ["Water", "Rock"]),
new Pokemon(370, "Luvdisc", ["Water"]),
new Pokemon(371, "Bagon", ["Dragon"]),
new Pokemon(372, "Shelgon", ["Dragon"]),
new Pokemon(373, "Salamence", ["Dragon", "Flying"]),
new Pokemon(374, "Beldum", ["Steel", "Psychic"]),
new Pokemon(375, "Metang", ["Steel", "Psychic"]),
new Pokemon(376, "Metagross", ["Steel", "Psychic"]),
new Pokemon(377, "Regirock", ["Rock"]),
new Pokemon(378, "Regice", ["Ice"]),
new Pokemon(379, "Registeel", ["Steel"]),
new Pokemon(380, "Latias", ["Dragon", "Psychic"]),
new Pokemon(381, "Latios", ["Dragon", "Psychic"]),
new Pokemon(382, "Kyogre", ["Water"]),
new Pokemon(383, "Groudon", ["Ground"]),
new Pokemon(384, "Rayquaza", ["Dragon", "Flying"]),
new Pokemon(385, "Jirachi", ["Steel", "Psychic"]),
new Pokemon(386, "Deoxys", ["Psychic"]),
];
public PokedexExtensionPage()
{
@@ -447,10 +446,7 @@ internal sealed partial class PokedexExtensionPage : ListPage
Name = "Pokedex";
}
public override IListItem[] GetItems()
{
return _kanto.AsEnumerable().Concat(_johto.AsEnumerable()).Concat(_hoenn.AsEnumerable()).Select(p => GetPokemonListItem(p)).ToArray();
}
public override IListItem[] GetItems() => _kanto.AsEnumerable().Concat(_johto.AsEnumerable()).Concat(_hoenn.AsEnumerable()).Select(GetPokemonListItem).ToArray();
private static ListItem GetPokemonListItem(Pokemon pokemon)
{
@@ -462,38 +458,31 @@ internal sealed partial class PokedexExtensionPage : ListPage
}
// Dictionary mapping Pokémon types to their corresponding colors
private static readonly Dictionary<string, Color> TypeColors = new()
private static readonly Dictionary<string, OptionalColor> TypeColors = new()
{
{ "Normal", Color.FromArgb(255, 168, 168, 120) }, // Light Brownish Grey
{ "Fire", Color.FromArgb(255, 240, 128, 48) }, // Orange-Red
{ "Water", Color.FromArgb(255, 104, 144, 240) }, // Medium Blue
{ "Electric", Color.FromArgb(255, 248, 208, 48) }, // Yellow
{ "Grass", Color.FromArgb(255, 120, 200, 80) }, // Green
{ "Ice", Color.FromArgb(255, 152, 216, 216) }, // Cyan
{ "Fighting", Color.FromArgb(255, 192, 48, 40) }, // Red
{ "Poison", Color.FromArgb(255, 160, 64, 160) }, // Purple
{ "Ground", Color.FromArgb(255, 224, 192, 104) }, // Yellowish Brown
{ "Flying", Color.FromArgb(255, 168, 144, 240) }, // Light Blue
{ "Psychic", Color.FromArgb(255, 248, 88, 136) }, // Pink
{ "Bug", Color.FromArgb(255, 168, 184, 32) }, // Greenish Yellow
{ "Rock", Color.FromArgb(255, 184, 160, 56) }, // Brown
{ "Ghost", Color.FromArgb(255, 112, 88, 152) }, // Dark Purple
{ "Dragon", Color.FromArgb(255, 112, 56, 248) }, // Blue-Violet
{ "Dark", Color.FromArgb(255, 112, 88, 72) }, // Dark Brown
{ "Steel", Color.FromArgb(255, 184, 184, 208) }, // Light Grey
{ "Fairy", Color.FromArgb(255, 238, 153, 172) }, // Light Pink
{ "Normal", ColorHelpers.FromArgb(255, 168, 168, 120) }, // Light Brownish Grey
{ "Fire", ColorHelpers.FromArgb(255, 240, 128, 48) }, // Orange-Red
{ "Water", ColorHelpers.FromArgb(255, 104, 144, 240) }, // Medium Blue
{ "Electric", ColorHelpers.FromArgb(255, 248, 208, 48) }, // Yellow
{ "Grass", ColorHelpers.FromArgb(255, 120, 200, 80) }, // Green
{ "Ice", ColorHelpers.FromArgb(255, 152, 216, 216) }, // Cyan
{ "Fighting", ColorHelpers.FromArgb(255, 192, 48, 40) }, // Red
{ "Poison", ColorHelpers.FromArgb(255, 160, 64, 160) }, // Purple
{ "Ground", ColorHelpers.FromArgb(255, 224, 192, 104) }, // Yellowish Brown
{ "Flying", ColorHelpers.FromArgb(255, 168, 144, 240) }, // Light Blue
{ "Psychic", ColorHelpers.FromArgb(255, 248, 88, 136) }, // Pink
{ "Bug", ColorHelpers.FromArgb(255, 168, 184, 32) }, // Greenish Yellow
{ "Rock", ColorHelpers.FromArgb(255, 184, 160, 56) }, // Brown
{ "Ghost", ColorHelpers.FromArgb(255, 112, 88, 152) }, // Dark Purple
{ "Dragon", ColorHelpers.FromArgb(255, 112, 56, 248) }, // Blue-Violet
{ "Dark", ColorHelpers.FromArgb(255, 112, 88, 72) }, // Dark Brown
{ "Steel", ColorHelpers.FromArgb(255, 184, 184, 208) }, // Light Grey
{ "Fairy", ColorHelpers.FromArgb(255, 238, 153, 172) }, // Light Pink
};
// Method to get the color for a given type
public static Color GetColorForType(string type)
{
// Check if the type exists in the dictionary
if (TypeColors.TryGetValue(type, out var color))
{
return color;
}
public static OptionalColor GetColorForType(string type) =>
// Default color (e.g., white) if the type is not found
return Color.FromArgb(255, 255, 255, 255);
}
// Check if the type exists in the dictionary
TypeColors.TryGetValue(type, out var color) ? color : ColorHelpers.NoColor();
}

View File

@@ -26,7 +26,7 @@ internal sealed partial class ProcessListPage : ListPage
private IListItem[] DoGetItems()
{
var items = GetRunningProcesses();
this.Loading = false;
this.IsLoading = false;
var s = items
.OrderByDescending(p => p.Memory)
.Select((process) => new ListItem(new SwitchToProcess(process))

View File

@@ -15,7 +15,7 @@ internal sealed partial class SampleDynamicListPage : DynamicListPage
{
Icon = new(string.Empty);
Name = "Dynamic List";
Loading = true;
IsLoading = true;
}
public override void UpdateSearchText(string oldSearch, string newSearch) => RaiseItemsChanged(newSearch.Length);

View File

@@ -31,7 +31,7 @@ public partial class PageViewModel : ExtensionObjectViewModel
// on the UI thread.
public string Name { get; private set; } = string.Empty;
public bool Loading { get; private set; } = true;
public bool IsLoading { get; private set; } = true;
public PageViewModel(IPage model, TaskScheduler scheduler)
{
@@ -69,11 +69,11 @@ public partial class PageViewModel : ExtensionObjectViewModel
}
Name = page.Name;
Loading = page.Loading;
IsLoading = page.IsLoading;
// Let the UI know about our initial properties too.
UpdateProperty(nameof(Name));
UpdateProperty(nameof(Loading));
UpdateProperty(nameof(IsLoading));
page.PropChanged += Model_PropChanged;
}
@@ -104,8 +104,8 @@ public partial class PageViewModel : ExtensionObjectViewModel
case nameof(Name):
this.Name = model.Name ?? string.Empty;
break;
case nameof(Loading):
this.Loading = model.Loading;
case nameof(IsLoading):
this.IsLoading = model.IsLoading;
break;
}

View File

@@ -4,7 +4,6 @@
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.UI.ViewModels.Models;
using Windows.UI;
namespace Microsoft.CmdPal.UI.ViewModels;
@@ -18,7 +17,7 @@ public partial class TagViewModel(ITag _tag, TaskScheduler Scheduler) : Extensio
public string Tooltip { get; private set; } = string.Empty;
public Color Color { get; private set; }
public OptionalColor Color { get; private set; }
// TODO Icon
public ExtensionObject<ICommand> Command { get; private set; } = new(null);

View File

@@ -113,7 +113,7 @@
<ProgressBar
IsIndeterminate="True"
VerticalAlignment="Top"
Visibility="{x:Bind ViewModel.Loading, Mode=OneWay}" />
Visibility="{x:Bind ViewModel.IsLoading, Mode=OneWay}" />
<!-- not using Interactivity:Interaction.Behaviors due to wanting to do AoT -->
<!--
sticking with ListView as ItemsView doesn't have grouping built-in, could investigate coordinating

View File

@@ -19,7 +19,7 @@ public sealed partial class MainListPage : DynamicListPage
private readonly MainViewModel _mainViewModel;
private readonly FilteredListSection _filteredSection;
private readonly ObservableCollection<MainListItem> topLevelItems = new();
private readonly ObservableCollection<MainListItem> topLevelItems = [];
private readonly DispatcherQueue _dispatcherQueue;
@@ -53,13 +53,10 @@ public sealed partial class MainListPage : DynamicListPage
PlaceholderText = "Search...";
ShowDetails = true;
Loading = false;
IsLoading = false;
}
public override void UpdateSearchText(string oldSearch, string newSearch)
{
UpdateQuery();
}
public override void UpdateSearchText(string oldSearch, string newSearch) => UpdateQuery();
private void UpdateQuery()
{
@@ -130,7 +127,7 @@ public sealed partial class MainListPage : DynamicListPage
{
foreach (var item in e.OldItems)
{
if (item is ExtensionObject<ICommandItem> _)
if (item is ExtensionObject<ICommandItem>)
{
// If we were maintaining the POC project we'd remove the items here.
}

View File

@@ -4,7 +4,6 @@
using Microsoft.CmdPal.Extensions;
using Windows.Foundation;
using Windows.UI;
namespace WindowsCommandPalette;
@@ -17,7 +16,20 @@ public class PageViewModel
// public IPage PageAction { get => pageAction; set => pageAction = value; }
public ActionViewModel Command { get; }
public Color AccentColor => PageAction.AccentColor;
public Windows.UI.Color AccentColor
{
get
{
var accent = PageAction.AccentColor;
if (accent.HasValue)
{
var c = accent.Color;
return Windows.UI.Color.FromArgb(c.A, c.R, c.G, c.B);
}
return default;
}
}
public event TypedEventHandler<object, ActionViewModel>? RequestDoAction;

View File

@@ -2,7 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using Microsoft.CmdPal.Extensions;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
@@ -10,7 +9,7 @@ using Windows.UI;
namespace WindowsCommandPalette;
public sealed class TagViewModel : INotifyPropertyChanged
public sealed class TagViewModel
{
private readonly ITag _tag;
@@ -18,18 +17,32 @@ public sealed class TagViewModel : INotifyPropertyChanged
internal string Text => _tag.Text;
public event PropertyChangedEventHandler? PropertyChanged;
public bool HasIcon => !string.IsNullOrEmpty(Icon?.Icon);
internal IconElement IcoElement => Microsoft.Terminal.UI.IconPathConverter.IconMUX(Icon?.Icon ?? string.Empty, 10);
public Windows.UI.Color Color
{
get
{
var color = _tag.Color;
if (color.HasValue)
{
var c = color.Color;
return Windows.UI.Color.FromArgb(c.A, c.R, c.G, c.B);
}
return default;
}
}
// TODO! VV These guys should have proper theme-aware lookups for default values
internal Brush BorderBrush => new SolidColorBrush(_tag.Color);
// All this code is exceptionally terrible, but it's just here to keep the POC app running at this point.
internal Brush BorderBrush => new SolidColorBrush(Color);
internal Brush TextBrush => new SolidColorBrush(_tag.Color.A == 0 ? Color.FromArgb(255, 255, 255, 255) : _tag.Color);
internal Brush TextBrush => new SolidColorBrush(Color.A == 0 ? Windows.UI.Color.FromArgb(255, 255, 255, 255) : Color);
internal Brush BackgroundBrush => new SolidColorBrush(_tag.Color.A == 0 ? _tag.Color : Color.FromArgb((byte)(_tag.Color.A / 4), _tag.Color.R, _tag.Color.G, _tag.Color.B));
internal Brush BackgroundBrush => new SolidColorBrush(Color.A == 0 ? Color : Windows.UI.Color.FromArgb((byte)(Color.A / 4), Color.R, Color.G, Color.B));
public TagViewModel(ITag tag)
{
@@ -37,9 +50,4 @@ public sealed class TagViewModel : INotifyPropertyChanged
// this.Tag.PropChanged += Tag_PropertyChanged;
}
private void Tag_PropertyChanged(object sender, Microsoft.CmdPal.Extensions.PropChangedEventArgs args)
{
this.PropertyChanged?.Invoke(this, new(args.PropertyName));
}
}

View File

@@ -19,8 +19,6 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
internal IListPage Page => (IListPage)this.PageAction;
private bool IsDynamic => Page is IDynamicListPage;
private IDynamicListPage? IsDynamicPage => Page as IDynamicListPage;
private readonly DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread();
@@ -30,7 +28,7 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
public bool ShowDetails => _forceShowDetails || Page.ShowDetails;
public bool HasMore { get; private set; }
public bool HasMoreItems { get; private set; }
public string PlaceholderText { get; private set; } = "Type here to search...";
@@ -46,7 +44,7 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
page.PropChanged += Page_PropChanged;
page.ItemsChanged += Page_ItemsChanged;
HasMore = page.HasMore;
HasMoreItems = page.HasMoreItems;
PlaceholderText = page.PlaceholderText;
}
@@ -68,8 +66,8 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
{
switch (args.PropertyName)
{
case nameof(HasMore):
HasMore = Page.HasMore;
case nameof(HasMoreItems):
HasMoreItems = Page.HasMoreItems;
break;
case nameof(PlaceholderText):
PlaceholderText = Page.PlaceholderText;
@@ -83,10 +81,7 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
});
}
internal Task InitialRender()
{
return UpdateListItems();
}
internal Task InitialRender() => UpdateListItems();
internal async Task UpdateListItems()
{
@@ -113,7 +108,7 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
// really hoping that the equality check in `InPlaceUpdateList`
// properly uses ListItemViewModel.Equals to compare if the objects
// are literally the same.
Collection<ListItemViewModel> newItems = new(items.Select(i => new ListItemViewModel(i)).ToList());
Collection<ListItemViewModel> newItems = [.. items.Select(i => new ListItemViewModel(i)).ToList()];
// Debug.WriteLine($" Found {newItems.Count} items");
@@ -142,14 +137,14 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
{
var filtered = ListItemViewModel
.FilterList(_items, query);
Collection<ListItemViewModel> newItems = new(filtered.ToList());
Collection<ListItemViewModel> newItems = [.. filtered.ToList()];
ListHelpers.InPlaceUpdateList(FilteredItems, newItems);
}
}
public async void LoadMoreIfNeeded()
{
if (!_loadingMore && HasMore)
if (!_loadingMore && HasMoreItems)
{
// This is kinda a hack, to prevent us from over-requesting
// more at the bottom.
@@ -160,7 +155,7 @@ public sealed class ListPageViewModel : PageViewModel, INotifyPropertyChanged
// TODO GH #73: When we have a real prototype, this should be an async call
// A thought: maybe the ExtensionObject.Unsafe could be an async
// call, so that you _know_ you need to wrap it up when you call it?
var t = new Task(() => Page.LoadMore());
var t = new Task(Page.LoadMore);
t.Start();
await t;
}

View File

@@ -59,6 +59,7 @@ functionality.
- [Other types](#other-types)
- [`ContextItem`s](#contextitems)
- [`IconDataType`](#icondatatype)
- [`OptionalColor`](#optionalcolor)
- [`Details`](#details)
- [`INotifyPropChanged`](#inotifypropchanged)
- [`ICommandProvider`](#icommandprovider)
@@ -640,9 +641,9 @@ information that the host application will then use to render the page.
```csharp
interface IPage requires ICommand {
String Title { get; };
Boolean Loading { get; };
Boolean IsLoading { get; };
Windows.UI.Color AccentColor { get; };
OptionalColor AccentColor { get; };
}
```
@@ -735,7 +736,7 @@ interface IListPage requires IPage, INotifyItemsChanged {
Boolean ShowDetails{ get; };
IFilters Filters { get; };
IGridProperties GridProperties { get; };
Boolean HasMore { get; };
Boolean HasMoreItems { get; };
IListItem[] GetItems();
void LoadMore();
@@ -930,7 +931,7 @@ class HackerNewsPage: Microsoft.Windows.Run.Extensions.ListPage {
public bool Loading => true;
IListItem[] GetItems() {
List<NewsItem> items = /* do some RSS feed stuff */;
this.Loading = false;
this.IsLoading = false;
return items
.Select((post) => new NewsListItem(post))
.ToArray();
@@ -1117,7 +1118,7 @@ class GithubIssuePage(GithubIssue issue): Microsoft.Windows.Run.Extensions.Markd
public bool Loading => true;
public string Body() {
issue.Body = /* fetch the body from the API */;
this.Loading = false;
this.IsLoading = false;
return issue.Body;
}
public IContextItem[] Commands => [ new CommandContextItem(new OpenLinkAction(issue)) ];
@@ -1224,6 +1225,32 @@ As a future consideration, we may also consider supporting a base64 encoded
image in the `Icon` member. Base64 doesn't include `:`, `.` or `\`, the presence
of any of which would indicate the string is probably a URI, not base64 data.
#### `OptionalColor`
We declare our own `Color` struct to avoid depending on `Windows.UI.Color` and
to avoid passing around unclothed `uint32s`.
```c#
struct Color
{
UInt8 R;
UInt8 G;
UInt8 B;
UInt8 A;
};
struct OptionalColor
{
Boolean HasValue;
Microsoft.CmdPal.Extensions.Color Color;
};
```
We also define `OptionalColor` as a helper struct here. Yes, this is also just
an `IReference<Color>`. However, `IReference` has some weird ownership semantics
that just make it a pain for something as simple as "maybe this color doesn't
have a value set".
#### `Details`
This represents additional information that can be displayed about an action or
@@ -1248,7 +1275,7 @@ block, and the generator will pull this into the file first. -->
interface ITag {
IconDataType Icon { get; };
String Text { get; };
Windows.UI.Color Color { get; };
OptionalColor Color { get; };
String ToolTip { get; };
ICommand Command { get; };
};
@@ -1542,7 +1569,7 @@ class HackerNewsPage: Microsoft.Windows.Run.Extensions.ListPage {
public bool Loading => true;
IListItem[] GetItems(String query) {
List<NewsItem> items = /* do some RSS feed stuff */;
this.Loading = false;
this.IsLoading = false;
return items
.Select((post) => new NewsListItem(post))
.ToArray();
@@ -1776,7 +1803,7 @@ classDiagram
IPage --|> ICommand
class IPage {
String Title
Boolean Loading
Boolean IsLoading
}
IInvokableCommand --|> ICommand
@@ -1884,7 +1911,7 @@ classDiagram
class ITag {
IconDataType Icon
String Text
Windows.UI.Color Color
Color Color
String ToolTip
ICommand Command
}

View File

@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace Microsoft.CmdPal.Extensions.Helpers;
public sealed class ColorHelpers
{
public static OptionalColor FromArgb(byte a, byte r, byte g, byte b) => new(true, new(r, g, b, a));
public static OptionalColor FromRgb(byte r, byte g, byte b) => new(true, new(r, g, b, 255));
public static OptionalColor Transparent() => new(true, new(0, 0, 0, 0));
public static OptionalColor NoColor() => new(false, new(0, 0, 0, 0));
}

View File

@@ -47,13 +47,13 @@ public class ListPage : Page, IListPage
}
}
public bool HasMore
public bool HasMoreItems
{
get => _hasMore;
set
{
_hasMore = value;
OnPropertyChanged(nameof(HasMore));
OnPropertyChanged(nameof(HasMoreItems));
}
}

View File

@@ -2,23 +2,21 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Windows.UI;
namespace Microsoft.CmdPal.Extensions.Helpers;
public partial class Page : Command, IPage
{
private bool _loading;
private string _title = string.Empty;
private Color _accentColor;
private OptionalColor _accentColor;
public bool Loading
public bool IsLoading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(Loading));
OnPropertyChanged(nameof(IsLoading));
}
}
@@ -32,7 +30,7 @@ public partial class Page : Command, IPage
}
}
public Color AccentColor
public OptionalColor AccentColor
{
get => _accentColor;
set

View File

@@ -2,19 +2,17 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Windows.UI;
namespace Microsoft.CmdPal.Extensions.Helpers;
public class Tag : BaseObservable, ITag
{
private Color _color;
private OptionalColor _color;
private IconDataType _icon = new(string.Empty);
private string _text = string.Empty;
private string _toolTip = string.Empty;
private ICommand? _command;
public Color Color
public OptionalColor Color
{
get => _color;
set

View File

@@ -114,11 +114,25 @@ namespace Microsoft.CmdPal.Extensions
IFilterItem[] Filters();
}
struct Color
{
UInt8 R;
UInt8 G;
UInt8 B;
UInt8 A;
};
struct OptionalColor
{
Boolean HasValue;
Microsoft.CmdPal.Extensions.Color Color;
};
[contract(Microsoft.CmdPal.Extensions.ExtensionsContract, 1)]
interface ITag {
IconDataType Icon { get; };
String Text { get; };
Windows.UI.Color Color { get; };
OptionalColor Color { get; };
String ToolTip { get; };
ICommand Command { get; };
};
@@ -197,9 +211,9 @@ namespace Microsoft.CmdPal.Extensions
[contract(Microsoft.CmdPal.Extensions.ExtensionsContract, 1)]
interface IPage requires ICommand {
String Title { get; };
Boolean Loading { get; };
Boolean IsLoading { get; };
Windows.UI.Color AccentColor { get; };
OptionalColor AccentColor { get; };
}
[uuid("c78b9851-e76b-43ee-8f76-da5ba14e69a4")]
@@ -247,7 +261,7 @@ namespace Microsoft.CmdPal.Extensions
Boolean ShowDetails{ get; };
IFilters Filters { get; };
IGridProperties GridProperties { get; };
Boolean HasMore { get; };
Boolean HasMoreItems { get; };
IListItem[] GetItems();
void LoadMore();