diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Action.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Action.cs new file mode 100644 index 0000000000..db8dbc8883 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Action.cs @@ -0,0 +1,9 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class Action : BaseObservable, ICommand +{ + protected string _Name = ""; + protected IconDataType _Icon = new(""); + public string Name { get => _Name; set { _Name = value; OnPropertyChanged(nameof(Name)); } } + public IconDataType Icon { get => _Icon; set { _Icon = value; OnPropertyChanged(nameof(Icon)); } } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ActionResult.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ActionResult.cs new file mode 100644 index 0000000000..45b40791ff --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ActionResult.cs @@ -0,0 +1,20 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class ActionResult : ICommandResult +{ + private ICommandResultArgs _Args = null; + private CommandResultKind _Kind = CommandResultKind.Dismiss; + public ICommandResultArgs Args => _Args; + public CommandResultKind Kind => _Kind; + public static ActionResult Dismiss() { + return new ActionResult() { _Kind = CommandResultKind.Dismiss }; + } + public static ActionResult GoHome() + { + return new ActionResult() { _Kind = CommandResultKind.GoHome }; + } + public static ActionResult KeepOpen() + { + return new ActionResult() { _Kind = CommandResultKind.KeepOpen }; + } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/BaseObservable.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/BaseObservable.cs new file mode 100644 index 0000000000..ec775eb5f2 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/BaseObservable.cs @@ -0,0 +1,16 @@ +using Windows.Foundation; + +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +// TODO! We probably want to have OnPropertyChanged raise the event +// asynchonously, so as to not block the extension app while it's being +// processed in the host app. +public class BaseObservable : INotifyPropChanged +{ + public event TypedEventHandler? PropChanged; + protected void OnPropertyChanged(string propertyName) + { + if (PropChanged != null) + PropChanged.Invoke(this, new Microsoft.Windows.CommandPalette.Extensions.PropChangedEventArgs(propertyName)); + } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/CommandContextItem.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/CommandContextItem.cs new file mode 100644 index 0000000000..3394231e24 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/CommandContextItem.cs @@ -0,0 +1,12 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class CommandContextItem : ICommandContextItem +{ + public bool IsCritical { get; set; } + public ICommand Command { get; set; } + public string Tooltip { get; set; } = ""; + public CommandContextItem(ICommand command) + { + Command = command; + } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DefaultClasses.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DefaultClasses.cs deleted file mode 100644 index eb9e8b913f..0000000000 --- a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DefaultClasses.cs +++ /dev/null @@ -1,227 +0,0 @@ -using Windows.Foundation; -using Windows.UI; - -namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; - -// TODO! We probably want to have OnPropertyChanged raise the event -// asynchonously, so as to not block the extension app while it's being -// processed in the host app. -public class BaseObservable : INotifyPropChanged -{ - public event TypedEventHandler? PropChanged; - protected void OnPropertyChanged(string propertyName) - { - if (PropChanged != null) - PropChanged.Invoke(this, new Microsoft.Windows.CommandPalette.Extensions.PropChangedEventArgs(propertyName)); - } -} - -public class Action : BaseObservable, ICommand -{ - protected string _Name = ""; - protected IconDataType _Icon = new(""); - public string Name { get => _Name; set { _Name = value; OnPropertyChanged(nameof(Name)); } } - public IconDataType Icon { get => _Icon; set { _Icon = value; OnPropertyChanged(nameof(Icon)); } } -} - -public class InvokableCommand : Action, IInvokableCommand -{ - public virtual ICommandResult Invoke() => throw new NotImplementedException(); -} - -public class NoOpAction : InvokableCommand -{ - public override ICommandResult Invoke() => ActionResult.KeepOpen(); -} - -public class ListItem : BaseObservable, IListItem -{ - protected string _Title = ""; - protected string _Subtitle = ""; - protected ITag[] _Tags = []; - protected IDetails? _Details; - protected ICommand _Command; - protected IContextItem[] _MoreCommands = []; - protected IFallbackHandler? _FallbackHandler; - - public string Title { get => !string.IsNullOrEmpty(this._Title) ? this._Title : _Command.Name; set { _Title = value; OnPropertyChanged(nameof(Title)); } } - public string Subtitle { get => _Subtitle; set { _Subtitle = value; OnPropertyChanged(nameof(Subtitle)); } } - public ITag[] Tags { get => _Tags; set { _Tags = value; OnPropertyChanged(nameof(Tags)); } } - public IDetails? Details { get => _Details; set { _Details = value; OnPropertyChanged(nameof(Details)); } } - public ICommand Command { get => _Command; set { _Command = value; OnPropertyChanged(nameof(Command)); } } - public IContextItem[] MoreCommands { get => _MoreCommands; set { _MoreCommands = value; OnPropertyChanged(nameof(MoreCommands)); } } - - public IFallbackHandler? FallbackHandler { get => _FallbackHandler ?? _Command as IFallbackHandler; init { _FallbackHandler = value; } } - - public ListItem(ICommand command) - { - _Command = command; - _Title = command.Name; - } -} - -public class Tag : BaseObservable, ITag -{ - protected Color _Color = new(); - protected IconDataType _Icon = null; - protected string _Text = ""; - protected string _ToolTip = ""; - protected ICommand _Action; - - public Color Color { get => _Color; set { _Color = value; OnPropertyChanged(nameof(Color)); } } - public IconDataType Icon { get => _Icon; set { _Icon = value; OnPropertyChanged(nameof(Icon)); } } - public string Text { get => _Text; set { _Text = value; OnPropertyChanged(nameof(Text)); } } - public string ToolTip { get => _ToolTip; set { _ToolTip = value; OnPropertyChanged(nameof(ToolTip)); } } - public ICommand Command { get => _Action; set { _Action = value; OnPropertyChanged(nameof(Action)); } } - -} - -public class ListSection : ISection -{ - public string Title { get; set; } = ""; - public virtual IListItem[] Items { get; set; } = []; -} - -public class CommandContextItem : ICommandContextItem -{ - public bool IsCritical { get; set; } - public ICommand Command { get; set; } - public string Tooltip { get; set; } = ""; - public CommandContextItem(ICommand command) - { - Command = command; - } -} - -public class ActionResult : ICommandResult -{ - private ICommandResultArgs _Args = null; - private CommandResultKind _Kind = CommandResultKind.Dismiss; - public ICommandResultArgs Args => _Args; - public CommandResultKind Kind => _Kind; - public static ActionResult Dismiss() { - return new ActionResult() { _Kind = CommandResultKind.Dismiss }; - } - public static ActionResult GoHome() - { - return new ActionResult() { _Kind = CommandResultKind.GoHome }; - } - public static ActionResult KeepOpen() - { - return new ActionResult() { _Kind = CommandResultKind.KeepOpen }; - } -} - -public class GoToPageArgs : IGoToPageArgs -{ - public required string PageId { get; set; } -} - -public class SeparatorContextItem : ISeparatorContextItem -{ -} - -public class SeparatorFilterItem : ISeparatorFilterItem -{ -} - -public class Filter : IFilter -{ - public IconDataType Icon => throw new NotImplementedException(); - public string Id => throw new NotImplementedException(); - public string Name => throw new NotImplementedException(); -} - -public class ListPage : Action, IListPage -{ - private string _PlaceholderText = ""; - private string _SearchText = ""; - private bool _ShowDetails = false; - private bool _Loading = false; - private IFilters _Filters = null; - private IGridProperties _GridProperties = null; - - public string PlaceholderText { get => _PlaceholderText; set { _PlaceholderText = value; OnPropertyChanged(nameof(PlaceholderText)); } } - public string SearchText { get => _SearchText; set { _SearchText = value; OnPropertyChanged(nameof(SearchText)); } } - public bool ShowDetails { get => _ShowDetails; set { _ShowDetails = value; OnPropertyChanged(nameof(ShowDetails)); } } - public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } - public IFilters Filters { get => _Filters; set { _Filters = value; OnPropertyChanged(nameof(Filters)); } } - public IGridProperties GridProperties { get => _GridProperties; set { _GridProperties = value; OnPropertyChanged(nameof(GridProperties)); } } - - public virtual ISection[] GetItems() => throw new NotImplementedException(); -} - -public class DynamicListPage : ListPage, IDynamicListPage -{ - public virtual ISection[] GetItems(string query) => throw new NotImplementedException(); -} - -public class MarkdownPage : Action, IMarkdownPage -{ - private bool _Loading = false; - protected ITag[] _Tags = []; - protected IDetails? _Details = null; - protected string _Title = ""; - - public string Title { get => !string.IsNullOrEmpty(this._Title) ? this._Title : this.Name; set { _Title = value; OnPropertyChanged(nameof(Title)); } } - public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } - public ITag[] Tags { get => _Tags; set { _Tags = value; OnPropertyChanged(nameof(Tags)); } } - // public IDetails Details { get => _Details; set { _Details = value; OnPropertyChanged(nameof(Details)); } } - public IContextItem[] Commands { get; set; } = []; - - public virtual string[] Bodies() => throw new NotImplementedException(); - public virtual IDetails Details() => null; -} - -public class Form: IForm -{ - public string Data { get; set; } - public string State { get; set; } - public string Template { get; set; } - - public virtual string DataJson() => Data; - public virtual string StateJson() => State; - public virtual string TemplateJson() => Template; - public virtual ICommandResult SubmitForm(string payload) => throw new NotImplementedException(); -} -public class FormPage : Action, IFormPage -{ - private bool _Loading = false; - - public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } - - public virtual IForm[] Forms() => throw new NotImplementedException(); -} - -public class DetailsTags : IDetailsTags -{ - public ITag[] Tags { get; set; } -} - -public class DetailsLink : IDetailsLink -{ - public Uri Link { get; set; } - public string Text { get; set; } -} - -public class DetailsSeparator : IDetailsSeparator -{ -} - -public class Details : BaseObservable, IDetails -{ - protected IconDataType _HeroImage; - protected string _Title; - protected string _Body; - protected IDetailsElement[] _Metadata = []; - - public IconDataType HeroImage { get => _HeroImage; set { _HeroImage = value; OnPropertyChanged(nameof(HeroImage)); } } - public string Title { get => _Title; set { _Title = value; OnPropertyChanged(nameof(Title)); } } - public string Body { get => _Body; set { _Body = value; OnPropertyChanged(nameof(Body)); } } - public IDetailsElement[] Metadata { get => _Metadata; set { _Metadata = value; OnPropertyChanged(nameof(Metadata)); } } -} -public class DetailsElement : IDetailsElement -{ - public string Key { get; set; } - public IDetailsData? Data { get; set; } -} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Details.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Details.cs new file mode 100644 index 0000000000..a2d03081d7 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Details.cs @@ -0,0 +1,14 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class Details : BaseObservable, IDetails +{ + protected IconDataType _HeroImage; + protected string _Title; + protected string _Body; + protected IDetailsElement[] _Metadata = []; + + public IconDataType HeroImage { get => _HeroImage; set { _HeroImage = value; OnPropertyChanged(nameof(HeroImage)); } } + public string Title { get => _Title; set { _Title = value; OnPropertyChanged(nameof(Title)); } } + public string Body { get => _Body; set { _Body = value; OnPropertyChanged(nameof(Body)); } } + public IDetailsElement[] Metadata { get => _Metadata; set { _Metadata = value; OnPropertyChanged(nameof(Metadata)); } } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsElement.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsElement.cs new file mode 100644 index 0000000000..a8bd34f01d --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsElement.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class DetailsElement : IDetailsElement +{ + public string Key { get; set; } + public IDetailsData? Data { get; set; } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsLink.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsLink.cs new file mode 100644 index 0000000000..c57c57a73f --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsLink.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class DetailsLink : IDetailsLink +{ + public Uri Link { get; set; } + public string Text { get; set; } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsSeparator.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsSeparator.cs new file mode 100644 index 0000000000..5ce5d50013 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsSeparator.cs @@ -0,0 +1,5 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class DetailsSeparator : IDetailsSeparator +{ +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsTags.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsTags.cs new file mode 100644 index 0000000000..a7f3e38b12 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DetailsTags.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class DetailsTags : IDetailsTags +{ + public ITag[] Tags { get; set; } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DynamicListPage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DynamicListPage.cs new file mode 100644 index 0000000000..260892834e --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/DynamicListPage.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class DynamicListPage : ListPage, IDynamicListPage +{ + public virtual ISection[] GetItems(string query) => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Filter.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Filter.cs new file mode 100644 index 0000000000..302b648c14 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Filter.cs @@ -0,0 +1,8 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class Filter : IFilter +{ + public IconDataType Icon => throw new NotImplementedException(); + public string Id => throw new NotImplementedException(); + public string Name => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Form.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Form.cs new file mode 100644 index 0000000000..78c10475e3 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Form.cs @@ -0,0 +1,13 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class Form: IForm +{ + public string Data { get; set; } + public string State { get; set; } + public string Template { get; set; } + + public virtual string DataJson() => Data; + public virtual string StateJson() => State; + public virtual string TemplateJson() => Template; + public virtual ICommandResult SubmitForm(string payload) => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/FormPage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/FormPage.cs new file mode 100644 index 0000000000..6e10858eff --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/FormPage.cs @@ -0,0 +1,10 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class FormPage : Action, IFormPage +{ + private bool _Loading = false; + + public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } + + public virtual IForm[] Forms() => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/GoToPageArgs.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/GoToPageArgs.cs new file mode 100644 index 0000000000..2e187246a9 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/GoToPageArgs.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class GoToPageArgs : IGoToPageArgs +{ + public required string PageId { get; set; } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/InvokableCommand.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/InvokableCommand.cs new file mode 100644 index 0000000000..8cd9c49921 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/InvokableCommand.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class InvokableCommand : Action, IInvokableCommand +{ + public virtual ICommandResult Invoke() => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListItem.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListItem.cs new file mode 100644 index 0000000000..914ae9357a --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListItem.cs @@ -0,0 +1,27 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class ListItem : BaseObservable, IListItem +{ + protected string _Title = ""; + protected string _Subtitle = ""; + protected ITag[] _Tags = []; + protected IDetails? _Details; + protected ICommand _Command; + protected IContextItem[] _MoreCommands = []; + protected IFallbackHandler? _FallbackHandler; + + public string Title { get => !string.IsNullOrEmpty(this._Title) ? this._Title : _Command.Name; set { _Title = value; OnPropertyChanged(nameof(Title)); } } + public string Subtitle { get => _Subtitle; set { _Subtitle = value; OnPropertyChanged(nameof(Subtitle)); } } + public ITag[] Tags { get => _Tags; set { _Tags = value; OnPropertyChanged(nameof(Tags)); } } + public IDetails? Details { get => _Details; set { _Details = value; OnPropertyChanged(nameof(Details)); } } + public ICommand Command { get => _Command; set { _Command = value; OnPropertyChanged(nameof(Command)); } } + public IContextItem[] MoreCommands { get => _MoreCommands; set { _MoreCommands = value; OnPropertyChanged(nameof(MoreCommands)); } } + + public IFallbackHandler? FallbackHandler { get => _FallbackHandler ?? _Command as IFallbackHandler; init { _FallbackHandler = value; } } + + public ListItem(ICommand command) + { + _Command = command; + _Title = command.Name; + } +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListPage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListPage.cs new file mode 100644 index 0000000000..a7fd896188 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListPage.cs @@ -0,0 +1,20 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class ListPage : Action, IListPage +{ + private string _PlaceholderText = ""; + private string _SearchText = ""; + private bool _ShowDetails = false; + private bool _Loading = false; + private IFilters _Filters = null; + private IGridProperties _GridProperties = null; + + public string PlaceholderText { get => _PlaceholderText; set { _PlaceholderText = value; OnPropertyChanged(nameof(PlaceholderText)); } } + public string SearchText { get => _SearchText; set { _SearchText = value; OnPropertyChanged(nameof(SearchText)); } } + public bool ShowDetails { get => _ShowDetails; set { _ShowDetails = value; OnPropertyChanged(nameof(ShowDetails)); } } + public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } + public IFilters Filters { get => _Filters; set { _Filters = value; OnPropertyChanged(nameof(Filters)); } } + public IGridProperties GridProperties { get => _GridProperties; set { _GridProperties = value; OnPropertyChanged(nameof(GridProperties)); } } + + public virtual ISection[] GetItems() => throw new NotImplementedException(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListSection.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListSection.cs new file mode 100644 index 0000000000..09b25a6cb7 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/ListSection.cs @@ -0,0 +1,7 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class ListSection : ISection +{ + public string Title { get; set; } = ""; + public virtual IListItem[] Items { get; set; } = []; +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/MarkdownPage.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/MarkdownPage.cs new file mode 100644 index 0000000000..faf9e0f700 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/MarkdownPage.cs @@ -0,0 +1,18 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class MarkdownPage : Action, IMarkdownPage +{ + private bool _Loading = false; + protected ITag[] _Tags = []; + protected IDetails? _Details = null; + protected string _Title = ""; + + public string Title { get => !string.IsNullOrEmpty(this._Title) ? this._Title : this.Name; set { _Title = value; OnPropertyChanged(nameof(Title)); } } + public bool Loading { get => _Loading; set { _Loading = value; OnPropertyChanged(nameof(Loading)); } } + public ITag[] Tags { get => _Tags; set { _Tags = value; OnPropertyChanged(nameof(Tags)); } } + // public IDetails Details { get => _Details; set { _Details = value; OnPropertyChanged(nameof(Details)); } } + public IContextItem[] Commands { get; set; } = []; + + public virtual string[] Bodies() => throw new NotImplementedException(); + public virtual IDetails Details() => null; +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/NoOpAction.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/NoOpAction.cs new file mode 100644 index 0000000000..5b731e7e16 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/NoOpAction.cs @@ -0,0 +1,6 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class NoOpAction : InvokableCommand +{ + public override ICommandResult Invoke() => ActionResult.KeepOpen(); +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorContextItem.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorContextItem.cs new file mode 100644 index 0000000000..e24e9ffcf9 --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorContextItem.cs @@ -0,0 +1,5 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class SeparatorContextItem : ISeparatorContextItem +{ +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorFilterItem.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorFilterItem.cs new file mode 100644 index 0000000000..a2d07bbafb --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/SeparatorFilterItem.cs @@ -0,0 +1,5 @@ +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class SeparatorFilterItem : ISeparatorFilterItem +{ +} diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Tag.cs b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Tag.cs new file mode 100644 index 0000000000..73cb4c19db --- /dev/null +++ b/src/modules/cmdpal/extensionsdk/Microsoft.Windows.CommandPalette.Extensions.Helpers/Tag.cs @@ -0,0 +1,19 @@ +using Windows.UI; + +namespace Microsoft.Windows.CommandPalette.Extensions.Helpers; + +public class Tag : BaseObservable, ITag +{ + protected Color _Color = new(); + protected IconDataType _Icon = null; + protected string _Text = ""; + protected string _ToolTip = ""; + protected ICommand _Action; + + public Color Color { get => _Color; set { _Color = value; OnPropertyChanged(nameof(Color)); } } + public IconDataType Icon { get => _Icon; set { _Icon = value; OnPropertyChanged(nameof(Icon)); } } + public string Text { get => _Text; set { _Text = value; OnPropertyChanged(nameof(Text)); } } + public string ToolTip { get => _ToolTip; set { _ToolTip = value; OnPropertyChanged(nameof(ToolTip)); } } + public ICommand Command { get => _Action; set { _Action = value; OnPropertyChanged(nameof(Action)); } } + +}