Compare commits

...

1 Commits

Author SHA1 Message Date
Mike Griese
201debdca2 known working commit:
This is the SDK of 73786cd, but with changes:
*  the `IExtendedAttributesProvider` commented off of the `CommandItem`
* and we move IEAP onto ListItem. It's implemented by the base
  CommandItem's GetProperties. This does work.

so at least we have _something_ to work with.
2026-02-03 09:47:04 -06:00
30 changed files with 806 additions and 1147 deletions

View File

@@ -1,10 +1,12 @@
// Copyright (c) Microsoft Corporation
// 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.CommandPalette.Extensions;
using Shmuelie.WinRTServer;
using Shmuelie.WinRTServer.CsWinRT;
namespace SamplePagesExtension;
@@ -15,18 +17,22 @@ public class Program
{
if (args.Length > 0 && args[0] == "-RegisterProcessAsComServer")
{
using ExtensionServer server = new();
var extensionDisposedEvent = new ManualResetEvent(false);
var extensionInstance = new SampleExtension(extensionDisposedEvent);
global::Shmuelie.WinRTServer.ComServer server = new();
ManualResetEvent extensionDisposedEvent = new(false);
// 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);
SampleExtension extensionInstance = new(extensionDisposedEvent);
server.RegisterClass<SampleExtension, IExtension>(() => extensionInstance);
server.Start();
// This will make the main thread wait until the event is signalled by the extension class.
// Since we have a single instance of the extension object, we exit as soon as it is disposed.
// Since we have single instance of the extension object, we exit as soon as it is disposed.
extensionDisposedEvent.WaitOne();
server.Stop();
server.UnsafeDispose();
}
else
{

View File

@@ -34,6 +34,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Shmuelie.WinRTServer" />
<PackageReference Include="Microsoft.WindowsAppSDK" />
<PackageReference Include="Microsoft.Windows.CsWin32">
<PrivateAssets>all</PrivateAssets>

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.Runtime.CompilerServices;
using Windows.Foundation;
namespace Microsoft.CommandPalette.Extensions.Toolkit;
@@ -15,7 +14,7 @@ public partial class BaseObservable : INotifyPropChanged
{
public event TypedEventHandler<object, IPropChangedEventArgs>? PropChanged;
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null)
protected void OnPropertyChanged(string propertyName)
{
try
{
@@ -23,37 +22,10 @@ public partial class BaseObservable : INotifyPropChanged
// this can crash as we try to invoke the handlers from that process.
// However, just catching it seems to still raise the event on the
// new host?
PropChanged?.Invoke(this, new PropChangedEventArgs(propertyName!));
PropChanged?.Invoke(this, new PropChangedEventArgs(propertyName));
}
catch
{
}
}
/// <summary>
/// Sets the backing field to the specified value and raises a property changed
/// notification if the value is different from the current one.
/// </summary>
/// <typeparam name="T">The type of the property.</typeparam>
/// <param name="field">A reference to the backing field for the property.</param>
/// <param name="value">The new value to assign to the property.</param>
/// <param name="propertyName">
/// The name of the property. This is optional and is usually supplied
/// automatically by the <see cref="CallerMemberNameAttribute"/>.
/// </param>
/// <returns>
/// <see langword="true"/> if the field was updated and a property changed
/// notification was raised; otherwise, <see langword="false"/>.
/// </returns>
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
{
return false;
}
field = value;
OnPropertyChanged(propertyName!);
return true;
}
}

View File

@@ -6,11 +6,31 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Command : BaseObservable, ICommand
{
public virtual string Name { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Name
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Name));
}
}
= string.Empty;
public virtual string Id { get; set; } = string.Empty;
public virtual IconInfo Icon { get; set => SetProperty(ref field, value); } = new();
public virtual IconInfo Icon
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Icon));
}
}
= new();
IIconInfo ICommand.Icon => Icon;
}

View File

