diff --git a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.Common/Helpers/WrappedDockItem.cs b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.Common/Helpers/WrappedDockItem.cs index 3a8a8b83f3..30b83afc57 100644 --- a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.Common/Helpers/WrappedDockItem.cs +++ b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.Common/Helpers/WrappedDockItem.cs @@ -11,16 +11,25 @@ namespace Microsoft.CmdPal.Core.Common.Helpers; public partial class WrappedDockItem : CommandItem { - public override string Title => string.Empty; + public override string Title => $"{_itemTitle} (Pinned)"; + + public override IIconInfo? Icon => _icon; + + private readonly string _itemTitle; + private readonly IIconInfo? _icon; public WrappedDockItem(ICommand command) { Command = new WrappedDockList(command); + _itemTitle = command.Name; + _icon = command.Icon; } public WrappedDockItem(ICommandItem item, string id) { Command = new WrappedDockList(item, id); + _itemTitle = item.Title; + _icon = item.Icon; } } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs index 76ac49e1b5..4a6bb4e71b 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs @@ -168,21 +168,62 @@ public sealed partial class DockViewModel : IDisposable, // } public partial class DockBandSettingsViewModel : ObservableObject { - private readonly DockBandSettings _settingsModel; + private readonly SettingsModel _settingsModel; + private readonly DockBandSettings _dockSettingsModel; private readonly TopLevelViewModel _adapter; public string Title => _adapter.Title; + public string Description + { + get + { + // TODO! we should have a way of saying "pinned from {extension}" vs + // just a band that's from an extension + return $"{_adapter.ExtensionName}"; + } + } + public string ProviderId => _adapter.CommandProviderId; - public IconInfoViewModel Icon => _adapter.ItemViewModel.Icon; + public IconInfoViewModel Icon => _adapter.IconViewModel; - public bool ShowLabels => _settingsModel.ShowLabels ?? true; // TODO! deal with the fact it might be null - - public DockBandSettingsViewModel(DockBandSettings settingsModel, TopLevelViewModel adapter) + public bool ShowLabels { - _settingsModel = settingsModel; + get => _dockSettingsModel.ShowLabels ?? true; // TODO! deal with the fact it might be null + set => _dockSettingsModel.ShowLabels = value; // TODO! save settings + } + + public string PinSide + { + // returns "Start", "End" or "None" + get + { + var dockSettings = _settingsModel.DockSettings; + var inStart = dockSettings.StartBands.Any(b => b.Id == _dockSettingsModel.Id); + if (inStart) + { + return "Start"; + } + + var inEnd = dockSettings.EndBands.Any(b => b.Id == _dockSettingsModel.Id); + if (inEnd) + { + return "End"; + } + + return "None"; + } + } + + public DockBandSettingsViewModel( + DockBandSettings dockSettingsModel, + TopLevelViewModel adapter, + SettingsModel settingsModel) + { + _dockSettingsModel = dockSettingsModel; _adapter = adapter; + _settingsModel = settingsModel; } } #pragma warning restore SA1402 // File may only contain a single type diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs index bc61a0c52f..57b1ae6984 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelViewModel.cs @@ -48,18 +48,22 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem public CommandPaletteHost ExtensionHost { get; private set; } + public string ExtensionName => ExtensionHost.Extension?.ExtensionDisplayName ?? "Built-in"; // TODO! loc + public CommandViewModel CommandViewModel => _commandItemViewModel.Command; public CommandItemViewModel ItemViewModel => _commandItemViewModel; public string CommandProviderId => _commandProviderId; + public IconInfoViewModel IconViewModel => _commandItemViewModel.Icon; + ////// ICommandItem public string Title => _commandItemViewModel.Title; public string Subtitle => _commandItemViewModel.Subtitle; - public IIconInfo Icon => _commandItemViewModel.Icon; + public IIconInfo Icon => (IIconInfo)IconViewModel; public IIconInfo InitialIcon => _initialIcon ?? _commandItemViewModel.Icon; @@ -258,7 +262,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem return; } - _initialIcon = _commandItemViewModel.Icon; + _initialIcon = (IIconInfo?)_commandItemViewModel.Icon; if (raiseNotification) { diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml index 843c270c1c..368abab579 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml @@ -94,7 +94,7 @@ - + @@ -107,6 +107,17 @@ + + + + + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs index 4057466cd1..ac2b165349 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Settings/DockSettingsPage.xaml.cs @@ -130,13 +130,14 @@ public sealed partial class DockSettingsPage : Page // var allBands = GetAllBands(); var tlcManager = App.Current.Services.GetService()!; + var settingsModel = App.Current.Services.GetService()!; var allBands = tlcManager.DockBands; foreach (var band in allBands) { var setting = band.DockBandSettings; if (setting is not null) { - allSettings.Add(new(setting, band)); + allSettings.Add(new(setting, band, settingsModel)); } }