mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[TUI] Add HexView Help dialog with F1 shortcut for user assistance
This commit is contained in:
@@ -30,6 +30,10 @@
|
||||
<DependentUpon>ImageHelpDialog.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Views\Dialogs\HexViewHelpDialog.axaml.cs">
|
||||
<DependentUpon>HexViewHelpDialog.axaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
24
Aaru.Tui/ViewModels/Dialogs/HexViewHelpDialogViewModel.cs
Normal file
24
Aaru.Tui/ViewModels/Dialogs/HexViewHelpDialogViewModel.cs
Normal 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 HexViewHelpDialogViewModel : ViewModelBase
|
||||
{
|
||||
internal ManagedWindow _dialog = null!;
|
||||
|
||||
|
||||
public HexViewHelpDialogViewModel(ManagedWindow dialog)
|
||||
{
|
||||
_dialog = dialog;
|
||||
OkCommand = new RelayCommand(Ok);
|
||||
}
|
||||
|
||||
public ICommand OkCommand { get; }
|
||||
|
||||
void Ok()
|
||||
{
|
||||
_dialog.Close(true);
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using Aaru.CommonTypes.Interfaces;
|
||||
using Aaru.Tui.ViewModels.Dialogs;
|
||||
using Aaru.Tui.Views.Dialogs;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
@@ -61,6 +62,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase
|
||||
NextSectorCommand = new RelayCommand(NextSector);
|
||||
PreviousSectorCommand = new RelayCommand(PreviousSector);
|
||||
GoToCommand = new AsyncRelayCommand(GoToAsync);
|
||||
HelpCommand = new AsyncRelayCommand(HelpAsync);
|
||||
|
||||
_parent = parent;
|
||||
_view = view;
|
||||
@@ -75,6 +77,20 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase
|
||||
public ICommand NextSectorCommand { get; }
|
||||
public ICommand PreviousSectorCommand { get; }
|
||||
public ICommand GoToCommand { get; }
|
||||
public ICommand HelpCommand { get; }
|
||||
|
||||
Task HelpAsync()
|
||||
{
|
||||
var dialog = new HexViewHelpDialog
|
||||
{
|
||||
DataContext = new HexViewHelpDialogViewModel(null!)
|
||||
};
|
||||
|
||||
// Set the dialog reference after creation
|
||||
((HexViewHelpDialogViewModel)dialog.DataContext!)._dialog = dialog;
|
||||
|
||||
return dialog.ShowDialog(_view);
|
||||
}
|
||||
|
||||
async Task GoToAsync()
|
||||
{
|
||||
|
||||
89
Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml
Normal file
89
Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml
Normal file
@@ -0,0 +1,89 @@
|
||||
<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.HexViewHelpDialog"
|
||||
Width="40"
|
||||
Height="10"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
BorderBrush="Blue"
|
||||
CanResize="False"
|
||||
Title="Help">
|
||||
<Design.DataContext>
|
||||
<dialogs:HexViewHelpDialogViewModel />
|
||||
</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="Go to next sector" />
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="Auto,*"
|
||||
ColumnSpacing="2">
|
||||
<TextBlock Grid.Column="0"
|
||||
Foreground="Aqua"
|
||||
Text="F3 " />
|
||||
<TextBlock Grid.Column="1"
|
||||
Foreground="SlateBlue"
|
||||
Text="Go to previous sector" />
|
||||
</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 sector" />
|
||||
</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>
|
||||
11
Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml.cs
Normal file
11
Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Iciclecreek.Avalonia.WindowManager;
|
||||
|
||||
namespace Aaru.Tui.Views.Dialogs;
|
||||
|
||||
public partial class HexViewHelpDialog : ManagedWindow
|
||||
{
|
||||
public HexViewHelpDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,9 @@
|
||||
<MenuItem Header="ESC Back"
|
||||
HotKey="Escape"
|
||||
Command="{Binding BackCommand, Mode=OneWay}" />
|
||||
<MenuItem Header="F1 Help" />
|
||||
<MenuItem Header="F1 Help"
|
||||
Command="{Binding HelpCommand, Mode=OneWay}"
|
||||
HotKey="F1" />
|
||||
<MenuItem Header="F2 Next"
|
||||
Command="{Binding NextSectorCommand, Mode=OneWay}"
|
||||
HotKey="F2" />
|
||||
@@ -22,9 +24,6 @@
|
||||
<MenuItem Header="F4 GoTo"
|
||||
Command="{Binding GoToCommand, Mode=OneWay}"
|
||||
HotKey="F4" />
|
||||
<MenuItem Header="F5 Save"
|
||||
Command="{Binding SaveCommand, Mode=OneWay}"
|
||||
HotKey="F5" />
|
||||
<MenuItem Header="F10 Exit"
|
||||
HotKey="F10"
|
||||
Command="{Binding ExitCommand, Mode=OneWay}" />
|
||||
|
||||
Reference in New Issue
Block a user