@@ -6,9 +6,9 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class CommandContextItem : CommandItem, ICommandContextItem
{
public virtual bool IsCritical { get; set => SetProperty(ref field, value); }
public virtual bool IsCritical { get; set; }
public virtual KeyChord RequestedShortcut { get; set => SetProperty(ref field, value); }
public virtual KeyChord RequestedShortcut { get; set; }
public CommandContextItem(ICommand command)
: base(command)

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation
// 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.
@@ -8,7 +8,7 @@ using WinRT;
namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class CommandItem : BaseObservable, ICommandItem, IExtendedAttributesProvider
public partial class CommandItem : BaseObservable, ICommandItem
{
private readonly PropertySet _extendedAttributes = new();
@@ -19,36 +19,44 @@ public partial class CommandItem : BaseObservable, ICommandItem, IExtendedAttrib
private DataPackage? _dataPackage;
private DataPackageView? _dataPackageView;
public virtual IIconInfo? Icon { get; set => SetProperty(ref field, value); }
public virtual IIconInfo? Icon
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(Icon));
}
}
public virtual string Title
{
get => !string.IsNullOrEmpty(_title) ? _title : _command?.Name ?? string.Empty;
set
{
var oldTitle = Title;
_title = value;
if (Title != oldTitle)
{
OnPropertyChanged();
}
OnPropertyChanged(nameof(Title));
}
}
public virtual string Subtitle { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Subtitle
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Subtitle));
}
}
= string.Empty;
public virtual ICommand? Command
{
get => _command;
set
{
if (EqualityComparer<ICommand?>.Default.Equals(value, _command))
{
return;
}
var oldTitle = Title;
if (_commandListener is not null)
{
_commandListener.Detach();
@@ -63,8 +71,8 @@ public partial class CommandItem : BaseObservable, ICommandItem, IExtendedAttrib
value.PropChanged += _commandListener.OnEvent;
}
OnPropertyChanged();
if (string.IsNullOrEmpty(_title) && oldTitle != Title)
OnPropertyChanged(nameof(Command));
if (string.IsNullOrEmpty(_title))
{
OnPropertyChanged(nameof(Title));
}
@@ -80,7 +88,17 @@ public partial class CommandItem : BaseObservable, ICommandItem, IExtendedAttrib
}
}
public virtual IContextItem[] MoreCommands { get; set => SetProperty(ref field, value); } = [];
public virtual IContextItem[] MoreCommands
{
get;
set
{
field = value;
OnPropertyChanged(nameof(MoreCommands));
}
}
= [];
public DataPackage? DataPackage
{

View File

@@ -6,9 +6,9 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class CommandResult : ICommandResult
{
public ICommandResultArgs? Args { get; private init; }
public ICommandResultArgs? Args { get; private set; }
public CommandResultKind Kind { get; private init; } = CommandResultKind.Dismiss;
public CommandResultKind Kind { get; private set; } = CommandResultKind.Dismiss;
public static CommandResult Dismiss()
{

View File

@@ -10,9 +10,17 @@ public abstract partial class ContentPage : Page, IContentPage
{
public event TypedEventHandler<object, IItemsChangedEventArgs>? ItemsChanged;
public virtual IDetails? Details { get; set => SetProperty(ref field, value); }
public virtual IDetails? Details
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(Details));
}
}
public virtual IContextItem[] Commands { get; set => SetProperty(ref field, value); } = [];
public virtual IContextItem[] Commands { get; set; } = [];
public abstract IContent[] GetContent();

View File

@@ -7,15 +7,65 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Details : BaseObservable, IDetails, IExtendedAttributesProvider
{
public virtual IIconInfo HeroImage { get; set => SetProperty(ref field, value); } = new IconInfo();
public virtual IIconInfo HeroImage
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(HeroImage));
}
}
public virtual string Title { get; set => SetProperty(ref field, value); } = string.Empty;
= new IconInfo();
public virtual string Body { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Title
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Title));
}
}
public virtual IDetailsElement[] Metadata { get; set => SetProperty(ref field, value); } = [];
= string.Empty;
public virtual ContentSize Size { get; set => SetProperty(ref field, value); } = ContentSize.Small;
public virtual string Body
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Body));
}
}
= string.Empty;
public virtual IDetailsElement[] Metadata
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Metadata));
}
}
= [];
public virtual ContentSize Size
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Size));
}
}
= ContentSize.Small;
public IDictionary<string, object>? GetProperties() => new ValueSet()
{

View File

@@ -0,0 +1,124 @@
// 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.CommandPalette.Extensions.Toolkit;
#pragma warning disable SA1402 // File may only contain a single type
public partial class WrappedDockItem : CommandItem
{
public override string Title => _itemTitle;
public override IIconInfo? Icon => _icon;
public override ICommand? Command => _backingList;
private readonly string _itemTitle;
private readonly IIconInfo? _icon;
private readonly WrappedDockList _backingList;
public IListItem[] Items { get => _backingList.GetItems(); set => _backingList.SetItems(value); }
public WrappedDockItem(
ICommand command,
string displayTitle)
{
_backingList = new WrappedDockList(command);
_itemTitle = string.IsNullOrEmpty(displayTitle) ? command.Name : displayTitle;
_icon = command.Icon;
}
public WrappedDockItem(
ICommandItem item,
string id,
string displayTitle)
{
_backingList = new WrappedDockList(item, id);
_itemTitle = string.IsNullOrEmpty(displayTitle) ? item.Title : displayTitle;
_icon = item.Icon;
}
public WrappedDockItem(IListItem[] items, string id, string displayTitle)
{
_backingList = new WrappedDockList(items, id, displayTitle);
_itemTitle = displayTitle;
}
}
public partial class WrappedDockList : ListPage
{
private string _id;
public override string Id => _id;
// private ICommand _command;
private List<IListItem> _items;
public WrappedDockList(ICommand command)
{
// _command = command;
_items = new() { new ListItem(command) };
Name = command.Name;
_id = command.Id;
}
public WrappedDockList(ICommandItem item, string id)
{
var command = item.Command;
// TODO! This isn't _totally correct, because the wrapping item will not
// listen for property changes on the inner item.
_items = new()
{
new ListItem(command)
{
Title = item.Title,
Subtitle = item.Subtitle,
Icon = item.Icon,
MoreCommands = item.MoreCommands,
},
};
Name = command.Name;
_id = string.IsNullOrEmpty(id) ? command.Id : id;
}
public WrappedDockList(IListItem[] items, string id, string name)
{
_items = new(items);
Name = name;
_id = id;
}
public WrappedDockList(ICommand[] items, string id, string name)
{
_items = new();
foreach (var item in items)
{
_items.Add(new ListItem(item));
}
Name = name;
_id = id;
}
public override IListItem[] GetItems()
{
return _items.ToArray();
}
internal void SetItems(IListItem[]? newItems)
{
if (newItems == null)
{
_items = [];
RaiseItemsChanged(0);
return;
}
ListHelpers.InPlaceUpdateList(_items, newItems);
RaiseItemsChanged(_items.Count);
}
}
#pragma warning restore SA1402 // File may only contain a single type

View File

@@ -4,25 +4,18 @@
namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class FallbackCommandItem : CommandItem, IFallbackCommandItem, IFallbackHandler, IFallbackCommandItem2
public partial class FallbackCommandItem : CommandItem, IFallbackCommandItem, IFallbackHandler
{
private readonly IFallbackHandler? _fallbackHandler;
public FallbackCommandItem(string displayTitle, string id)
public FallbackCommandItem(string displayTitle)
{
DisplayTitle = displayTitle;
Id = id;
}
public FallbackCommandItem(ICommand command, string displayTitle, string id)
public FallbackCommandItem(ICommand command, string displayTitle)
: base(command)
{
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentException("A non-empty or whitespace Id must be provided.", nameof(id));
}
Id = id;
DisplayTitle = displayTitle;
if (command is IFallbackHandler f)
{
@@ -36,8 +29,6 @@ public partial class FallbackCommandItem : CommandItem, IFallbackCommandItem, IF
init => _fallbackHandler = value;
}
public virtual string Id { get; }
public virtual string DisplayTitle { get; }
public virtual void UpdateQuery(string query) => _fallbackHandler?.UpdateQuery(query);

View File

@@ -6,9 +6,39 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Filter : BaseObservable, IFilter
{
public virtual IIconInfo Icon { get; set => SetProperty(ref field, value); } = new IconInfo();
public virtual IIconInfo Icon
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(Icon));
}
}
public virtual string Id { get; set => SetProperty(ref field, value); } = string.Empty;
= new IconInfo();
public virtual string Name { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Id
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Id));
}
}
= string.Empty;
public virtual string Name
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Name));
}
}
= string.Empty;
}

