From ada6f59434afb42b2a13ac0d4b1e6a2cea576354 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Mon, 17 Nov 2025 18:25:21 +0100 Subject: [PATCH] hotkey fix & contextmenu --- .../Ui/MainWindow.axaml | 9 ++++- .../Ui/MainWindow.axaml.cs | 40 ++++++++++++++----- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml index 380c1a1..ef76614 100644 --- a/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml +++ b/ModpackUpdater.Apps.Manager/Ui/MainWindow.axaml @@ -13,8 +13,9 @@ Title="Minecraft Modpack Manager" WindowState="Maximized" Loaded="Window_OnLoaded" - Closed="Window_OnClosed"> - + Closed="Window_OnClosed" + KeyDown="Window_OnKeyDown"> + + + + + (); @@ -121,6 +136,12 @@ public partial class MainWindow : Window, IMainApi HasClosed = true; } + private async void Window_OnKeyDown(object? sender, KeyEventArgs e) + { + if (e.KeyModifiers == KeyModifiers.Control && e.Key == Key.Space) + await SaveWorkspace(); + } + private async void MenuItemNewWorkspaceItem_Click(object? sender, RoutedEventArgs e) { if (sender is not MenuItem item || item.Tag is not WorkspaceFeature feature) @@ -145,12 +166,7 @@ public partial class MainWindow : Window, IMainApi private async void MenuItemSaveWorkspace_OnClick(object? sender, RoutedEventArgs e) { - if (Model.CurrentWorkspace is not { } ws) - return; - - Model.Progress.Start(); - await ws.Save(); - Model.Progress.End(); + await SaveWorkspace(); } private async void MenuItemRecentWorkspaceItem_Click(object? sender, RoutedEventArgs e) @@ -159,10 +175,16 @@ public partial class MainWindow : Window, IMainApi await LoadNewWorkspace(workspace, tag.Feature); } - private void MenuItemToolsItem_Click(object? sender, RoutedEventArgs e) + private async void MenuItemToolsItem_Click(object? sender, RoutedEventArgs e) { if (sender is MenuItem item && item.Tag is PluginFunction func) - func.ExecuteAsync(new MainApiParameters(this)); + await func.ExecuteAsync(new MainApiParameters(this)); + } + + private async void MenuItemActionItem_Click(object? sender, RoutedEventArgs e) + { + if (sender is MenuItem item && item.Tag is PluginFunction func) + await func.ExecuteAsync(new MainApiParameters(this)); } private void MenuItemCreateUpdate_OnClick(object? sender, RoutedEventArgs e)