diff --git a/WinUIGallery/App.xaml.cs b/WinUIGallery/App.xaml.cs index ff37e96ce..6faf0081c 100644 --- a/WinUIGallery/App.xaml.cs +++ b/WinUIGallery/App.xaml.cs @@ -140,6 +140,24 @@ private async void EnsureWindow() targetPageType = typeof(ItemPage); } } + // Handle JumpList launch arguments (passed as command-line args) + else if (eventArgs != null && + eventArgs.Kind == ExtendedActivationKind.Launch && + eventArgs.Data is ILaunchActivatedEventArgs launchArgs && + !string.IsNullOrEmpty(launchArgs.Arguments)) + { + string arg = launchArgs.Arguments.Trim(); + targetPageArguments = arg; + + if (ControlInfoDataSource.Instance.Groups.Any(g => g.UniqueId == arg)) + { + targetPageType = typeof(SectionPage); + } + else if (ControlInfoDataSource.Instance.Groups.Any(g => g.Items.Any(i => i.UniqueId == arg))) + { + targetPageType = typeof(ItemPage); + } + } MainWindow.Navigate(targetPageType, targetPageArguments); @@ -149,6 +167,9 @@ private async void EnsureWindow() navItem.IsSelected = true; } + // Initialize the taskbar JumpList with fixed tasks and favorites. + await JumpListHelper.UpdateJumpListAsync(); + // Activate the startup window. MainWindow.Activate(); } diff --git a/WinUIGallery/Assets/ControlImages/JumpList.png b/WinUIGallery/Assets/ControlImages/JumpList.png new file mode 100644 index 000000000..6fdc534a6 Binary files /dev/null and b/WinUIGallery/Assets/ControlImages/JumpList.png differ diff --git a/WinUIGallery/Controls/PageHeader.xaml b/WinUIGallery/Controls/PageHeader.xaml index 705d3e193..654af6aa6 100644 --- a/WinUIGallery/Controls/PageHeader.xaml +++ b/WinUIGallery/Controls/PageHeader.xaml @@ -7,9 +7,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="using:CommunityToolkit.WinUI.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:models="using:WinUIGallery.Models" xmlns:local="using:WinUIGallery.Controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:models="using:WinUIGallery.Models" Loaded="UserControl_Loaded" mc:Ignorable="d"> @@ -34,11 +34,11 @@ + TextWrapping="NoWrap" /> - + - + diff --git a/WinUIGallery/Controls/PageHeader.xaml.cs b/WinUIGallery/Controls/PageHeader.xaml.cs index 57297eb7d..ff22544da 100644 --- a/WinUIGallery/Controls/PageHeader.xaml.cs +++ b/WinUIGallery/Controls/PageHeader.xaml.cs @@ -53,11 +53,13 @@ public void SetControlSourceLink(string BaseUri, string SourceLink) if (!string.IsNullOrEmpty(SourceLink)) { ControlSourcePanel.Visibility = Visibility.Visible; + ControlSourceSeparator.Visibility = Visibility.Visible; ControlSourceLink.NavigateUri = new Uri(BaseUri + SourceLink); } else { ControlSourcePanel.Visibility = Visibility.Collapsed; + ControlSourceSeparator.Visibility = Visibility.Collapsed; } } diff --git a/WinUIGallery/Helpers/JumpListHelper.cs b/WinUIGallery/Helpers/JumpListHelper.cs new file mode 100644 index 000000000..6daaca17f --- /dev/null +++ b/WinUIGallery/Helpers/JumpListHelper.cs @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Windows.UI.StartScreen; +using WinUIGallery.Models; + +namespace WinUIGallery.Helpers; + +/// +/// Manages the app's taskbar JumpList, providing quick access to +/// recently visited items and user-favorited items. +/// +internal static class JumpListHelper +{ + /// + /// Rebuilds the JumpList with recently visited items and the current set of favorite items. + /// Safe to call at any time; silently returns if JumpList is not supported. + /// + public static async Task UpdateJumpListAsync() + { + if (!NativeMethods.IsAppPackaged || !JumpList.IsSupported()) + { + return; + } + + try + { + JumpList jumpList = await JumpList.LoadCurrentAsync(); + jumpList.Items.Clear(); + jumpList.SystemGroupKind = JumpListSystemGroupKind.None; + + // Dynamic group: Recent + var recentlyVisited = SettingsHelper.Current.RecentlyVisited; + foreach (string uniqueId in recentlyVisited) + { + AddItemTask(jumpList, uniqueId, groupName: "Recent"); + } + + // Dynamic group: Favorites + var favorites = SettingsHelper.Current.Favorites; + foreach (string uniqueId in favorites) + { + AddItemTask(jumpList, uniqueId, groupName: "Favorites"); + } + + await jumpList.SaveAsync(); + } + catch + { + // JumpList updates are best-effort; don't crash the app. + } + } + + private static void AddItemTask(JumpList jumpList, string uniqueId, string groupName) + { + ControlInfoDataItem? item = ControlInfoDataSource.Instance.Groups + .SelectMany(g => g.Items) + .FirstOrDefault(i => i.UniqueId == uniqueId); + + if (item == null) + { + return; + } + + JumpListItem task = JumpListItem.CreateWithArguments(uniqueId, item.Title); + task.GroupName = groupName; + task.Description = "Go to " + item.Title; + task.Logo = new Uri(item.ImagePath); + jumpList.Items.Add(task); + } +} \ No newline at end of file diff --git a/WinUIGallery/Helpers/SettingsHelper/SettingsHelper.cs b/WinUIGallery/Helpers/SettingsHelper/SettingsHelper.cs index 7e432895e..abb8b8a40 100644 --- a/WinUIGallery/Helpers/SettingsHelper/SettingsHelper.cs +++ b/WinUIGallery/Helpers/SettingsHelper/SettingsHelper.cs @@ -56,11 +56,13 @@ public void UpdateFavorites(Action> updater) var list = Favorites; updater(list); Favorites = list; + _ = JumpListHelper.UpdateJumpListAsync(); } public void UpdateRecentlyVisited(Action> updater) { var list = RecentlyVisited; updater(list); RecentlyVisited = list; + _ = JumpListHelper.UpdateJumpListAsync(); } } diff --git a/WinUIGallery/Samples/ControlPages/JumpListPage.xaml b/WinUIGallery/Samples/ControlPages/JumpListPage.xaml new file mode 100644 index 000000000..b4fa0b4d9 --- /dev/null +++ b/WinUIGallery/Samples/ControlPages/JumpListPage.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + +