[CmdPal Dock] New pin UX (#46436)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## 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)


<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #46433
<!-- - [ ] Closes: #yyy (add separate lines for additional resolved
issues) -->
- [ ] **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

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
This commit is contained in:
Niels Laute
2026-03-24 21:19:28 +01:00
committed by GitHub
parent 79d9b0e667
commit 3d2f069c43
11 changed files with 457 additions and 9 deletions

View File

@@ -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<ISettingsService>(); var settingsService = serviceProvider.GetRequiredService<ISettingsService>();
var settings = settingsService.Settings; var settings = settingsService.Settings;
@@ -444,8 +444,23 @@ public sealed class CommandProviderWrapper : ICommandProviderContext
{ {
CommandId = commandId, CommandId = commandId,
ProviderId = this.ProviderId, 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 // Raise CommandsChanged so the TopLevelCommandManager reloads our commands
this.CommandsChanged?.Invoke(this, new ItemsChangedEventArgs(-1)); this.CommandsChanged?.Invoke(this, new ItemsChangedEventArgs(-1));

View File

@@ -2,6 +2,14 @@
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using Microsoft.CmdPal.UI.ViewModels.Dock;
namespace Microsoft.CmdPal.UI.ViewModels.Messages; 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);

View File

@@ -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);

View File