View File

@@ -6,7 +6,17 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public abstract partial class Filters : BaseObservable, IFilters
{
public string CurrentFilterId { get; set => SetProperty(ref field, value); } = string.Empty;
public string CurrentFilterId
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(CurrentFilterId));
}
}
= string.Empty;
// This method should be overridden in derived classes to provide the actual filters.
public abstract IFilterItem[] GetFilters();

View File

@@ -6,11 +6,41 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class FormContent : BaseObservable, IFormContent
{
public virtual string DataJson { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string DataJson
{
get;
set
{
field = value;
OnPropertyChanged(nameof(DataJson));
}
}
public virtual string StateJson { get; set => SetProperty(ref field, value); } = string.Empty;
= string.Empty;
public virtual string TemplateJson { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string StateJson
{
get;
set
{
field = value;
OnPropertyChanged(nameof(StateJson));
}
}
= string.Empty;
public virtual string TemplateJson
{
get;
set
{
field = value;
OnPropertyChanged(nameof(TemplateJson));
}
}
= string.Empty;
public virtual ICommandResult SubmitForm(string inputs, string data) => SubmitForm(inputs);

View File

@@ -6,7 +6,27 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class GalleryGridLayout : BaseObservable, IGalleryGridLayout
{
public virtual bool ShowTitle { get; set => SetProperty(ref field, value); } = true;
public virtual bool ShowTitle
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(ShowTitle));
}
}
public virtual bool ShowSubtitle { get; set => SetProperty(ref field, value); } = true;
= true;
public virtual bool ShowSubtitle
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(ShowSubtitle));
}
}
= true;
}

