From 3d2f069c433c181a28fb376654a6c283765b2f7d Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 24 Mar 2026 21:19:28 +0100 Subject: [PATCH] [CmdPal Dock] New pin UX (#46436) ## Summary of the Pull Request This PR introduces a new dialog that gives you more control on how a command gets pinned to the Dock. ![PinUX](https://github.com/user-attachments/assets/c270e93f-3fd9-42d5-aaa9-95c08efb8bac) ## PR Checklist - [x] Closes: #46433 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- .../CommandProviderWrapper.cs | 19 +- .../Messages/PinToDockMessage.cs | 10 +- .../Messages/ShowPinToDockDialogMessage.cs | 15 ++ .../TopLevelCommandManager.cs | 2 +- .../CommandPaletteContextMenuFactory.cs | 14 +- .../Dock/PinToDockDialogContent.xaml | 127 +++++++++++++ .../Dock/PinToDockDialogContent.xaml.cs | 171 ++++++++++++++++++ .../Microsoft.CmdPal.UI/MainWindow.xaml | 4 +- .../Microsoft.CmdPal.UI.csproj | 1 + .../Pages/ShellPage.xaml.cs | 39 ++++ .../Strings/en-us/Resources.resw | 64 +++++++ 11 files changed, 457 insertions(+), 9 deletions(-) create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowPinToDockDialogMessage.cs create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml create mode 100644 src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml.cs diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs index 73c613962e..ce5cbcf69d 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/CommandProviderWrapper.cs @@ -436,7 +436,7 @@ public sealed class CommandProviderWrapper : ICommandProviderContext } } - public void PinDockBand(string commandId, IServiceProvider serviceProvider) + public void PinDockBand(string commandId, IServiceProvider serviceProvider, Dock.DockPinSide side = Dock.DockPinSide.Start, bool? showTitles = null, bool? showSubtitles = null) { var settingsService = serviceProvider.GetRequiredService(); var settings = settingsService.Settings; @@ -444,8 +444,23 @@ public sealed class CommandProviderWrapper : ICommandProviderContext { CommandId = commandId, ProviderId = this.ProviderId, + ShowTitles = showTitles, + ShowSubtitles = showSubtitles, }; - settings.DockSettings.StartBands.Add(bandSettings); + + switch (side) + { + case Dock.DockPinSide.Center: + settings.DockSettings.CenterBands.Add(bandSettings); + break; + case Dock.DockPinSide.End: + settings.DockSettings.EndBands.Add(bandSettings); + break; + case Dock.DockPinSide.Start: + default: + settings.DockSettings.StartBands.Add(bandSettings); + break; + } // Raise CommandsChanged so the TopLevelCommandManager reloads our commands this.CommandsChanged?.Invoke(this, new ItemsChangedEventArgs(-1)); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PinToDockMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PinToDockMessage.cs index 29ae2e018b..bf13edc6ab 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PinToDockMessage.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/PinToDockMessage.cs @@ -2,6 +2,14 @@ // The Microsoft Corporation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.CmdPal.UI.ViewModels.Dock; + namespace Microsoft.CmdPal.UI.ViewModels.Messages; -public record PinToDockMessage(string ProviderId, string CommandId, bool Pin); +public record PinToDockMessage( + string ProviderId, + string CommandId, + bool Pin, + DockPinSide Side = DockPinSide.Start, + bool? ShowTitles = null, + bool? ShowSubtitles = null); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowPinToDockDialogMessage.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowPinToDockDialogMessage.cs new file mode 100644 index 0000000000..db83e67059 --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/Messages/ShowPinToDockDialogMessage.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.CmdPal.UI.ViewModels.Settings; + +namespace Microsoft.CmdPal.UI.ViewModels.Messages; + +public record ShowPinToDockDialogMessage( + string ProviderId, + string CommandId, + string Title, + string Subtitle, + IconInfoViewModel? Icon, + DockSide DockSide); diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs index dc4372308a..f480776087 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI.ViewModels/TopLevelCommandManager.cs @@ -707,7 +707,7 @@ public sealed partial class TopLevelCommandManager : ObservableObject, { if (message.Pin) { - wrapper?.PinDockBand(message.CommandId, _serviceProvider); + wrapper?.PinDockBand(message.CommandId, _serviceProvider, message.Side, message.ShowTitles, message.ShowSubtitles); } else { diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/CommandPaletteContextMenuFactory.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/CommandPaletteContextMenuFactory.cs index 55ce07ba5c..7cf91b0d21 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/CommandPaletteContextMenuFactory.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/CommandPaletteContextMenuFactory.cs @@ -198,7 +198,8 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac pin: !alreadyPinned, PinLocation.Dock, _settingsService, - _topLevelCommandManager); + _topLevelCommandManager, + commandItemViewModel: commandItem); var contextItem = new PinToContextItem(pinToTopLevelCommand, commandItem); moreCommands.Add(contextItem); @@ -249,6 +250,7 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac private readonly TopLevelCommandManager _topLevelCommandManager; private readonly bool _pin; private readonly PinLocation _pinLocation; + private readonly CommandItemViewModel? _commandItemViewModel; private bool IsPinToDock => _pinLocation == PinLocation.Dock; @@ -266,7 +268,8 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac bool pin, PinLocation pinLocation, ISettingsService settingsService, - TopLevelCommandManager topLevelCommandManager) + TopLevelCommandManager topLevelCommandManager, + CommandItemViewModel? commandItemViewModel = null) { _commandId = commandId; _providerId = providerId; @@ -274,6 +277,7 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac _settingsService = settingsService; _topLevelCommandManager = topLevelCommandManager; _pin = pin; + _commandItemViewModel = commandItemViewModel; } public override CommandResult Invoke() @@ -325,7 +329,11 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac private void PinToDock() { - PinToDockMessage message = new(_providerId, _commandId, true); + var title = _commandItemViewModel?.Title ?? string.Empty; + var subtitle = _commandItemViewModel?.Subtitle ?? string.Empty; + var icon = _commandItemViewModel?.Icon; + var dockSide = _settingsService.Settings.DockSettings.Side; + ShowPinToDockDialogMessage message = new(_providerId, _commandId, title, subtitle, icon, dockSide); WeakReferenceMessenger.Default.Send(message); } diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml new file mode 100644 index 0000000000..e65c1673c0 --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml @@ -0,0 +1,127 @@ + + + + + + + + + + + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM24 18C25.1046 18 26 18.8954 26 20C26 21.1046 25.1046 22 24 22H12C10.8954 22 10 21.1046 10 20C10 18.8954 10.8954 18 12 18H24Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM38 18C39.1046 18 40 18.8954 40 20C40 21.1046 39.1046 22 38 22H26C24.8954 22 24 21.1046 24 20C24 18.8954 24.8954 18 26 18H38Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM52 18C53.1046 18 54 18.8954 54 20C54 21.1046 53.1046 22 52 22H40C38.8954 22 38 21.1046 38 20C38 18.8954 38.8954 18 40 18H52Z + + + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM24 42C25.1046 42 26 42.8954 26 44C26 45.1046 25.1046 46 24 46H12C10.8954 46 10 45.1046 10 44C10 42.8954 10.8954 42 12 42H24Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM38 42C39.1046 42 40 42.8954 40 44C40 45.1046 39.1046 46 38 46H26C24.8954 46 24 45.1046 24 44C24 42.8954 24.8954 42 26 42H38Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM52 42C53.1046 42 54 42.8954 54 44C54 45.1046 53.1046 46 52 46H40C38.8954 46 38 45.1046 38 44C38 42.8954 38.8954 42 40 42H52Z + + + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM12 14C13.1046 14 14 14.8954 14 16V28C14 29.1046 13.1046 30 12 30C10.8954 30 10 29.1046 10 28V16C10 14.8954 10.8954 14 12 14Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM12 24C13.1046 24 14 24.8954 14 26V38C14 39.1046 13.1046 40 12 40C10.8954 40 10 39.1046 10 38V26C10 24.8954 10.8954 24 12 24Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM12 34C13.1046 34 14 34.8954 14 36V48C14 49.1046 13.1046 50 12 50C10.8954 50 10 49.1046 10 48V36C10 34.8954 10.8954 34 12 34Z + + + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM52 14C53.1046 14 54 14.8954 54 16V28C54 29.1046 53.1046 30 52 30C50.8954 30 50 29.1046 50 28V16C50 14.8954 50.8954 14 52 14Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM52 24C53.1046 24 54 24.8954 54 26V38C54 39.1046 53.1046 40 52 40C50.8954 40 50 39.1046 50 38V26C50 24.8954 50.8954 24 52 24Z + M52.25 8C53.8125 8 55.3021 8.3125 56.7188 8.9375C58.1354 9.5625 59.3854 10.4167 60.4688 11.5C61.5521 12.5833 62.4062 13.8333 63.0312 15.25C63.6562 16.6667 63.9792 18.1667 64 19.75V44.25C64 45.8125 63.6875 47.3021 63.0625 48.7188C62.4375 50.1354 61.5833 51.3854 60.5 52.4688C59.4167 53.5521 58.1667 54.4062 56.75 55.0312C55.3333 55.6562 53.8333 55.9792 52.25 56H11.75C10.1875 56 8.69792 55.6875 7.28125 55.0625C5.86458 54.4375 4.61458 53.5833 3.53125 52.5C2.44792 51.4167 1.59375 50.1667 0.96875 48.75C0.34375 47.3333 0.0208333 45.8333 0 44.25V19.75C0 18.1875 0.3125 16.6979 0.9375 15.2812C1.5625 13.8646 2.41667 12.6146 3.5 11.5312C4.58333 10.4479 5.83333 9.59375 7.25 8.96875C8.66667 8.34375 10.1667 8.02083 11.75 8H52.25ZM11.8438 12C10.8021 12 9.8125 12.2083 8.875 12.625C7.9375 13.0417 7.10417 13.6146 6.375 14.3438C5.64583 15.0729 5.07292 15.9062 4.65625 16.8438C4.23958 17.7812 4.02083 18.7812 4 19.8438V44.1562C4 45.1979 4.20833 46.1875 4.625 47.125C5.04167 48.0625 5.61458 48.8958 6.34375 49.625C7.07292 50.3542 7.90625 50.9271 8.84375 51.3438C9.78125 51.7604 10.7812 51.9792 11.8438 52H52.1562C53.1979 52 54.1875 51.7917 55.125 51.375C56.0625 50.9583 56.8958 50.3854 57.625 49.6562C58.3542 48.9271 58.9271 48.0938 59.3438 47.1562C59.7604 46.2188 59.9792 45.2188 60 44.1562V19.8438C60 18.8021 59.7917 17.8125 59.375 16.875C58.9583 15.9375 58.3854 15.1042 57.6562 14.375C56.9271 13.6458 56.0938 13.0729 55.1562 12.6562C54.2188 12.2396 53.2188 12.0208 52.1562 12H11.8438ZM52 34C53.1046 34 54 34.8954 54 36V48C54 49.1046 53.1046 50 52 50C50.8954 50 50 49.1046 50 48V36C50 34.8954 50.8954 34 52 34Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml.cs new file mode 100644 index 0000000000..75be43af8c --- /dev/null +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Dock/PinToDockDialogContent.xaml.cs @@ -0,0 +1,171 @@ +// 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 Microsoft.CmdPal.UI.ViewModels; +using Microsoft.CmdPal.UI.ViewModels.Dock; +using Microsoft.CmdPal.UI.ViewModels.Settings; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +using Windows.System; +using RS_ = Microsoft.CmdPal.UI.Helpers.ResourceLoaderInstance; + +namespace Microsoft.CmdPal.UI.Dock; + +public sealed partial class PinToDockDialogContent : UserControl +{ + private string _title = string.Empty; + private string _subtitle = string.Empty; + + public DockPinSide SelectedSide => SectionSegmented.SelectedIndex switch + { + 0 => DockPinSide.Start, + 1 => DockPinSide.Center, + 2 => DockPinSide.End, + _ => DockPinSide.Start, + }; + + public bool? ShowTitles => ShowTitleCheckBox.IsChecked; + + public bool? ShowSubtitles => ShowSubtitleCheckBox.IsChecked; + + public PinToDockDialogContent() + { + InitializeComponent(); + } + + public void Configure(string title, string subtitle, IconInfoViewModel? icon, DockSide dockSide) + { + _title = title; + _subtitle = subtitle; + + var hasTitle = !string.IsNullOrEmpty(title); + var hasSubtitle = !string.IsNullOrEmpty(subtitle); + + PreviewTitleText.Text = title; + PreviewTitleText.Visibility = hasTitle ? Visibility.Visible : Visibility.Collapsed; + + PreviewSubtitleText.Text = subtitle; + PreviewSubtitleText.Visibility = hasSubtitle ? Visibility.Visible : Visibility.Collapsed; + + PreviewTextPanel.Visibility = (hasTitle || hasSubtitle) ? Visibility.Visible : Visibility.Collapsed; + + ShowTitleCheckBox.Visibility = hasTitle ? Visibility.Visible : Visibility.Collapsed; + ShowTitleCheckBox.IsChecked = hasTitle; + + ShowSubtitleCheckBox.Visibility = hasSubtitle ? Visibility.Visible : Visibility.Collapsed; + ShowSubtitleCheckBox.IsChecked = hasSubtitle; + + if (icon is not null) + { + PreviewIcon.SourceKey = icon; + } + + ApplyDockOrientation(dockSide); + } + + public static async System.Threading.Tasks.Task<(ContentDialogResult Result, PinToDockDialogContent Content)> ShowAsync( + XamlRoot xamlRoot, + string title, + string subtitle, + IconInfoViewModel? icon, + DockSide dockSide) + { + var content = new PinToDockDialogContent(); + content.Configure(title, subtitle, icon, dockSide); + + var dialog = new ContentDialog + { + Title = RS_.GetString("PinToDock_DialogTitle"), + Content = content, + PrimaryButtonText = RS_.GetString("PinToDock_PinButton"), + CloseButtonText = RS_.GetString("PinToDock_CancelButton"), + DefaultButton = ContentDialogButton.Primary, + XamlRoot = xamlRoot, + }; + + // Inner controls (Segmented, CheckBox) may consume the Enter key event, + // preventing DefaultButton from activating. Handle it explicitly. + var enterPressed = false; + dialog.AddHandler( + UIElement.KeyDownEvent, + new KeyEventHandler((s, e) => + { + if (e.Key == VirtualKey.Enter) + { + enterPressed = true; + dialog.Hide(); + } + }), + true); + + var result = await dialog.ShowAsync(); + + if (result == ContentDialogResult.None && enterPressed) + { + result = ContentDialogResult.Primary; + } + + return (result, content); + } + + private void ApplyDockOrientation(DockSide dockSide) + { + var isVertical = dockSide is DockSide.Left or DockSide.Right; + + if (isVertical) + { + StartSegmentedItem.Content = RS_.GetString("PinToDock_Top"); + CenterSegmentedItem.Content = RS_.GetString("PinToDock_CenterLabel"); + EndSegmentedItem.Content = RS_.GetString("PinToDock_Bottom"); + } + else + { + StartSegmentedItem.Content = RS_.GetString("PinToDock_Left"); + CenterSegmentedItem.Content = RS_.GetString("PinToDock_CenterLabel"); + EndSegmentedItem.Content = RS_.GetString("PinToDock_RightLabel"); + } + + // Pick the 3 icon path strings based on dock orientation + var (startKey, centerKey, endKey) = dockSide switch + { + DockSide.Top => ("TopStartPath", "TopCenterPath", "TopEndPath"), + DockSide.Bottom => ("BottomStartPath", "BottomCenterPath", "BottomEndPath"), + DockSide.Left => ("LeftStartPath", "LeftCenterPath", "LeftEndPath"), + DockSide.Right => ("RightStartPath", "RightCenterPath", "RightEndPath"), + _ => ("TopStartPath", "TopCenterPath", "TopEndPath"), + }; + + StartSegmentedItem.Icon = CreatePathIcon((string)Resources[startKey]); + CenterSegmentedItem.Icon = CreatePathIcon((string)Resources[centerKey]); + EndSegmentedItem.Icon = CreatePathIcon((string)Resources[endKey]); + } + + private static PathIcon CreatePathIcon(string pathData) + { + var geometry = (Microsoft.UI.Xaml.Media.Geometry)Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue( + typeof(Microsoft.UI.Xaml.Media.Geometry), pathData); + return new PathIcon { Data = geometry }; + } + + private void OnLabelOptionChanged(object sender, RoutedEventArgs e) + { + if (PreviewTitleText is null || PreviewSubtitleText is null || + PreviewTextPanel is null || ShowTitleCheckBox is null || ShowSubtitleCheckBox is null) + { + return; + } + + var showTitle = ShowTitleCheckBox.IsChecked == true; + var showSubtitle = ShowSubtitleCheckBox.IsChecked == true; + + PreviewTitleText.Text = showTitle ? _title : string.Empty; + PreviewTitleText.Visibility = showTitle ? Visibility.Visible : Visibility.Collapsed; + + PreviewSubtitleText.Text = showSubtitle ? _subtitle : string.Empty; + PreviewSubtitleText.Visibility = showSubtitle ? Visibility.Visible : Visibility.Collapsed; + + PreviewTextPanel.Visibility = (showTitle || showSubtitle) ? Visibility.Visible : Visibility.Collapsed; + } +} diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml index ee11551c5a..e2eb64d38c 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/MainWindow.xaml @@ -10,8 +10,8 @@ xmlns:winuiex="using:WinUIEx" Width="800" Height="480" - MinWidth="320" - MinHeight="240" + MinWidth="640" + MinHeight="420" Activated="MainWindow_Activated" Closed="MainWindow_Closed" mc:Ignorable="d"> diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj index 2e54f58abd..38399d0fa1 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Microsoft.CmdPal.UI.csproj @@ -105,6 +105,7 @@ + diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs index 6565b8438b..9ee05c2402 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Pages/ShellPage.xaml.cs @@ -51,6 +51,7 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page, IRecipient, IRecipient, IRecipient, + IRecipient, INotifyPropertyChanged, IDisposable { @@ -102,6 +103,7 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page, WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); + WeakReferenceMessenger.Default.Register(this); AddHandler(PreviewKeyDownEvent, new KeyEventHandler(ShellPage_OnPreviewKeyDown), true); AddHandler(KeyDownEvent, new KeyEventHandler(ShellPage_OnKeyDown), false); @@ -210,6 +212,43 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page, }); } + public void Receive(ShowPinToDockDialogMessage message) + { + DispatcherQueue.TryEnqueue(async () => + { + try + { + await HandlePinToDockDialogOnUiThread(message); + } + catch (Exception ex) + { + Logger.LogError(ex.ToString()); + } + }); + } + + private async Task HandlePinToDockDialogOnUiThread(ShowPinToDockDialogMessage message) + { + var (result, content) = await PinToDockDialogContent.ShowAsync( + this.XamlRoot, + message.Title, + message.Subtitle, + message.Icon, + message.DockSide); + + if (result == ContentDialogResult.Primary) + { + var pinMessage = new PinToDockMessage( + message.ProviderId, + message.CommandId, + Pin: true, + Side: content.SelectedSide, + ShowTitles: content.ShowTitles, + ShowSubtitles: content.ShowSubtitles); + WeakReferenceMessenger.Default.Send(pinMessage); + } + } + // This gets called from the UI thread private async Task HandleConfirmArgsOnUiThread(IConfirmationArgs? args) { diff --git a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw index bc218e8886..8b7323857e 100644 --- a/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw +++ b/src/modules/cmdpal/Microsoft.CmdPal.UI/Strings/en-us/Resources.resw @@ -989,4 +989,68 @@ Right-click to remove the key combination, thereby deactivating the shortcut.NEW Must be all caps + + Pin to Dock + Title for the pin to dock configuration dialog + + + Preview + Header for the preview section in the pin to dock dialog + + + Choose where to pin this command + Header for the dock section selector in the pin to dock dialog + + + Start + Start section option in pin to dock dialog + + + Center + Center section option in pin to dock dialog + + + End + End section option in pin to dock dialog + + + Show title + Checkbox label to show the title of a pinned dock item + + + Show subtitle + Checkbox label to show the subtitle of a pinned dock item + + + Pin + Button text to confirm pinning an item to the dock + + + Cancel + Button text to cancel pinning an item to the dock + + + Left + Left section option in pin to dock dialog (horizontal dock) + + + Right + Right section option in pin to dock dialog (horizontal dock) + + + Top + Top section option in pin to dock dialog (vertical dock) + + + Bottom + Bottom section option in pin to dock dialog (vertical dock) + + + Center + Center section label in pin to dock dialog (code access) + + + Right + Right section label in pin to dock dialog (code access, horizontal end) + \ No newline at end of file