@@ -707,7 +707,7 @@ public sealed partial class TopLevelCommandManager : ObservableObject,
{ {
if (message.Pin) if (message.Pin)
{ {
wrapper?.PinDockBand(message.CommandId, _serviceProvider); wrapper?.PinDockBand(message.CommandId, _serviceProvider, message.Side, message.ShowTitles, message.ShowSubtitles);
} }
else else
{ {

View File

@@ -198,7 +198,8 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
pin: !alreadyPinned, pin: !alreadyPinned,
PinLocation.Dock, PinLocation.Dock,
_settingsService, _settingsService,
_topLevelCommandManager); _topLevelCommandManager,
commandItemViewModel: commandItem);
var contextItem = new PinToContextItem(pinToTopLevelCommand, commandItem); var contextItem = new PinToContextItem(pinToTopLevelCommand, commandItem);
moreCommands.Add(contextItem); moreCommands.Add(contextItem);
@@ -249,6 +250,7 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
private readonly TopLevelCommandManager _topLevelCommandManager; private readonly TopLevelCommandManager _topLevelCommandManager;
private readonly bool _pin; private readonly bool _pin;
private readonly PinLocation _pinLocation; private readonly PinLocation _pinLocation;
private readonly CommandItemViewModel? _commandItemViewModel;
private bool IsPinToDock => _pinLocation == PinLocation.Dock; private bool IsPinToDock => _pinLocation == PinLocation.Dock;
@@ -266,7 +268,8 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
bool pin, bool pin,
PinLocation pinLocation, PinLocation pinLocation,
ISettingsService settingsService, ISettingsService settingsService,
TopLevelCommandManager topLevelCommandManager) TopLevelCommandManager topLevelCommandManager,
CommandItemViewModel? commandItemViewModel = null)
{ {
_commandId = commandId; _commandId = commandId;
_providerId = providerId; _providerId = providerId;
@@ -274,6 +277,7 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
_settingsService = settingsService; _settingsService = settingsService;
_topLevelCommandManager = topLevelCommandManager; _topLevelCommandManager = topLevelCommandManager;
_pin = pin; _pin = pin;
_commandItemViewModel = commandItemViewModel;
} }
public override CommandResult Invoke() public override CommandResult Invoke()
@@ -325,7 +329,11 @@ internal sealed partial class CommandPaletteContextMenuFactory : IContextMenuFac
private void PinToDock() 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); WeakReferenceMessenger.Default.Send(message);
} }

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8" ?>
<UserControl
x:Class="Microsoft.CmdPal.UI.Dock.PinToDockDialogContent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cpcontrols="using:Microsoft.CmdPal.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:help="using:Microsoft.CmdPal.UI.Helpers"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.Segmented/Segmented/Segmented.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Top dock: horizontal bar at top (left/center/right) -->
<x:String x:Key="TopStartPath">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</x:String>
<x:String x:Key="TopCenterPath">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</x:String>
<x:String x:Key="TopEndPath">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</x:String>
<!-- Bottom dock: horizontal bar at bottom (left/center/right) -->
<x:String x:Key="BottomStartPath">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</x:String>
<x:String x:Key="BottomCenterPath">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</x:String>
<x:String x:Key="BottomEndPath">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</x:String>
<!-- Left dock: vertical bar at left (top/center/bottom) -->
<x:String x:Key="LeftStartPath">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</x:String>
<x:String x:Key="LeftCenterPath">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</x:String>
<x:String x:Key="LeftEndPath">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</x:String>
<!-- Right dock: vertical bar at right (top/center/bottom) -->
<x:String x:Key="RightStartPath">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</x:String>
<x:String x:Key="RightCenterPath">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</x:String>
<x:String x:Key="RightEndPath">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</x:String>
</ResourceDictionary>
</UserControl.Resources>
<ScrollViewer>
<StackPanel Width="420" Spacing="16">
<!-- Preview -->
<StackPanel Spacing="8">
<Border
Padding="12,8"
HorizontalAlignment="Left"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="{ThemeResource ControlCornerRadius}">
<Grid ColumnSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Icon -->
<cpcontrols:IconBox
x:Name="PreviewIcon"
Width="16"
Height="16"
VerticalAlignment="Center"
SourceRequested="{x:Bind help:IconCacheProvider.SourceRequested20}" />
<!-- Text -->
<StackPanel
x:Name="PreviewTextPanel"
Grid.Column="1"
Margin="8,0,0,0"
VerticalAlignment="Center">
<TextBlock
x:Name="PreviewTitleText"
FontSize="12"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
<TextBlock
x:Name="PreviewSubtitleText"
FontSize="10"
Foreground="{ThemeResource TextFillColorTertiary}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap" />
</StackPanel>
</Grid>
</Border>
</StackPanel>
<Rectangle
Height="1"
Margin="-24,0,-24,0"
HorizontalAlignment="Stretch"
Fill="{ThemeResource DividerStrokeColorDefaultBrush}" />
<!-- Dock Section Selector -->
<StackPanel Spacing="8">
<TextBlock
x:Uid="PinToDock_SectionHeader"
FontWeight="SemiBold"
Foreground="{ThemeResource TextFillColorSecondaryBrush}" />
<tkcontrols:Segmented
x:Name="SectionSegmented"
HorizontalAlignment="Stretch"
SelectedIndex="0"
SelectionMode="Single">
<tkcontrols:SegmentedItem x:Name="StartSegmentedItem" x:Uid="PinToDock_Start" />
<tkcontrols:SegmentedItem x:Name="CenterSegmentedItem" x:Uid="PinToDock_Center" />
<tkcontrols:SegmentedItem x:Name="EndSegmentedItem" x:Uid="PinToDock_End" />
</tkcontrols:Segmented>
</StackPanel>
<!-- Label Options -->
<StackPanel Spacing="4">
<CheckBox
x:Name="ShowTitleCheckBox"
x:Uid="PinToDock_ShowTitle"
Checked="OnLabelOptionChanged"
IsChecked="True"
Unchecked="OnLabelOptionChanged" />
<CheckBox
x:Name="ShowSubtitleCheckBox"
x:Uid="PinToDock_ShowSubtitle"
Checked="OnLabelOptionChanged"
IsChecked="True"
Unchecked="OnLabelOptionChanged" />
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>

View File

@@ -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;
}
}

View File

@@ -10,8 +10,8 @@
xmlns:winuiex="using:WinUIEx" xmlns:winuiex="using:WinUIEx"
Width="800" Width="800"
Height="480" Height="480"
MinWidth="320" MinWidth="640"
MinHeight="240" MinHeight="420"
Activated="MainWindow_Activated" Activated="MainWindow_Activated"
Closed="MainWindow_Closed" Closed="MainWindow_Closed"
mc:Ignorable="d"> mc:Ignorable="d">

View File

@@ -105,6 +105,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" /> <PackageReference Include="CommunityToolkit.WinUI.Controls.Primitives" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.Segmented" />
<PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" /> <PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" />
<PackageReference Include="CommunityToolkit.WinUI.Converters" /> <PackageReference Include="CommunityToolkit.WinUI.Converters" />
<PackageReference Include="CommunityToolkit.WinUI.Animations" /> <PackageReference Include="CommunityToolkit.WinUI.Animations" />

View File

