oh god oh god what have i done

This commit is contained in:
Mike Griese
2025-08-07 10:51:14 -05:00
parent c198ceaa1e
commit 95cfdbb93d
3 changed files with 124 additions and 3 deletions

View File

@@ -2,8 +2,10 @@
// 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.Diagnostics.CodeAnalysis;
using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.System;
using Windows.Win32;
@@ -170,10 +172,22 @@ internal sealed partial class SampleListPage : ListPage
{
Title = "Get the name of the Foreground window",
},
new ListItem(new JustHasProps())
{
Title = "Not actually invokable",
},
new ListItem(new CommandWithProperties())
{
Title = "I have properties",
},
new ListItem(new OtherCommandWithProperties())
{
Title = "I also have properties",
},
new ListItem(new AnotherCommandWithProperties())
{
Title = "InvokableCommand, IHaveProperties",
},
];
}
@@ -188,4 +202,72 @@ internal sealed partial class SampleListPage : ListPage
{ "hmm?", null },
};
}
#nullable enable
internal sealed partial class OtherCommandWithProperties : ICommand2, IInvokableCommand
{
public string Name => "Revetahw";
public IIconInfo Icon => new IconInfo("\uF146");
public string Id => string.Empty;
public event TypedEventHandler<object, IPropChangedEventArgs>? PropChanged;
public ICommandResult Invoke(object sender)
{
PropChanged?.Invoke(this, new PropChangedEventArgs(nameof(Name)));
return CommandResult.ShowToast("whoop");
}
public IPropertySet OtherProperties => new PropertySet()
{
{ "Foo", "bar" },
{ "Secret", 42 },
{ "hmm?", null },
};
}
internal sealed partial class JustHasProps : ICommand2
{
public string Name => "JustHasProps";
public IIconInfo Icon => new IconInfo("\uF147");
public string Id => string.Empty;
public event TypedEventHandler<object, IPropChangedEventArgs>? PropChanged;
public ICommandResult Invoke(object sender)
{
PropChanged?.Invoke(this, new PropChangedEventArgs(nameof(Name)));
return CommandResult.ShowToast("whoop");
}
public IPropertySet OtherProperties => new PropertySet()
{
{ "Foo", "bar" },
{ "Secret", 42 },
{ "hmm?", null },
};
}
internal sealed partial class AnotherCommandWithProperties : InvokableCommand, IHaveProperties
{
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(IHaveProperties))]
static AnotherCommandWithProperties()
{
}
public override string Name => "Another";
public override IconInfo Icon => new IconInfo("\uF147");
public IPropertySet Properties => new PropertySet()
{
{ "it", "doesn't" },
{ "matter", 42 },
{ "nothing seems to", "work" },
};
}
}