diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 282263e..813cc57 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -107,6 +107,12 @@ public partial class MainWindow : Window var duplicateMenuItem = new System.Windows.Controls.MenuItem { Header = "Duplicate Item" }; duplicateMenuItem.Click += DuplicateItem_Click; + var sortMenuItem = new System.Windows.Controls.MenuItem + { + Header = item.Type == LauncherItemType.Menu ? "Sort This Menu" : "Sort This Level" + }; + sortMenuItem.Click += SortSelected_Click; + var treeItem = new TreeViewItem { Header = $"{GetTreeStatusPrefix(item)}{item.Title} ({item.Type})", @@ -117,6 +123,7 @@ public partial class MainWindow : Window treeItem.ContextMenu.Items.Add(disableMenuItem); treeItem.ContextMenu.Items.Add(openContainingFolderMenuItem); treeItem.ContextMenu.Items.Add(duplicateMenuItem); + treeItem.ContextMenu.Items.Add(sortMenuItem); treeItem.PreviewMouseRightButtonDown += (_, e) => { treeItem.IsSelected = true; @@ -1046,6 +1053,46 @@ public partial class MainWindow : Window RefreshView(selectedItem); } + private void SortSelected_Click(object sender, RoutedEventArgs e) + { + if (controller is null || selectedItem is null) + { + return; + } + + ApplyCurrentItem(); + LauncherItem itemToSelect = selectedItem; + if (selectedItem.Type == LauncherItemType.Menu) + { + SortItems(selectedItem.Children); + RefreshView(itemToSelect); + StatusText.Text = $"Sorted {itemToSelect.Title}. Click Save to keep it."; + return; + } + + List? siblings = FindSiblings(controller.Config.Items, selectedItem); + if (siblings is null) + { + return; + } + + SortItems(siblings); + RefreshView(itemToSelect); + StatusText.Text = $"Sorted this level. Click Save to keep it."; + } + + private static void SortItems(List items) + { + List sortedItems = items + .OrderByDescending(item => item.IsFavorite) + .ThenBy(item => item.Title, StringComparer.CurrentCultureIgnoreCase) + .ThenBy(item => item.Type) + .ToList(); + + items.Clear(); + items.AddRange(sortedItems); + } + private static bool RemoveItem(List items, LauncherItem item) { if (items.Remove(item)) diff --git a/README.md b/README.md index 567f07e..522c6c3 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Download the compiled Windows release from: - Right-click app/file entries to open their containing folder - Validate missing app, file, and folder targets from Settings - Export and import selected items or menu sections +- Sort a selected menu or item level alphabetically - Right-click item duplication in Settings - Right-click items in Settings to pin them to the top of their menu - Per-item icon and display mode diff --git a/TaskbarLauncher.csproj b/TaskbarLauncher.csproj index ec5a926..4a236ed 100644 --- a/TaskbarLauncher.csproj +++ b/TaskbarLauncher.csproj @@ -12,8 +12,8 @@ Ray Berezowski Assets\AppIcon.ico 1.0.1 - 1.0.1.12 - 1.0.1.12 + 1.0.1.13 + 1.0.1.13 1.0.1 diff --git a/docs/INSTALL.md b/docs/INSTALL.md index a522c7e..7c20ec7 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -43,6 +43,7 @@ From Settings you can: - Right-click an app or file item and choose **Open Containing Folder** - Use **Config... > Validate Targets** to check for missing app, file, and folder targets - Use **Config... > Export Selected Item** or **Import Item** to share one item or menu section +- Right-click an item and choose **Sort This Menu** or **Sort This Level** - Set per-item icon sizes - Back up and restore `config.json` - Enable Start with Windows