[TUI] Add Image Help dialog with F1 shortcut for user assistance

This commit is contained in:
2025-10-16 21:20:20 +01:00
parent 8aca911c3d
commit c6fdc456fb
6 changed files with 130 additions and 1 deletions

View File

@@ -26,6 +26,10 @@
<Compile Update="Views\Dialogs\GoToSectorDialog.axaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Dialogs\ImageHelpDialog.axaml.cs">
<DependentUpon>ImageHelpDialog.axaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>

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 ImageHelpDialogViewModel : ViewModelBase
{
internal ManagedWindow _dialog = null!;
public ImageHelpDialogViewModel(ManagedWindow dialog)
{
_dialog = dialog;
OkCommand = new RelayCommand(Ok);
}
public ICommand OkCommand { get; }
void Ok()
{
_dialog.Close(true);
}
}

View File

@@ -31,6 +31,8 @@ using System.Windows.Input;
using Aaru.CommonTypes;
using Aaru.CommonTypes.Interfaces;
using Aaru.Tui.Models;
using Aaru.Tui.ViewModels.Dialogs;
using Aaru.Tui.Views.Dialogs;
using Aaru.Tui.Views.Windows;
using Avalonia;
using Avalonia.Controls;
@@ -91,6 +93,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
ExitCommand = new RelayCommand(Exit);
BackCommand = new RelayCommand(Back);
HelpCommand = new AsyncRelayCommand(HelpAsync);
SectorViewCommand = new RelayCommand(SectorView);
}
@@ -146,6 +149,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
}
public ICommand BackCommand { get; }
public ICommand HelpCommand { get; }
public ICommand ExitCommand { get; }
public ICommand SectorViewCommand { get; }
@@ -178,6 +182,19 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
_ = Task.Run(Worker);
}
Task HelpAsync()
{
var dialog = new ImageHelpDialog
{
DataContext = new ImageHelpDialogViewModel(null!)
};
// Set the dialog reference after creation
((ImageHelpDialogViewModel)dialog.DataContext!)._dialog = dialog;
return dialog.ShowDialog(_view);
}
void Worker()
{
IsStatusVisible = true;

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.ImageHelpDialog"
Width="40"
Height="8"
WindowStartupLocation="CenterScreen"
BorderBrush="Blue"
CanResize="False"
Title="Help">
<Design.DataContext>
<dialogs:ImageHelpDialogViewModel />
</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="ESC" />
<TextBlock Grid.Column="1"
Foreground="SlateBlue"
Text="Go back to previous window" />
</Grid>
<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="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 ImageHelpDialog : ManagedWindow
{
public ImageHelpDialog()
{
InitializeComponent();
}
}

View File

@@ -18,7 +18,9 @@
<MenuItem Header="ESC Back"
Command="{Binding BackCommand, Mode=OneWay}"
HotKey="Escape" />
<MenuItem Header="F1 Help" />
<MenuItem Header="F1 Help"
Command="{Binding HelpCommand, Mode=OneWay}"
HotKey="F1" />
<MenuItem Header="F2 ScVw"
Command="{Binding SectorViewCommand, Mode=OneWay}"
HotKey="F2" />