hotkey fix & contextmenu
This commit is contained in:
@@ -13,7 +13,8 @@
|
||||
Title="Minecraft Modpack Manager"
|
||||
WindowState="Maximized"
|
||||
Loaded="Window_OnLoaded"
|
||||
Closed="Window_OnClosed">
|
||||
Closed="Window_OnClosed"
|
||||
KeyDown="Window_OnKeyDown">
|
||||
|
||||
<Grid
|
||||
x:Name="GridMain"
|
||||
@@ -174,6 +175,10 @@
|
||||
ItemsSource="{Binding CurrentGridRows}"
|
||||
SelectedItem="{Binding SelectedGridRow}">
|
||||
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu x:Name="ContextMenuActions"/>
|
||||
</DataGrid.ContextMenu>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Header="{x:Static langRes:GeneralLangRes.Id}"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using ModpackUpdater.Apps.Manager.Api;
|
||||
@@ -50,10 +51,14 @@ public partial class MainWindow : Window, IMainApi
|
||||
ImageSource.Source = AppGlobals.Symbols.GetImageSource(AppSymbols.input);
|
||||
ImageDestination.Source = AppGlobals.Symbols.GetImageSource(AppSymbols.output);
|
||||
|
||||
PluginFeatureController.Instance.Features.Get(FeatureTypes.Workspace).InsertItemsTo(MenuItemNewWorkspace.Items,
|
||||
PluginFeatureController.Instance.Features.Get(FeatureTypes.Workspace).Ordered().InsertItemsTo(MenuItemNewWorkspace.Items,
|
||||
customClickHandler: MenuItemNewWorkspaceItem_Click,
|
||||
insertPrioSplitters: true);
|
||||
|
||||
PluginFeatureController.Instance.Features.Get(FeatureTypes.ActionsContextMenu).Ordered().InsertItemsTo(ContextMenuActions.Items,
|
||||
customClickHandler: MenuItemActionItem_Click,
|
||||
insertPrioSplitters: true);
|
||||
|
||||
var menuFlyoutTools = new MenuFlyout();
|
||||
ButtonTools.Flyout = menuFlyoutTools;
|
||||
PluginFeatureController.Instance.Functions.Get(FeatureTypes.Tools).InsertItemsTo(menuFlyoutTools.Items,
|
||||
@@ -79,6 +84,16 @@ public partial class MainWindow : Window, IMainApi
|
||||
LoadRecentWorkspaces();
|
||||
}
|
||||
|
||||
private async Task SaveWorkspace()
|
||||
{
|
||||
if (Model.CurrentWorkspace is not { } ws)
|
||||
return;
|
||||
|
||||
Model.Progress.Start();
|
||||
await ws.Save();
|
||||
Model.Progress.End();
|
||||
}
|
||||
|
||||
private void LoadRecentWorkspaces()
|
||||
{
|
||||
var settings = Program.Settings.Get<WorkspaceSettings>();
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user