Add menu sort action
This commit is contained in:
@@ -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<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)
|
||||
{
|
||||
if (items.Remove(item))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<Authors>Ray Berezowski</Authors>
|
||||
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
|
||||
<Version>1.0.1</Version>
|
||||
<AssemblyVersion>1.0.1.12</AssemblyVersion>
|
||||
<FileVersion>1.0.1.12</FileVersion>
|
||||
<AssemblyVersion>1.0.1.13</AssemblyVersion>
|
||||
<FileVersion>1.0.1.13</FileVersion>
|
||||
<InformationalVersion>1.0.1</InformationalVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user