From eb76898d2cdf641ae1fa1439caba95b00bafa6ee Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Fri, 15 Nov 2024 05:31:46 -0800 Subject: [PATCH] Fix a layout cycle crash in the prototype (#156) Resurrects the Pokedex extension I was working on before Luca was born. This is a simple sample of a list with a _lot_ of items, and tags tags tags. It helps to repro a E_LAYOUT_CYCLE that we were seeing. This also fixes that layout cycle, by removing that unneeded `StackPanel` Fixes #WaitItLooksLikeINeverFiledThis --- PowerToys.sln | 21 + src/modules/cmdpal/.wt.json | 5 + .../Assets/LockScreenLogo.scale-200.png | Bin 0 -> 738 bytes .../Assets/SplashScreen.scale-200.png | Bin 0 -> 7806 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 0 -> 2948 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 0 -> 1052 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 481 bytes .../PokedexExtension/Assets/StoreLogo.png | Bin 0 -> 772 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 3433 bytes .../PokedexExtension/Package.appxmanifest | 78 +++ .../Pages/PokedexExtensionPage.cs | 522 ++++++++++++++++++ .../PokedexExtension/PokedexExtension.csproj | 56 ++ .../PokedexExtensionCommandsProvider.cs | 30 + .../cmdpal/Exts/PokedexExtension/Program.cs | 36 ++ .../Exts/PokedexExtension/SampleExtension.cs | 41 ++ .../cmdpal/Exts/PokedexExtension/app.manifest | 19 + .../WindowsCommandPalette/Views/ListPage.xaml | 15 +- 17 files changed, 813 insertions(+), 10 deletions(-) create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/LockScreenLogo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/SplashScreen.scale-200.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/Square150x150Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/StoreLogo.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Assets/Wide310x150Logo.scale-200.png create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Package.appxmanifest create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Pages/PokedexExtensionPage.cs create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/PokedexExtension.csproj create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/PokedexExtensionCommandsProvider.cs create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/Program.cs create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/SampleExtension.cs create mode 100644 src/modules/cmdpal/Exts/PokedexExtension/app.manifest diff --git a/PowerToys.sln b/PowerToys.sln index a68983acfa..e1decbf71b 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -692,6 +692,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.UI", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CmdPal.UI.ViewModels", "src\modules\cmdpal\Microsoft.CmdPal.UI.ViewModels\Microsoft.CmdPal.UI.ViewModels.csproj", "{C66020D1-CB10-4CF7-8715-84C97FD5E5E2}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PokedexExtension", "src\modules\cmdpal\Exts\PokedexExtension\PokedexExtension.csproj", "{D8DD2E06-7956-4673-95E7-F395AB5A5485}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -3212,6 +3214,24 @@ Global {C66020D1-CB10-4CF7-8715-84C97FD5E5E2}.Release|x64.Build.0 = Release|x64 {C66020D1-CB10-4CF7-8715-84C97FD5E5E2}.Release|x86.ActiveCfg = Release|x64 {C66020D1-CB10-4CF7-8715-84C97FD5E5E2}.Release|x86.Build.0 = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|ARM64.Build.0 = Debug|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x64.ActiveCfg = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x64.Build.0 = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x64.Deploy.0 = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x86.ActiveCfg = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x86.Build.0 = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Debug|x86.Deploy.0 = Debug|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|ARM64.ActiveCfg = Release|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|ARM64.Build.0 = Release|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|ARM64.Deploy.0 = Release|ARM64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x64.ActiveCfg = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x64.Build.0 = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x64.Deploy.0 = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x86.ActiveCfg = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x86.Build.0 = Release|x64 + {D8DD2E06-7956-4673-95E7-F395AB5A5485}.Release|x86.Deploy.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -3474,6 +3494,7 @@ Global {7520A2FE-00A2-49B8-83ED-DB216E874C04} = {3846508C-77EB-4034-A702-F8BB263C4F79} {8FBDABA4-40EE-4C0E-9BC8-2F6444A6EF90} = {7520A2FE-00A2-49B8-83ED-DB216E874C04} {C66020D1-CB10-4CF7-8715-84C97FD5E5E2} = {7520A2FE-00A2-49B8-83ED-DB216E874C04} + {D8DD2E06-7956-4673-95E7-F395AB5A5485} = {071E18A4-A530-46B8-AB7D-B862EE55E24E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0} diff --git a/src/modules/cmdpal/.wt.json b/src/modules/cmdpal/.wt.json index 7916abdbb6..6b0b0e83e6 100644 --- a/src/modules/cmdpal/.wt.json +++ b/src/modules/cmdpal/.wt.json @@ -11,6 +11,11 @@ "input": "tasklist | findstr Extension", "name": "List running extensions", "description": "This will list all running extensions, as long as they have 'Extension' in the name (they should)" + }, + { + "input": "for /F \"tokens=2\" %A in ('tasklist ^| findstr Extension') do taskkill /PID %A /F", + "name": "🚨 Terminate extensions 🚨", + "description": "Terminate anything with 'Extension' in the name" } ] } diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Assets/LockScreenLogo.scale-200.png b/src/modules/cmdpal/Exts/PokedexExtension/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..6f55b2f4e4fcab71ec572ed508889f278d8f6dbd GIT binary patch literal 738 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 D3gM79 literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.scale-200.png b/src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..52e63feb1ccef10546179c2d1a2d9c1042fc2802 GIT binary patch literal 1052 zcmb7@+fGwK6o#hxN)Dgha|$|LXP9;($h9kBd38 zwiM-uKuU{*n>(=0H8mu60aUR^2QtkrxatQ)Vi*DMo@F*o^^y2}$SjP66$<`s4F(2| z^n}qJ?Lo;859D)!+>2Bit5qtyoWM4z1_WR#@787QlE{EN5IAll!%)hS_GXxOZ`K}1 z=^6>>S=3(1x8E$Tmvy2w;Q9TGWEYU0X_IFWg$dn)R+5vbtX4lKq6Qcb)^|v>sdn;y z74k2sg481iv{7`_H;a)u;eSnX{`~Mx-pX4gC~MR_lsMNv7mX!$7$k~=RQ zZdbCOmgc>JR`q!Yz?u@U)^v^&Hw-a literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/src/modules/cmdpal/Exts/PokedexExtension/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000000000000000000000000000000000000..498c0936f3db51e31d6d2a9bc8df14e927f9bb28 GIT binary patch literal 481 zcmZXRy-LGi6ozA~v5iSY$xu6JiqNGL6r`fG(AI<+lu$%${V9|b!A?pGY7xQF#aqxT zaMQ8$Cd5G;om_egKF4oUc;DweIr+%>4jGSz^{{3cY0J*Z;v7+PUvtv8eWxv zDg&>wfBo^wGdjd8j;bE8=PpPgPuyNZwfVoXDXih_!FUQe2jxXEq&!ql#ubRii?~Emitm`>M zGBKAU`m+EPi$GRg7|1QX%M487Rg5Na2m5xR9m`Uby7G1de?Pu>gi^jm`bXeIHP(p5 wF6d>Vm}>R%(K?k(mX!*s+j7ZMRjaM#Q?ee~F~6Q3NdA%*_@T_Jwt;2*03E^9WWE58Rp61X(D{T`|4xzM&CJLjdenP)N+O&%{ zK_G6T7H*?O;BW9R^qr1byMpr#XTbZ;^)_qOm1InoY_cSTkflUCvIgTLm^;CaP_tG= z2w?yxB3h=*1#sYq8cH;G7H-!@;7&NRvmCH|+(1h&_qhb;%yVg0=lOd5VH{qT3gAhu zdV|4WsL$i~BOT(>B@1(qMQ_~A)0r2XuCk=)Q#4-y9DS=SL%O&zZG&!ZgZf)v`u2q6 z%JqCpQ#yb!vWP=gu>CS^OdIlAqiQjD28JivjfEnt6Nr`LbW1y0H}@0;>YC#OZ0-Sh zX);{?9&wn4Y2fwxpUr&?3t%2-M_~XqJPJBBfu>5cbTWcYaWAl^wJ8NU04uNuAjBXj z#r`*|7P<`868Yk2R)xkqe{-)_rBh}A#hL|+d~Y}d^$LytUJlv?u}g8&T6A%a90;K=+C7l>inH}IT>eQmP@qQ*(YTkXKf>Tmi^NirR?@Q|S^5N! CH^H9( literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Assets/Wide310x150Logo.scale-200.png b/src/modules/cmdpal/Exts/PokedexExtension/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..0a065030287b79c5017aba28231e22c96e26856e GIT binary patch literal 3433 zcmcgvTW=dh6drryjb-EF$i9=wk8WSx1SvHLIa_~h?mYn@t8YWh z4~zXw<7g)h^)UDtcoqEnXAeT&2Nr7lwEoBDTVrBeJmBMp-{`RT{!iV;@x0wiep3>Wf+ z-b;|qTmmweF{{o6DIJ8ce_j8`Y>j!CLdzX#|Gdm0x4slBIZ)!9d3H7}2)mWb#AE0j z2ZLN&TF6w|49~m=vpCS{dr-I$!_1VfCd7px}3%X4rU~nN{go z9*1J5-59i(>hq=N-ihS96GhHTH((b$BEhUpL6#nJdtL7xCi4WMYBQZ^4p z%d)Txq4J!Yf$go|@)8WsXDE+ChkF0a&re{@9ig`b{Ss%Z?cECpg{^vLxx-UX7l6^J4cS~R)ZXuzI zEm+6dH&C?0#C4}#m`0+9K>fj z^x2P&Yz2bhhTg$?sdDp^JuUt2$u>{bx!z6d$1Ck@u=DjBz)fXls6hq!*%K}%rN-fD z&GFnQ^f)mrR?~n#U((L{qC#&_Oc*k6I6iK*Sudcyo4`8%|j_3s(3L942`#eQqeRk{P%tY;lfrpr`{v_#Z1m|-0M=FM> z>!k>Wae+e^{--fq9^x{p36-@5-MB365SpRhsu)@BPVO7fY3d+eY0$hYR;NsTCNbXS zhet>TK%e#@QDhU`6+s&;tHZNG?bC&TcI}%x*4&kS@2v$Nv)_Td{pkiIcV>}?&vCHO z)>nAz7924aneNzgeRpN=f*ZLhn>+7$K5yN?@teD2T&6FY8-j8f{xwZ z;4u{URWAfsHs|xNu)DaybA0$u0Omj4v17c`L*z#z_(6!eU$hTlIB4)5?hO1msoANs M{Cq#&gve$727jCe=l}o! literal 0 HcmV?d00001 diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Package.appxmanifest b/src/modules/cmdpal/Exts/PokedexExtension/Package.appxmanifest new file mode 100644 index 0000000000..1d0ad3fe25 --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/Package.appxmanifest @@ -0,0 +1,78 @@ + + + + + + + + Pocket Monsters for the Command Palette + A Lone Developer + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Pages/PokedexExtensionPage.cs b/src/modules/cmdpal/Exts/PokedexExtension/Pages/PokedexExtensionPage.cs new file mode 100644 index 0000000000..ac4b11902d --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/Pages/PokedexExtensionPage.cs @@ -0,0 +1,522 @@ +// 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. + +using System.Collections.Generic; +using System.Linq; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; +using Windows.UI; + +namespace PokedexExtension; + +[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")] +[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:File name should match first type name", Justification = "This is sample code")] +public class Pokemon +{ + public int Number { get; set; } + + public string Name { get; set; } + + public List Types { get; set; } + + public string IconUrl => $"https://serebii.net/pokedex-sv/icon/new/{Number:D3}.png"; + + public Pokemon(int number, string name, List types) + { + Number = number; + Name = name; + Types = types; + } +} + +[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:File may only contain a single type", Justification = "This is sample code")] +internal sealed partial class PokemonPage : NoOpCommand +{ + public PokemonPage(Pokemon pokemon) + { + Name = pokemon.Name; + Icon = new(pokemon.IconUrl); + } +} + +[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 _kanto = new() + { + new Pokemon(1, "Bulbasaur", new List { "Grass", "Poison" }), + new Pokemon(2, "Ivysaur", new List { "Grass", "Poison" }), + new Pokemon(3, "Venusaur", new List { "Grass", "Poison" }), + new Pokemon(4, "Charmander", new List { "Fire" }), + new Pokemon(5, "Charmeleon", new List { "Fire" }), + new Pokemon(6, "Charizard", new List { "Fire", "Flying" }), + new Pokemon(7, "Squirtle", new List { "Water" }), + new Pokemon(8, "Wartortle", new List { "Water" }), + new Pokemon(9, "Blastoise", new List { "Water" }), + new Pokemon(10, "Caterpie", new List { "Bug" }), + new Pokemon(11, "Metapod", new List { "Bug" }), + new Pokemon(12, "Butterfree", new List { "Bug", "Flying" }), + new Pokemon(13, "Weedle", new List { "Bug", "Poison" }), + new Pokemon(14, "Kakuna", new List { "Bug", "Poison" }), + new Pokemon(15, "Beedrill", new List { "Bug", "Poison" }), + new Pokemon(16, "Pidgey", new List { "Normal", "Flying" }), + new Pokemon(17, "Pidgeotto", new List { "Normal", "Flying" }), + new Pokemon(18, "Pidgeot", new List { "Normal", "Flying" }), + new Pokemon(19, "Rattata", new List { "Normal" }), + new Pokemon(20, "Raticate", new List { "Normal" }), + new Pokemon(21, "Spearow", new List { "Normal", "Flying" }), + new Pokemon(22, "Fearow", new List { "Normal", "Flying" }), + new Pokemon(23, "Ekans", new List { "Poison" }), + new Pokemon(24, "Arbok", new List { "Poison" }), + new Pokemon(25, "Pikachu", new List { "Electric" }), + new Pokemon(26, "Raichu", new List { "Electric" }), + new Pokemon(27, "Sandshrew", new List { "Ground" }), + new Pokemon(28, "Sandslash", new List { "Ground" }), + new Pokemon(29, "Nidoran♀", new List { "Poison" }), + new Pokemon(30, "Nidorina", new List { "Poison" }), + new Pokemon(31, "Nidoqueen", new List { "Poison", "Ground" }), + new Pokemon(32, "Nidoran♂", new List { "Poison" }), + new Pokemon(33, "Nidorino", new List { "Poison" }), + new Pokemon(34, "Nidoking", new List { "Poison", "Ground" }), + new Pokemon(35, "Clefairy", new List { "Fairy" }), + new Pokemon(36, "Clefable", new List { "Fairy" }), + new Pokemon(37, "Vulpix", new List { "Fire" }), + new Pokemon(38, "Ninetales", new List { "Fire" }), + new Pokemon(39, "Jigglypuff", new List { "Normal", "Fairy" }), + new Pokemon(40, "Wigglytuff", new List { "Normal", "Fairy" }), + new Pokemon(41, "Zubat", new List { "Poison", "Flying" }), + new Pokemon(42, "Golbat", new List { "Poison", "Flying" }), + new Pokemon(43, "Oddish", new List { "Grass", "Poison" }), + new Pokemon(44, "Gloom", new List { "Grass", "Poison" }), + new Pokemon(45, "Vileplume", new List { "Grass", "Poison" }), + new Pokemon(46, "Paras", new List { "Bug", "Grass" }), + new Pokemon(47, "Parasect", new List { "Bug", "Grass" }), + new Pokemon(48, "Venonat", new List { "Bug", "Poison" }), + new Pokemon(49, "Venomoth", new List { "Bug", "Poison" }), + new Pokemon(50, "Diglett", new List { "Ground" }), + new Pokemon(51, "Dugtrio", new List { "Ground" }), + new Pokemon(52, "Meowth", new List { "Normal" }), + new Pokemon(53, "Persian", new List { "Normal" }), + new Pokemon(54, "Psyduck", new List { "Water" }), + new Pokemon(55, "Golduck", new List { "Water" }), + new Pokemon(56, "Mankey", new List { "Fighting" }), + new Pokemon(57, "Primeape", new List { "Fighting" }), + new Pokemon(58, "Growlithe", new List { "Fire" }), + new Pokemon(59, "Arcanine", new List { "Fire" }), + new Pokemon(60, "Poliwag", new List { "Water" }), + new Pokemon(61, "Poliwhirl", new List { "Water" }), + new Pokemon(62, "Poliwrath", new List { "Water", "Fighting" }), + new Pokemon(63, "Abra", new List { "Psychic" }), + new Pokemon(64, "Kadabra", new List { "Psychic" }), + new Pokemon(65, "Alakazam", new List { "Psychic" }), + new Pokemon(66, "Machop", new List { "Fighting" }), + new Pokemon(67, "Machoke", new List { "Fighting" }), + new Pokemon(68, "Machamp", new List { "Fighting" }), + new Pokemon(69, "Bellsprout", new List { "Grass", "Poison" }), + new Pokemon(70, "Weepinbell", new List { "Grass", "Poison" }), + new Pokemon(71, "Victreebel", new List { "Grass", "Poison" }), + new Pokemon(72, "Tentacool", new List { "Water", "Poison" }), + new Pokemon(73, "Tentacruel", new List { "Water", "Poison" }), + new Pokemon(74, "Geodude", new List { "Rock", "Ground" }), + new Pokemon(75, "Graveler", new List { "Rock", "Ground" }), + new Pokemon(76, "Golem", new List { "Rock", "Ground" }), + new Pokemon(77, "Ponyta", new List { "Fire" }), + new Pokemon(78, "Rapidash", new List { "Fire" }), + new Pokemon(79, "Slowpoke", new List { "Water", "Psychic" }), + new Pokemon(80, "Slowbro", new List { "Water", "Psychic" }), + new Pokemon(81, "Magnemite", new List { "Electric", "Steel" }), + new Pokemon(82, "Magneton", new List { "Electric", "Steel" }), + new Pokemon(83, "Farfetch'd", new List { "Normal", "Flying" }), + new Pokemon(84, "Doduo", new List { "Normal", "Flying" }), + new Pokemon(85, "Dodrio", new List { "Normal", "Flying" }), + new Pokemon(86, "Seel", new List { "Water" }), + new Pokemon(87, "Dewgong", new List { "Water", "Ice" }), + new Pokemon(88, "Grimer", new List { "Poison" }), + new Pokemon(89, "Muk", new List { "Poison" }), + new Pokemon(90, "Shellder", new List { "Water" }), + new Pokemon(91, "Cloyster", new List { "Water", "Ice" }), + new Pokemon(92, "Gastly", new List { "Ghost", "Poison" }), + new Pokemon(93, "Haunter", new List { "Ghost", "Poison" }), + new Pokemon(94, "Gengar", new List { "Ghost", "Poison" }), + new Pokemon(95, "Onix", new List { "Rock", "Ground" }), + new Pokemon(96, "Drowzee", new List { "Psychic" }), + new Pokemon(97, "Hypno", new List { "Psychic" }), + new Pokemon(98, "Krabby", new List { "Water" }), + new Pokemon(99, "Kingler", new List { "Water" }), + new Pokemon(100, "Voltorb", new List { "Electric" }), + new Pokemon(101, "Electrode", new List { "Electric" }), + new Pokemon(102, "Exeggcute", new List { "Grass", "Psychic" }), + new Pokemon(103, "Exeggutor", new List { "Grass", "Psychic" }), + new Pokemon(104, "Cubone", new List { "Ground" }), + new Pokemon(105, "Marowak", new List { "Ground" }), + new Pokemon(106, "Hitmonlee", new List { "Fighting" }), + new Pokemon(107, "Hitmonchan", new List { "Fighting" }), + new Pokemon(108, "Lickitung", new List { "Normal" }), + new Pokemon(109, "Koffing", new List { "Poison" }), + new Pokemon(110, "Weezing", new List { "Poison" }), + new Pokemon(111, "Rhyhorn", new List { "Ground", "Rock" }), + new Pokemon(112, "Rhydon", new List { "Ground", "Rock" }), + new Pokemon(113, "Chansey", new List { "Normal" }), + new Pokemon(114, "Tangela", new List { "Grass" }), + new Pokemon(115, "Kangaskhan", new List { "Normal" }), + new Pokemon(116, "Horsea", new List { "Water" }), + new Pokemon(117, "Seadra", new List { "Water" }), + new Pokemon(118, "Goldeen", new List { "Water" }), + new Pokemon(119, "Seaking", new List { "Water" }), + new Pokemon(120, "Staryu", new List { "Water" }), + new Pokemon(121, "Starmie", new List { "Water", "Psychic" }), + new Pokemon(122, "Mr. Mime", new List { "Psychic", "Fairy" }), + new Pokemon(123, "Scyther", new List { "Bug", "Flying" }), + new Pokemon(124, "Jynx", new List { "Ice", "Psychic" }), + new Pokemon(125, "Electabuzz", new List { "Electric" }), + new Pokemon(126, "Magmar", new List { "Fire" }), + new Pokemon(127, "Pinsir", new List { "Bug" }), + new Pokemon(128, "Tauros", new List { "Normal" }), + new Pokemon(129, "Magikarp", new List { "Water" }), + new Pokemon(130, "Gyarados", new List { "Water", "Flying" }), + new Pokemon(131, "Lapras", new List { "Water", "Ice" }), + new Pokemon(132, "Ditto", new List { "Normal" }), + new Pokemon(133, "Eevee", new List { "Normal" }), + new Pokemon(134, "Vaporeon", new List { "Water" }), + new Pokemon(135, "Jolteon", new List { "Electric" }), + new Pokemon(136, "Flareon", new List { "Fire" }), + new Pokemon(137, "Porygon", new List { "Normal" }), + new Pokemon(138, "Omanyte", new List { "Rock", "Water" }), + new Pokemon(139, "Omastar", new List { "Rock", "Water" }), + new Pokemon(140, "Kabuto", new List { "Rock", "Water" }), + new Pokemon(141, "Kabutops", new List { "Rock", "Water" }), + new Pokemon(142, "Aerodactyl", new List { "Rock", "Flying" }), + new Pokemon(143, "Snorlax", new List { "Normal" }), + new Pokemon(144, "Articuno", new List { "Ice", "Flying" }), + new Pokemon(145, "Zapdos", new List { "Electric", "Flying" }), + new Pokemon(146, "Moltres", new List { "Fire", "Flying" }), + new Pokemon(147, "Dratini", new List { "Dragon" }), + new Pokemon(148, "Dragonair", new List { "Dragon" }), + new Pokemon(149, "Dragonite", new List { "Dragon", "Flying" }), + new Pokemon(150, "Mewtwo", new List { "Psychic" }), + new Pokemon(151, "Mew", new List { "Psychic" }), + }; + + private readonly List _johto = new() + { + new Pokemon(152, "Chikorita", new List { "Grass" }), + new Pokemon(153, "Bayleef", new List { "Grass" }), + new Pokemon(154, "Meganium", new List { "Grass" }), + new Pokemon(155, "Cyndaquil", new List { "Fire" }), + new Pokemon(156, "Quilava", new List { "Fire" }), + new Pokemon(157, "Typhlosion", new List { "Fire" }), + new Pokemon(158, "Totodile", new List { "Water" }), + new Pokemon(159, "Croconaw", new List { "Water" }), + new Pokemon(160, "Feraligatr", new List { "Water" }), + new Pokemon(161, "Sentret", new List { "Normal" }), + new Pokemon(162, "Furret", new List { "Normal" }), + new Pokemon(163, "Hoothoot", new List { "Normal", "Flying" }), + new Pokemon(164, "Noctowl", new List { "Normal", "Flying" }), + new Pokemon(165, "Ledyba", new List { "Bug", "Flying" }), + new Pokemon(166, "Ledian", new List { "Bug", "Flying" }), + new Pokemon(167, "Spinarak", new List { "Bug", "Poison" }), + new Pokemon(168, "Ariados", new List { "Bug", "Poison" }), + new Pokemon(169, "Crobat", new List { "Poison", "Flying" }), + new Pokemon(170, "Chinchou", new List { "Water", "Electric" }), + new Pokemon(171, "Lanturn", new List { "Water", "Electric" }), + new Pokemon(172, "Pichu", new List { "Electric" }), + new Pokemon(173, "Cleffa", new List { "Fairy" }), + new Pokemon(174, "Igglybuff", new List { "Normal", "Fairy" }), + new Pokemon(175, "Togepi", new List { "Fairy" }), + new Pokemon(176, "Togetic", new List { "Fairy", "Flying" }), + new Pokemon(177, "Natu", new List { "Psychic", "Flying" }), + new Pokemon(178, "Xatu", new List { "Psychic", "Flying" }), + new Pokemon(179, "Mareep", new List { "Electric" }), + new Pokemon(180, "Flaaffy", new List { "Electric" }), + new Pokemon(181, "Ampharos", new List { "Electric" }), + new Pokemon(182, "Bellossom", new List { "Grass" }), + new Pokemon(183, "Marill", new List { "Water", "Fairy" }), + new Pokemon(184, "Azumarill", new List { "Water", "Fairy" }), + new Pokemon(185, "Sudowoodo", new List { "Rock" }), + new Pokemon(186, "Politoed", new List { "Water" }), + new Pokemon(187, "Hoppip", new List { "Grass", "Flying" }), + new Pokemon(188, "Skiploom", new List { "Grass", "Flying" }), + new Pokemon(189, "Jumpluff", new List { "Grass", "Flying" }), + new Pokemon(190, "Aipom", new List { "Normal" }), + new Pokemon(191, "Sunkern", new List { "Grass" }), + new Pokemon(192, "Sunflora", new List { "Grass" }), + new Pokemon(193, "Yanma", new List { "Bug", "Flying" }), + new Pokemon(194, "Wooper", new List { "Water", "Ground" }), + new Pokemon(195, "Quagsire", new List { "Water", "Ground" }), + new Pokemon(196, "Espeon", new List { "Psychic" }), + new Pokemon(197, "Umbreon", new List { "Dark" }), + new Pokemon(198, "Murkrow", new List { "Dark", "Flying" }), + new Pokemon(199, "Slowking", new List { "Water", "Psychic" }), + new Pokemon(200, "Misdreavus", new List { "Ghost" }), + new Pokemon(201, "Unown", new List { "Psychic" }), + new Pokemon(202, "Wobbuffet", new List { "Psychic" }), + new Pokemon(203, "Girafarig", new List { "Normal", "Psychic" }), + new Pokemon(204, "Pineco", new List { "Bug" }), + new Pokemon(205, "Forretress", new List { "Bug", "Steel" }), + new Pokemon(206, "Dunsparce", new List { "Normal" }), + new Pokemon(207, "Gligar", new List { "Ground", "Flying" }), + new Pokemon(208, "Steelix", new List { "Steel", "Ground" }), + new Pokemon(209, "Snubbull", new List { "Fairy" }), + new Pokemon(210, "Granbull", new List { "Fairy" }), + new Pokemon(211, "Qwilfish", new List { "Water", "Poison" }), + new Pokemon(212, "Scizor", new List { "Bug", "Steel" }), + new Pokemon(213, "Shuckle", new List { "Bug", "Rock" }), + new Pokemon(214, "Heracross", new List { "Bug", "Fighting" }), + new Pokemon(215, "Sneasel", new List { "Dark", "Ice" }), + new Pokemon(216, "Teddiursa", new List { "Normal" }), + new Pokemon(217, "Ursaring", new List { "Normal" }), + new Pokemon(218, "Slugma", new List { "Fire" }), + new Pokemon(219, "Magcargo", new List { "Fire", "Rock" }), + new Pokemon(220, "Swinub", new List { "Ice", "Ground" }), + new Pokemon(221, "Piloswine", new List { "Ice", "Ground" }), + new Pokemon(222, "Corsola", new List { "Water", "Rock" }), + new Pokemon(223, "Remoraid", new List { "Water" }), + new Pokemon(224, "Octillery", new List { "Water" }), + new Pokemon(225, "Delibird", new List { "Ice", "Flying" }), + new Pokemon(226, "Mantine", new List { "Water", "Flying" }), + new Pokemon(227, "Skarmory", new List { "Steel", "Flying" }), + new Pokemon(228, "Houndour", new List { "Dark", "Fire" }), + new Pokemon(229, "Houndoom", new List { "Dark", "Fire" }), + new Pokemon(230, "Kingdra", new List { "Water", "Dragon" }), + new Pokemon(231, "Phanpy", new List { "Ground" }), + new Pokemon(232, "Donphan", new List { "Ground" }), + new Pokemon(233, "Porygon2", new List { "Normal" }), + new Pokemon(234, "Stantler", new List { "Normal" }), + new Pokemon(235, "Smeargle", new List { "Normal" }), + new Pokemon(236, "Tyrogue", new List { "Fighting" }), + new Pokemon(237, "Hitmontop", new List { "Fighting" }), + new Pokemon(238, "Smoochum", new List { "Ice", "Psychic" }), + new Pokemon(239, "Elekid", new List { "Electric" }), + new Pokemon(240, "Magby", new List { "Fire" }), + new Pokemon(241, "Miltank", new List { "Normal" }), + new Pokemon(242, "Blissey", new List { "Normal" }), + new Pokemon(243, "Raikou", new List { "Electric" }), + new Pokemon(244, "Entei", new List { "Fire" }), + new Pokemon(245, "Suicune", new List { "Water" }), + new Pokemon(246, "Larvitar", new List { "Rock", "Ground" }), + new Pokemon(247, "Pupitar", new List { "Rock", "Ground" }), + new Pokemon(248, "Tyranitar", new List { "Rock", "Dark" }), + new Pokemon(249, "Lugia", new List { "Psychic", "Flying" }), + new Pokemon(250, "Ho-Oh", new List { "Fire", "Flying" }), + new Pokemon(251, "Celebi", new List { "Psychic", "Grass" }), + }; + + private readonly List _hoenn = new() + { + new Pokemon(252, "Treecko", new List { "Grass" }), + new Pokemon(253, "Grovyle", new List { "Grass" }), + new Pokemon(254, "Sceptile", new List { "Grass" }), + new Pokemon(255, "Torchic", new List { "Fire" }), + new Pokemon(256, "Combusken", new List { "Fire", "Fighting" }), + new Pokemon(257, "Blaziken", new List { "Fire", "Fighting" }), + new Pokemon(258, "Mudkip", new List { "Water" }), + new Pokemon(259, "Marshtomp", new List { "Water", "Ground" }), + new Pokemon(260, "Swampert", new List { "Water", "Ground" }), + new Pokemon(261, "Poochyena", new List { "Dark" }), + new Pokemon(262, "Mightyena", new List { "Dark" }), + new Pokemon(263, "Zigzagoon", new List { "Normal" }), + new Pokemon(264, "Linoone", new List { "Normal" }), + new Pokemon(265, "Wurmple", new List { "Bug" }), + new Pokemon(266, "Silcoon", new List { "Bug" }), + new Pokemon(267, "Beautifly", new List { "Bug", "Flying" }), + new Pokemon(268, "Cascoon", new List { "Bug" }), + new Pokemon(269, "Dustox", new List { "Bug", "Poison" }), + new Pokemon(270, "Lotad", new List { "Water", "Grass" }), + new Pokemon(271, "Lombre", new List { "Water", "Grass" }), + new Pokemon(272, "Ludicolo", new List { "Water", "Grass" }), + new Pokemon(273, "Seedot", new List { "Grass" }), + new Pokemon(274, "Nuzleaf", new List { "Grass", "Dark" }), + new Pokemon(275, "Shiftry", new List { "Grass", "Dark" }), + new Pokemon(276, "Taillow", new List { "Normal", "Flying" }), + new Pokemon(277, "Swellow", new List { "Normal", "Flying" }), + new Pokemon(278, "Wingull", new List { "Water", "Flying" }), + new Pokemon(279, "Pelipper", new List { "Water", "Flying" }), + new Pokemon(280, "Ralts", new List { "Psychic", "Fairy" }), + new Pokemon(281, "Kirlia", new List { "Psychic", "Fairy" }), + new Pokemon(282, "Gardevoir", new List { "Psychic", "Fairy" }), + new Pokemon(283, "Surskit", new List { "Bug", "Water" }), + new Pokemon(284, "Masquerain", new List { "Bug", "Flying" }), + new Pokemon(285, "Shroomish", new List { "Grass" }), + new Pokemon(286, "Breloom", new List { "Grass", "Fighting" }), + new Pokemon(287, "Slakoth", new List { "Normal" }), + new Pokemon(288, "Vigoroth", new List { "Normal" }), + new Pokemon(289, "Slaking", new List { "Normal" }), + new Pokemon(290, "Nincada", new List { "Bug", "Ground" }), + new Pokemon(291, "Ninjask", new List { "Bug", "Flying" }), + new Pokemon(292, "Shedinja", new List { "Bug", "Ghost" }), + new Pokemon(293, "Whismur", new List { "Normal" }), + new Pokemon(294, "Loudred", new List { "Normal" }), + new Pokemon(295, "Exploud", new List { "Normal" }), + new Pokemon(296, "Makuhita", new List { "Fighting" }), + new Pokemon(297, "Hariyama", new List { "Fighting" }), + new Pokemon(298, "Azurill", new List { "Normal", "Fairy" }), + new Pokemon(299, "Nosepass", new List { "Rock" }), + new Pokemon(300, "Skitty", new List { "Normal" }), + new Pokemon(301, "Delcatty", new List { "Normal" }), + new Pokemon(302, "Sableye", new List { "Dark", "Ghost" }), + new Pokemon(303, "Mawile", new List { "Steel", "Fairy" }), + new Pokemon(304, "Aron", new List { "Steel", "Rock" }), + new Pokemon(305, "Lairon", new List { "Steel", "Rock" }), + new Pokemon(306, "Aggron", new List { "Steel", "Rock" }), + new Pokemon(307, "Meditite", new List { "Fighting", "Psychic" }), + new Pokemon(308, "Medicham", new List { "Fighting", "Psychic" }), + new Pokemon(309, "Electrike", new List { "Electric" }), + new Pokemon(310, "Manectric", new List { "Electric" }), + new Pokemon(311, "Plusle", new List { "Electric" }), + new Pokemon(312, "Minun", new List { "Electric" }), + new Pokemon(313, "Volbeat", new List { "Bug" }), + new Pokemon(314, "Illumise", new List { "Bug" }), + new Pokemon(315, "Roselia", new List { "Grass", "Poison" }), + new Pokemon(316, "Gulpin", new List { "Poison" }), + new Pokemon(317, "Swalot", new List { "Poison" }), + new Pokemon(318, "Carvanha", new List { "Water", "Dark" }), + new Pokemon(319, "Sharpedo", new List { "Water", "Dark" }), + new Pokemon(320, "Wailmer", new List { "Water" }), + new Pokemon(321, "Wailord", new List { "Water" }), + new Pokemon(322, "Numel", new List { "Fire", "Ground" }), + new Pokemon(323, "Camerupt", new List { "Fire", "Ground" }), + new Pokemon(324, "Torkoal", new List { "Fire" }), + new Pokemon(325, "Spoink", new List { "Psychic" }), + new Pokemon(326, "Grumpig", new List { "Psychic" }), + new Pokemon(327, "Spinda", new List { "Normal" }), + new Pokemon(328, "Trapinch", new List { "Ground" }), + new Pokemon(329, "Vibrava", new List { "Ground", "Dragon" }), + new Pokemon(330, "Flygon", new List { "Ground", "Dragon" }), + new Pokemon(331, "Cacnea", new List { "Grass" }), + new Pokemon(332, "Cacturne", new List { "Grass", "Dark" }), + new Pokemon(333, "Swablu", new List { "Normal", "Flying" }), + new Pokemon(334, "Altaria", new List { "Dragon", "Flying" }), + new Pokemon(335, "Zangoose", new List { "Normal" }), + new Pokemon(336, "Seviper", new List { "Poison" }), + new Pokemon(337, "Lunatone", new List { "Rock", "Psychic" }), + new Pokemon(338, "Solrock", new List { "Rock", "Psychic" }), + new Pokemon(339, "Barboach", new List { "Water", "Ground" }), + new Pokemon(340, "Whiscash", new List { "Water", "Ground" }), + new Pokemon(341, "Corphish", new List { "Water" }), + new Pokemon(342, "Crawdaunt", new List { "Water", "Dark" }), + new Pokemon(343, "Baltoy", new List { "Ground", "Psychic" }), + new Pokemon(344, "Claydol", new List { "Ground", "Psychic" }), + new Pokemon(345, "Lileep", new List { "Rock", "Grass" }), + new Pokemon(346, "Cradily", new List { "Rock", "Grass" }), + new Pokemon(347, "Anorith", new List { "Rock", "Bug" }), + new Pokemon(348, "Armaldo", new List { "Rock", "Bug" }), + new Pokemon(349, "Feebas", new List { "Water" }), + new Pokemon(350, "Milotic", new List { "Water" }), + new Pokemon(351, "Castform", new List { "Normal" }), + new Pokemon(352, "Kecleon", new List { "Normal" }), + new Pokemon(353, "Shuppet", new List { "Ghost" }), + new Pokemon(354, "Banette", new List { "Ghost" }), + new Pokemon(355, "Duskull", new List { "Ghost" }), + new Pokemon(356, "Dusclops", new List { "Ghost" }), + new Pokemon(357, "Tropius", new List { "Grass", "Flying" }), + new Pokemon(358, "Chimecho", new List { "Psychic" }), + new Pokemon(359, "Absol", new List { "Dark" }), + new Pokemon(360, "Wynaut", new List { "Psychic" }), + new Pokemon(361, "Snorunt", new List { "Ice" }), + new Pokemon(362, "Glalie", new List { "Ice" }), + new Pokemon(363, "Spheal", new List { "Ice", "Water" }), + new Pokemon(364, "Sealeo", new List { "Ice", "Water" }), + new Pokemon(365, "Walrein", new List { "Ice", "Water" }), + new Pokemon(366, "Clamperl", new List { "Water" }), + new Pokemon(367, "Huntail", new List { "Water" }), + new Pokemon(368, "Gorebyss", new List { "Water" }), + new Pokemon(369, "Relicanth", new List { "Water", "Rock" }), + new Pokemon(370, "Luvdisc", new List { "Water" }), + new Pokemon(371, "Bagon", new List { "Dragon" }), + new Pokemon(372, "Shelgon", new List { "Dragon" }), + new Pokemon(373, "Salamence", new List { "Dragon", "Flying" }), + new Pokemon(374, "Beldum", new List { "Steel", "Psychic" }), + new Pokemon(375, "Metang", new List { "Steel", "Psychic" }), + new Pokemon(376, "Metagross", new List { "Steel", "Psychic" }), + new Pokemon(377, "Regirock", new List { "Rock" }), + new Pokemon(378, "Regice", new List { "Ice" }), + new Pokemon(379, "Registeel", new List { "Steel" }), + new Pokemon(380, "Latias", new List { "Dragon", "Psychic" }), + new Pokemon(381, "Latios", new List { "Dragon", "Psychic" }), + new Pokemon(382, "Kyogre", new List { "Water" }), + new Pokemon(383, "Groudon", new List { "Ground" }), + new Pokemon(384, "Rayquaza", new List { "Dragon", "Flying" }), + new Pokemon(385, "Jirachi", new List { "Steel", "Psychic" }), + new Pokemon(386, "Deoxys", new List { "Psychic" }), + }; + + public PokedexExtensionPage() + { + Icon = new(string.Empty); + Name = "Pokedex"; + } + + public override IListItem[] GetItems() + { + return _kanto.AsEnumerable().Concat(_johto.AsEnumerable()).Concat(_hoenn.AsEnumerable()).Select(p => GetPokemonListItem(p)).ToArray(); + /*return [ + new ListSection() + { + Title = "Kanto", + Items = _kanto + .AsEnumerable() + .Select(p => GetPokemonListItem(p)).ToArray(), + }, + new ListSection() + { + Title = "Johto", + Items = _johto + .AsEnumerable() + .Select(p => GetPokemonListItem(p)).ToArray(), + }, + new ListSection() + { + Title = "Hoenn", + Items = _hoenn + .AsEnumerable() + .Select(p => GetPokemonListItem(p)).ToArray(), + }, + ];*/ + } + + private static ListItem GetPokemonListItem(Pokemon pokemon) + { + return new ListItem(new PokemonPage(pokemon)) + { + Subtitle = $"#{pokemon.Number}", + Tags = pokemon.Types.Select(t => new Tag() { Text = t, Color = GetColorForType(t) }).ToArray(), + }; + } + + // Dictionary mapping Pokémon types to their corresponding colors + private static readonly Dictionary 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 + }; + + // 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; + } + + // Default color (e.g., white) if the type is not found + return Color.FromArgb(255, 255, 255, 255); + } +} diff --git a/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtension.csproj b/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtension.csproj new file mode 100644 index 0000000000..f983ec279c --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtension.csproj @@ -0,0 +1,56 @@ + + + + WinExe + PokedexExtension + app.manifest + win-$(Platform).pubxml + false + true + $(SolutionDir)$(Platform)\$(Configuration)\WinUI3Apps\CmdPalExtensions\$(RootNamespace) + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + diff --git a/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtensionCommandsProvider.cs b/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtensionCommandsProvider.cs new file mode 100644 index 0000000000..5ae3d3ac8f --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/PokedexExtensionCommandsProvider.cs @@ -0,0 +1,30 @@ +// 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. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.CmdPal.Extensions; +using Microsoft.CmdPal.Extensions.Helpers; + +namespace PokedexExtension; + +public partial class PokedexExtensionActionsProvider : CommandProvider +{ + public PokedexExtensionActionsProvider() + { + DisplayName = "Pocket Monsters for the Command Palette Commands"; + } + + private readonly IListItem[] _commands = [ + new ListItem(new PokedexExtensionPage()), + ]; + + public override IListItem[] TopLevelCommands() + { + return _commands; + } +} diff --git a/src/modules/cmdpal/Exts/PokedexExtension/Program.cs b/src/modules/cmdpal/Exts/PokedexExtension/Program.cs new file mode 100644 index 0000000000..af2763b756 --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/Program.cs @@ -0,0 +1,36 @@ +// 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. + +using System; +using System.Threading; +using Microsoft.CmdPal.Extensions; + +namespace PokedexExtension; + +public class Program +{ + [MTAThread] + public static void Main(string[] args) + { + if (args.Length > 0 && args[0] == "-RegisterProcessAsComServer") + { + using ExtensionServer server = new(); + var extensionDisposedEvent = new ManualResetEvent(false); + var extensionInstance = new SampleExtension(extensionDisposedEvent); + + // We are instantiating an extension instance once above, and returning it every time the callback in RegisterExtension below is called. + // This makes sure that only one instance of SampleExtension is alive, which is returned every time the host asks for the IExtension object. + // If you want to instantiate a new instance each time the host asks, create the new instance inside the delegate. + server.RegisterExtension(() => extensionInstance); + + // This will make the main thread wait until the event is signalled by the extension class. + // Since we have single instance of the extension object, we exit as sooon as it is disposed. + extensionDisposedEvent.WaitOne(); + } + else + { + Console.WriteLine("Not being launched as a Extension... exiting."); + } + } +} diff --git a/src/modules/cmdpal/Exts/PokedexExtension/SampleExtension.cs b/src/modules/cmdpal/Exts/PokedexExtension/SampleExtension.cs new file mode 100644 index 0000000000..e6af5dcb41 --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/SampleExtension.cs @@ -0,0 +1,41 @@ +// 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. + +using System; +using System.Runtime.InteropServices; +using System.Threading; +using Microsoft.CmdPal.Extensions; + +namespace PokedexExtension; + +[ComVisible(true)] +[Guid("89bb01cf-674d-425f-80aa-49cded859ecf")] +[ComDefaultInterface(typeof(IExtension))] +public sealed partial class SampleExtension : IExtension, IDisposable +{ + private readonly ManualResetEvent _extensionDisposedEvent; + + private readonly PokedexExtensionActionsProvider _provider = new(); + + public SampleExtension(ManualResetEvent extensionDisposedEvent) + { + this._extensionDisposedEvent = extensionDisposedEvent; + } + + public object GetProvider(ProviderType providerType) + { + switch (providerType) + { + case ProviderType.Commands: + return _provider; + default: + return null; + } + } + + public void Dispose() + { + this._extensionDisposedEvent.Set(); + } +} diff --git a/src/modules/cmdpal/Exts/PokedexExtension/app.manifest b/src/modules/cmdpal/Exts/PokedexExtension/app.manifest new file mode 100644 index 0000000000..bcafb9bc5b --- /dev/null +++ b/src/modules/cmdpal/Exts/PokedexExtension/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + diff --git a/src/modules/cmdpal/WindowsCommandPalette/Views/ListPage.xaml b/src/modules/cmdpal/WindowsCommandPalette/Views/ListPage.xaml index 172ad7deb4..ff2613e187 100644 --- a/src/modules/cmdpal/WindowsCommandPalette/Views/ListPage.xaml +++ b/src/modules/cmdpal/WindowsCommandPalette/Views/ListPage.xaml @@ -92,16 +92,11 @@ - - - +