[TUI] Add Main Help dialog with F1 shortcut and Ok command

This commit is contained in:
2025-10-16 21:14:27 +01:00
parent e4be93ee5c
commit 8aca911c3d
5 changed files with 125 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
using Iciclecreek.Avalonia.WindowManager;
namespace Aaru.Tui.ViewModels.Dialogs;
public sealed class MainHelpDialogViewModel : ViewModelBase
{
internal ManagedWindow _dialog = null!;
public MainHelpDialogViewModel(ManagedWindow dialog)
{
_dialog = dialog;
OkCommand = new RelayCommand(Ok);
}
public ICommand OkCommand { get; }
void Ok()
{
_dialog.Close(true);
}
}

View File

@@ -73,6 +73,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
ExitCommand = new RelayCommand(Exit);
SectorViewCommand = new RelayCommand(SectorView);
GoToPathCommand = new AsyncRelayCommand(GoToPathAsync);
HelpCommand = new AsyncRelayCommand(HelpAsync);
OpenSelectedFileCommand = new RelayCommand(OpenSelectedFile, CanOpenSelectedFile);
InformationalVersion =
@@ -107,6 +108,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
public ICommand ExitCommand { get; }
public ICommand SectorViewCommand { get; }
public ICommand GoToPathCommand { get; }
public ICommand HelpCommand { get; }
public bool IsFileInfoAvailable => SelectedFile?.FileInfo != null;
public bool SelectedFileIsNotDirectory => SelectedFile?.IsDirectory == false;
public long? SelectedFileLength => SelectedFile?.IsDirectory == false ? SelectedFile?.FileInfo?.Length : 0;
@@ -118,6 +120,19 @@ public sealed partial class MainWindowViewModel : ViewModelBase
public string? SelectedFileInformation => SelectedFile?.Information;
Task HelpAsync()
{
var dialog = new MainHelpDialog
{
DataContext = new MainHelpDialogViewModel(null!)
};
// Set the dialog reference after creation
((MainHelpDialogViewModel)dialog.DataContext!)._dialog = dialog;
return dialog.ShowDialog(_view);
}
async Task GoToPathAsync()
{
var dialog = new GoToPathDialog

View File

@@ -0,0 +1,71 @@
<windowManager:ManagedWindow xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowManager="clr-namespace:Iciclecreek.Avalonia.WindowManager;assembly=Iciclecreek.Avalonia.WindowManager"
xmlns:dialogs="clr-namespace:Aaru.Tui.ViewModels.Dialogs"
xmlns:brushes="https://github.com/jinek/consolonia"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
x:Class="Aaru.Tui.Views.Dialogs.MainHelpDialog"
Width="40"
Height="8"
WindowStartupLocation="CenterScreen"
BorderBrush="Blue"
CanResize="False"
Title="Help">
<Design.DataContext>
<dialogs:MainHelpDialogViewModel />
</Design.DataContext>
<Border BorderThickness="1">
<Border.BorderBrush>
<brushes:LineBrush LineStyle="DoubleLine"
Brush="Blue" />
</Border.BorderBrush>
<StackPanel>
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="2">
<TextBlock Grid.Column="0"
Foreground="Aqua"
Text="F1 " />
<TextBlock Grid.Column="1"
Foreground="SlateBlue"
Text="Shows this help" />
</Grid>
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="2">
<TextBlock Grid.Column="0"
Foreground="Aqua"
Text="F2 " />
<TextBlock Grid.Column="1"
Foreground="SlateBlue"
Text="Sector viewer" />
</Grid>
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="2">
<TextBlock Grid.Column="0"
Foreground="Aqua"
Text="F4 " />
<TextBlock Grid.Column="1"
Foreground="SlateBlue"
Text="Go to the specified path" />
</Grid>
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="2">
<TextBlock Grid.Column="0"
Foreground="Aqua"
Text="F10" />
<TextBlock Grid.Column="1"
Foreground="SlateBlue"
Text="Exits the application" />
</Grid>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Spacing="1">
<Button Content="OK"
Command="{Binding OkCommand, Mode=OneWay}" />
</StackPanel>
</StackPanel>
</Border>
</windowManager:ManagedWindow>

View File

@@ -0,0 +1,11 @@
using Iciclecreek.Avalonia.WindowManager;
namespace Aaru.Tui.Views.Dialogs;
public partial class MainHelpDialog : ManagedWindow
{
public MainHelpDialog()
{
InitializeComponent();
}
}

View File

@@ -11,7 +11,10 @@
</Design.DataContext>
<DockPanel>
<Menu DockPanel.Dock="Bottom">
<MenuItem Header="ESC " /> <MenuItem Header="F1 Help" />
<MenuItem Header="ESC " />
<MenuItem Header="F1 Help"
Command="{Binding HelpCommand, Mode=OneWay}"
HotKey="F1" />
<MenuItem Header="F2 ScVw"
Command="{Binding SectorViewCommand, Mode=OneWay}"
HotKey="F2" />