View File

@@ -2,6 +2,7 @@
// 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 Windows.Storage.Streams;
namespace Microsoft.CommandPalette.Extensions.Toolkit;

View File

@@ -1,18 +1,56 @@
// Copyright (c) Microsoft Corporation
// 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.CommandPalette.Extensions.Toolkit;
public partial class ListItem : CommandItem, IListItem
public partial class ListItem : CommandItem, IListItem, IExtendedAttributesProvider
{
public virtual ITag[] Tags { get; set => SetProperty(ref field, value); } = [];
private ITag[] _tags = [];
private IDetails? _details;
public virtual IDetails? Details { get; set => SetProperty(ref field, value); }
private string _section = string.Empty;
private string _textToSuggest = string.Empty;
public virtual string Section { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual ITag[] Tags
{
get => _tags;
set
{
_tags = value;
OnPropertyChanged(nameof(Tags));
}
}
public virtual string TextToSuggest { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual IDetails? Details
{
get => _details;
set
{
_details = value;
OnPropertyChanged(nameof(Details));
}
}
public virtual string Section
{
get => _section;
set
{
_section = value;
OnPropertyChanged(nameof(Section));
}
}
public virtual string TextToSuggest
{
get => _textToSuggest;
set
{
_textToSuggest = value;
OnPropertyChanged(nameof(TextToSuggest));
}
}
public ListItem(ICommand command)
: base(command)

View File

@@ -8,23 +8,85 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class ListPage : Page, IListPage
{
private string _placeholderText = string.Empty;
private string _searchText = string.Empty;
private bool _showDetails;
private bool _hasMore;
private IFilters? _filters;
private IGridProperties? _gridProperties;
private ICommandItem? _emptyContent;
public event TypedEventHandler<object, IItemsChangedEventArgs>? ItemsChanged;
private string _searchText = string.Empty;
public virtual string PlaceholderText
{
get => _placeholderText;
set
{
_placeholderText = value;
OnPropertyChanged(nameof(PlaceholderText));
}
}
public virtual string PlaceholderText { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string SearchText
{
get => _searchText;
set
{
_searchText = value;
OnPropertyChanged(nameof(SearchText));
}
}
public virtual string SearchText { get => _searchText; set => SetProperty(ref _searchText, value); }
public virtual bool ShowDetails
{
get => _showDetails;
set
{
_showDetails = value;
OnPropertyChanged(nameof(ShowDetails));
}
}
public virtual bool ShowDetails { get; set => SetProperty(ref field, value); }
public virtual bool HasMoreItems
{
get => _hasMore;
set
{
_hasMore = value;
OnPropertyChanged(nameof(HasMoreItems));
}
}
public virtual bool HasMoreItems { get; set => SetProperty(ref field, value); }
public virtual IFilters? Filters
{
get => _filters;
set
{
_filters = value;
OnPropertyChanged(nameof(Filters));
}
}
public virtual IFilters? Filters { get; set => SetProperty(ref field, value); }
public virtual IGridProperties? GridProperties
{
get => _gridProperties;
set
{
_gridProperties = value;
OnPropertyChanged(nameof(GridProperties));
}
}
public virtual IGridProperties? GridProperties { get; set => SetProperty(ref field, value); }
public virtual ICommandItem? EmptyContent { get; set => SetProperty(ref field, value); }
public virtual ICommandItem? EmptyContent
{
get => _emptyContent;
set
{
_emptyContent = value;
OnPropertyChanged(nameof(EmptyContent));
}
}
public virtual IListItem[] GetItems() => [];

View File

@@ -6,7 +6,17 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class MarkdownContent : BaseObservable, IMarkdownContent
{
public virtual string Body { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Body
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Body));
}
}
= string.Empty;
public MarkdownContent()
{

View File

@@ -6,5 +6,15 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class MediumGridLayout : BaseObservable, IMediumGridLayout
{
public virtual bool ShowTitle { get; set => SetProperty(ref field, value); } = true;
public virtual bool ShowTitle
{
get => field;
set
{
field = value;
OnPropertyChanged(nameof(ShowTitle));
}
}
= true;
}

View File

@@ -6,9 +6,37 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Page : Command, IPage
{
public virtual bool IsLoading { get; set => SetProperty(ref field, value); }
private bool _loading;
private string _title = string.Empty;
private OptionalColor _accentColor;
public virtual string Title { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual bool IsLoading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(IsLoading));
}
}
public virtual OptionalColor AccentColor { get; set => SetProperty(ref field, value); }
public virtual string Title
{
get => _title;
set
{
_title = value;
OnPropertyChanged(nameof(Title));
}
}
public virtual OptionalColor AccentColor
{
get => _accentColor;
set
{
_accentColor = value;
OnPropertyChanged(nameof(AccentColor));
}
}
}

View File

@@ -6,7 +6,27 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class ProgressState : BaseObservable, IProgressState
{
public virtual bool IsIndeterminate { get; set => SetProperty(ref field, value); }
private bool _isIndeterminate;
public virtual uint ProgressPercent { get; set => SetProperty(ref field, value); }
private uint _progressPercent;
public virtual bool IsIndeterminate
{
get => _isIndeterminate;
set
{
_isIndeterminate = value;
OnPropertyChanged(nameof(IsIndeterminate));
}
}
public virtual uint ProgressPercent
{
get => _progressPercent;
set
{
_progressPercent = value;
OnPropertyChanged(nameof(ProgressPercent));
}
}
}

View File

@@ -2,6 +2,8 @@
// 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.Foundation;
namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class PropChangedEventArgs : IPropChangedEventArgs

View File

@@ -12,6 +12,11 @@ public sealed partial class Section : IEnumerable<IListItem>
public string SectionTitle { get; set; } = string.Empty;
private Separator CreateSectionListItem()
{
return new Separator(SectionTitle);
}
public Section(string sectionName, IListItem[] items)
{
SectionTitle = sectionName;
@@ -28,11 +33,6 @@ public sealed partial class Section : IEnumerable<IListItem>
{
}
private Separator CreateSectionListItem()
{
return new Separator(SectionTitle);
}
public IEnumerator<IListItem> GetEnumerator() => Items.ToList().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

View File

@@ -4,8 +4,15 @@
namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Separator : BaseObservable, IListItem, ISeparatorContextItem, ISeparatorFilterItem
public partial class Separator : IListItem, ISeparatorContextItem, ISeparatorFilterItem
{
public Separator(string? title = "")
: base()
{
Section = title ?? string.Empty;
Command = null;
}
public IDetails? Details => null;
public string? Section { get; private set; }
@@ -14,7 +21,7 @@ public partial class Separator : BaseObservable, IListItem, ISeparatorContextIte
public string? TextToSuggest => null;
public ICommand? Command => null;
public ICommand? Command { get; private set; }
public IIconInfo? Icon => null;
@@ -25,19 +32,12 @@ public partial class Separator : BaseObservable, IListItem, ISeparatorContextIte
public string? Title
{
get => Section;
set
{
if (Section != value)
{
Section = value;
OnPropertyChanged();
OnPropertyChanged(Section);
}
}
set => Section = value;
}
public Separator(string? title = "")
public event Windows.Foundation.TypedEventHandler<object, IPropChangedEventArgs>? PropChanged
{
Section = title ?? string.Empty;
add { }
remove { }
}
}

View File

@@ -6,9 +6,37 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class StatusMessage : BaseObservable, IStatusMessage
{
public virtual string Message { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual string Message
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Message));
}
}
public virtual MessageState State { get; set => SetProperty(ref field, value); } = MessageState.Info;
= string.Empty;
public virtual IProgressState? Progress { get; set => SetProperty(ref field, value); }
public virtual MessageState State
{
get;
set
{
field = value;
OnPropertyChanged(nameof(State));
}
}
= MessageState.Info;
public virtual IProgressState? Progress
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Progress));
}
}
}

