Add menu sort action

This commit is contained in:
Ray Berezowski
2026-08-26 21:41:45 -04:00
parent 86f667f595
commit 03417e6d99
4 changed files with 51 additions and 2 deletions

View File

@@ -107,6 +107,12 @@ public partial class MainWindow : Window
var duplicateMenuItem = new System.Windows.Controls.MenuItem { Header = "Duplicate Item" }; var duplicateMenuItem = new System.Windows.Controls.MenuItem { Header = "Duplicate Item" };
duplicateMenuItem.Click += DuplicateItem_Click; 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 var treeItem = new TreeViewItem
{ {
Header = $"{GetTreeStatusPrefix(item)}{item.Title} ({item.Type})", 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(disableMenuItem);
treeItem.ContextMenu.Items.Add(openContainingFolderMenuItem); treeItem.ContextMenu.Items.Add(openContainingFolderMenuItem);
treeItem.ContextMenu.Items.Add(duplicateMenuItem); treeItem.ContextMenu.Items.Add(duplicateMenuItem);
treeItem.ContextMenu.Items.Add(sortMenuItem);
treeItem.PreviewMouseRightButtonDown += (_, e) => treeItem.PreviewMouseRightButtonDown += (_, e) =>
{ {
treeItem.IsSelected = true; treeItem.IsSelected = true;
@@ -1046,6 +1053,46 @@ public partial class MainWindow : Window
RefreshView(selectedItem); 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<LauncherItem>? 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<LauncherItem> items)
{
List<LauncherItem> 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<LauncherItem> items, LauncherItem item) private static bool RemoveItem(List<LauncherItem> items, LauncherItem item)
{ {
if (items.Remove(item)) if (items.Remove(item))

View File

@@ -21,6 +21,7 @@ Download the compiled Windows release from:
- Right-click app/file entries to open their containing folder - Right-click app/file entries to open their containing folder
- Validate missing app, file, and folder targets from Settings - Validate missing app, file, and folder targets from Settings
- Export and import selected items or menu sections - Export and import selected items or menu sections
- Sort a selected menu or item level alphabetically
- Right-click item duplication in Settings - Right-click item duplication in Settings
- Right-click items in Settings to pin them to the top of their menu - Right-click items in Settings to pin them to the top of their menu
- Per-item icon and display mode - Per-item icon and display mode

View File

@@ -12,8 +12,8 @@
<Authors>Ray Berezowski</Authors> <Authors>Ray Berezowski</Authors>
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon> <ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
<Version>1.0.1</Version> <Version>1.0.1</Version>
<AssemblyVersion>1.0.1.12</AssemblyVersion> <AssemblyVersion>1.0.1.13</AssemblyVersion>
<FileVersion>1.0.1.12</FileVersion> <FileVersion>1.0.1.13</FileVersion>
<InformationalVersion>1.0.1</InformationalVersion> <InformationalVersion>1.0.1</InformationalVersion>
</PropertyGroup> </PropertyGroup>

View File

@@ -43,6 +43,7 @@ From Settings you can:
- Right-click an app or file item and choose **Open Containing Folder** - 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... > 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 - 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 - Set per-item icon sizes
- Back up and restore `config.json` - Back up and restore `config.json`
- Enable Start with Windows - Enable Start with Windows