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