View File

@@ -6,15 +6,63 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class Tag : BaseObservable, ITag
{
public virtual OptionalColor Foreground { get; set => SetProperty(ref field, value); }
private OptionalColor _foreground;
private OptionalColor _background;
private string _text = string.Empty;
public virtual OptionalColor Background { get; set => SetProperty(ref field, value); }
public virtual OptionalColor Foreground
{
get => _foreground;
set
{
_foreground = value;
OnPropertyChanged(nameof(Foreground));
}
}
public virtual IIconInfo Icon { get; set => SetProperty(ref field, value); } = new IconInfo();
public virtual OptionalColor Background
{
get => _background;
set
{
_background = value;
OnPropertyChanged(nameof(Background));
}
}
public virtual string Text { get; set => SetProperty(ref field, value); } = string.Empty;
public virtual IIconInfo Icon
{
get;
set
{
field = value;
OnPropertyChanged(nameof(Icon));
}
}
public virtual string ToolTip { get; set => SetProperty(ref field, value); } = string.Empty;
= new IconInfo();
public virtual string Text
{
get => _text;
set
{
_text = value;
OnPropertyChanged(nameof(Text));
}
}
public virtual string ToolTip
{
get;
set
{
field = value;
OnPropertyChanged(nameof(ToolTip));
}
}
= string.Empty;
public Tag()
{
@@ -22,6 +70,6 @@ public partial class Tag : BaseObservable, ITag
public Tag(string text)
{
Text = text;
_text = text;
}
}

View File

@@ -8,11 +8,19 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class TreeContent : BaseObservable, ITreeContent
{
public event TypedEventHandler<object, IItemsChangedEventArgs>? ItemsChanged;
public IContent[] Children { get; set; } = [];
public virtual IContent? RootContent { get; set => SetProperty(ref field, value); }
public virtual IContent? RootContent
{
get;
set
{
field = value;
OnPropertyChanged(nameof(RootContent));
}
}
public event TypedEventHandler<object, IItemsChangedEventArgs>? ItemsChanged;
public virtual IContent[] GetChildren() => Children;

View File

@@ -371,11 +371,6 @@ namespace Microsoft.CommandPalette.Extensions
IFallbackHandler FallbackHandler{ get; };
String DisplayTitle { get; };
};
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface IFallbackCommandItem2 requires IFallbackCommandItem {
String Id { get; };
};
[contract(Microsoft.CommandPalette.Extensions.ExtensionsContract, 1)]
interface ICommandProvider requires Windows.Foundation.IClosable, INotifyItemsChanged