@@ -51,6 +51,7 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
IRecipient<ShowToastMessage>, IRecipient<ShowToastMessage>,
IRecipient<NavigateToPageMessage>, IRecipient<NavigateToPageMessage>,
IRecipient<ShowHideDockMessage>, IRecipient<ShowHideDockMessage>,
IRecipient<ShowPinToDockDialogMessage>,
INotifyPropertyChanged, INotifyPropertyChanged,
IDisposable IDisposable
{ {
@@ -102,6 +103,7 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
WeakReferenceMessenger.Default.Register<NavigateToPageMessage>(this); WeakReferenceMessenger.Default.Register<NavigateToPageMessage>(this);
WeakReferenceMessenger.Default.Register<ShowHideDockMessage>(this); WeakReferenceMessenger.Default.Register<ShowHideDockMessage>(this);
WeakReferenceMessenger.Default.Register<ShowPinToDockDialogMessage>(this);
AddHandler(PreviewKeyDownEvent, new KeyEventHandler(ShellPage_OnPreviewKeyDown), true); AddHandler(PreviewKeyDownEvent, new KeyEventHandler(ShellPage_OnPreviewKeyDown), true);
AddHandler(KeyDownEvent, new KeyEventHandler(ShellPage_OnKeyDown), false); 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 // This gets called from the UI thread
private async Task HandleConfirmArgsOnUiThread(IConfirmationArgs? args) private async Task HandleConfirmArgsOnUiThread(IConfirmationArgs? args)
{ {

View File

@@ -989,4 +989,68 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<value>NEW</value> <value>NEW</value>
<comment>Must be all caps</comment> <comment>Must be all caps</comment>
</data> </data>
<data name="PinToDock_DialogTitle" xml:space="preserve">
<value>Pin to Dock</value>
<comment>Title for the pin to dock configuration dialog</comment>
</data>
<data name="PinToDock_PreviewHeader.Text" xml:space="preserve">
<value>Preview</value>
<comment>Header for the preview section in the pin to dock dialog</comment>
</data>
<data name="PinToDock_SectionHeader.Text" xml:space="preserve">
<value>Choose where to pin this command</value>
<comment>Header for the dock section selector in the pin to dock dialog</comment>
</data>
<data name="PinToDock_Start.Content" xml:space="preserve">
<value>Start</value>
<comment>Start section option in pin to dock dialog</comment>
</data>
<data name="PinToDock_Center.Content" xml:space="preserve">
<value>Center</value>
<comment>Center section option in pin to dock dialog</comment>
</data>
<data name="PinToDock_End.Content" xml:space="preserve">
<value>End</value>
<comment>End section option in pin to dock dialog</comment>
</data>
<data name="PinToDock_ShowTitle.Content" xml:space="preserve">
<value>Show title</value>
<comment>Checkbox label to show the title of a pinned dock item</comment>
</data>
<data name="PinToDock_ShowSubtitle.Content" xml:space="preserve">
<value>Show subtitle</value>
<comment>Checkbox label to show the subtitle of a pinned dock item</comment>
</data>
<data name="PinToDock_PinButton" xml:space="preserve">
<value>Pin</value>
<comment>Button text to confirm pinning an item to the dock</comment>
</data>
<data name="PinToDock_CancelButton" xml:space="preserve">
<value>Cancel</value>
<comment>Button text to cancel pinning an item to the dock</comment>
</data>
<data name="PinToDock_Left" xml:space="preserve">
<value>Left</value>
<comment>Left section option in pin to dock dialog (horizontal dock)</comment>
</data>
<data name="PinToDock_Right" xml:space="preserve">
<value>Right</value>
<comment>Right section option in pin to dock dialog (horizontal dock)</comment>
</data>
<data name="PinToDock_Top" xml:space="preserve">
<value>Top</value>
<comment>Top section option in pin to dock dialog (vertical dock)</comment>
</data>
<data name="PinToDock_Bottom" xml:space="preserve">
<value>Bottom</value>
<comment>Bottom section option in pin to dock dialog (vertical dock)</comment>
</data>
<data name="PinToDock_CenterLabel" xml:space="preserve">
<value>Center</value>
<comment>Center section label in pin to dock dialog (code access)</comment>
</data>
<data name="PinToDock_RightLabel" xml:space="preserve">
<value>Right</value>
<comment>Right section label in pin to dock dialog (code access, horizontal end)</comment>
</data>
</root> </root>