mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Add an API to allow _any_ command to be pinned
This commit is contained in:
@@ -2061,6 +2061,7 @@ bands via the new `DockBand` property on `ICommandProvider3`.
|
||||
interface ICommandProvider3 requires ICommandProvider2
|
||||
{
|
||||
ICommandItem[] GetDockBands();
|
||||
ICommandItem GetCommandItemById(String id);
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
@@ -188,4 +188,14 @@ public partial class AllAppsCommandProvider : CommandProvider
|
||||
{
|
||||
RaiseItemsChanged(0);
|
||||
}
|
||||
|
||||
public override ICommandItem? GetCommandItemById(string id)
|
||||
{
|
||||
if (id == _listItem.Command.Id)
|
||||
{
|
||||
return _listItem;
|
||||
}
|
||||
|
||||
return _page.GetAppCommandItemById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,4 +205,19 @@ public sealed partial class AllAppsPage : ListPage
|
||||
|
||||
RaiseItemsChanged(0);
|
||||
}
|
||||
|
||||
internal ICommandItem? GetAppCommandItemById(string id)
|
||||
{
|
||||
var items = this.GetItems();
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.Command.Id == id)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,11 @@ public abstract partial class CommandProvider :
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual ICommandItem? GetCommandItemById(string id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used to manually populate the WinRT type cache in CmdPal with
|
||||
/// any interfaces that might not follow a straight linear path of requires.
|
||||
|
||||
Reference in New Issue
Block a user