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 3d2e630d54..e84509c306 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Dock/DockViewModel.cs @@ -8,16 +8,19 @@ using ManagedCommon; using Microsoft.CmdPal.Core.Common; using Microsoft.CmdPal.Core.ViewModels; using Microsoft.CmdPal.UI.ViewModels.Messages; +using Microsoft.CmdPal.UI.ViewModels.Settings; using Microsoft.CommandPalette.Extensions.Toolkit; using Microsoft.UI.Dispatching; namespace Microsoft.CmdPal.UI.ViewModels.Dock; -public sealed partial class DockViewModel : IDisposable, IRecipient, IPageContext +public sealed partial class DockViewModel : IDisposable, + IRecipient, + IPageContext { private readonly TopLevelCommandManager _topLevelCommandManager; - // private Settings _settings; + private DockSettings _settings; private DispatcherQueue _dispatcherQueue = DispatcherQueue.GetForCurrentThread(); private DispatcherQueue _updateWindowsQueue = DispatcherQueueController.CreateOnDedicatedThread().DispatcherQueue; @@ -25,31 +28,44 @@ public sealed partial class DockViewModel : IDisposable, IRecipient EndItems { get; } = new(); - public DockViewModel(TopLevelCommandManager tlcManager, SettingsModel settings, TaskScheduler scheduler) + public DockViewModel( + TopLevelCommandManager tlcManager, + SettingsModel settings, + TaskScheduler scheduler) { _topLevelCommandManager = tlcManager; + _settings = settings.DockSettings; Scheduler = scheduler; WeakReferenceMessenger.Default.Register(this); } - private static string[] _startCommands = [ - "com.microsoft.cmdpal.windowwalker.dockband", - ]; - - private static string[] _endCommands = [ - "com.crloewen.performanceMonitor.dockband", - "com.microsoft.cmdpal.clipboardHistory.Band", - "com.zadjii.virtualDesktops.band", - "com.microsoft.cmdpal.timedate.dockband", - ]; - - private void SetupBands() + public void UpdateSettings(DockSettings settings) { - SetupBands(_startCommands, StartItems); - SetupBands(_endCommands, EndItems); + Logger.LogDebug($"DockViewModel.UpdateSettings"); + _settings = settings; + SetupBands(); } - private void SetupBands(string[] bandIds, ObservableCollection target) + // private static string[] _startCommands = [ + // "com.microsoft.cmdpal.windowwalker.dockband", + // ]; + + // private static string[] _endCommands = [ + // "com.crloewen.performanceMonitor.dockband", + // "com.microsoft.cmdpal.clipboardHistory.Band", + // "com.zadjii.virtualDesktops.band", + // "com.microsoft.cmdpal.timedate.dockband", + // ]; + private void SetupBands() + { + Logger.LogDebug($"Setting up dock bands"); + SetupBands(_settings.StartBands, StartItems); + SetupBands(_settings.EndBands, EndItems); + } + + private void SetupBands( + List bandIds, + ObservableCollection target) { List newBands = new(); foreach (var commandId in bandIds) @@ -60,6 +76,7 @@ public sealed partial class DockViewModel : IDisposable, IRecipient { ListHelpers.InPlaceUpdateList(target, newBands, out var removed); - Logger.LogDebug($"({beforeCount}) -> ({afterCount}), Removed {removed?.Count ?? 0} items"); + var isStartBand = target == StartItems; + var label = isStartBand ? "Start bands:" : "End bands:"; + Logger.LogDebug($"{label} ({beforeCount}) -> ({afterCount}), Removed {removed?.Count ?? 0} items"); }); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs index 155af250f6..1ef10709e6 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Settings/DockSettings.cs @@ -14,6 +14,10 @@ public class DockSettings public DockSize DockSize { get; set; } = DockSize.Small; public DockBackdrop Backdrop { get; set; } = DockBackdrop.Acrylic; + + public List StartBands { get; set; } = []; + + public List EndBands { get; set; } = []; } public enum DockSide diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs index e141ee7a90..45e223b041 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/DockWindow.xaml.cs @@ -143,6 +143,8 @@ public sealed partial class DockWindow : WindowEx, // , IRecipient