mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[TUI] Add Image Help dialog with F1 shortcut for user assistance
This commit is contained in:
@@ -26,6 +26,10 @@
|
|||||||
<Compile Update="Views\Dialogs\GoToSectorDialog.axaml.cs">
|
<Compile Update="Views\Dialogs\GoToSectorDialog.axaml.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Views\Dialogs\ImageHelpDialog.axaml.cs">
|
||||||
|
<DependentUpon>ImageHelpDialog.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
24
Aaru.Tui/ViewModels/Dialogs/ImageHelpDialogViewModel.cs
Normal file
24
Aaru.Tui/ViewModels/Dialogs/ImageHelpDialogViewModel.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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,8 @@ using System.Windows.Input;
|
|||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Tui.Models;
|
using Aaru.Tui.Models;
|
||||||
|
using Aaru.Tui.ViewModels.Dialogs;
|
||||||
|
using Aaru.Tui.Views.Dialogs;
|
||||||
using Aaru.Tui.Views.Windows;
|
using Aaru.Tui.Views.Windows;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
@@ -91,6 +93,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
ExitCommand = new RelayCommand(Exit);
|
ExitCommand = new RelayCommand(Exit);
|
||||||
BackCommand = new RelayCommand(Back);
|
BackCommand = new RelayCommand(Back);
|
||||||
|
HelpCommand = new AsyncRelayCommand(HelpAsync);
|
||||||
SectorViewCommand = new RelayCommand(SectorView);
|
SectorViewCommand = new RelayCommand(SectorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +149,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ICommand BackCommand { get; }
|
public ICommand BackCommand { get; }
|
||||||
|
public ICommand HelpCommand { get; }
|
||||||
public ICommand ExitCommand { get; }
|
public ICommand ExitCommand { get; }
|
||||||
public ICommand SectorViewCommand { get; }
|
public ICommand SectorViewCommand { get; }
|
||||||
|
|
||||||
@@ -178,6 +182,19 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
_ = Task.Run(Worker);
|
_ = 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()
|
void Worker()
|
||||||
{
|
{
|
||||||
IsStatusVisible = true;
|
IsStatusVisible = true;
|
||||||
|
|||||||
71
Aaru.Tui/Views/Dialogs/ImageHelpDialog.axaml
Normal file
71
Aaru.Tui/Views/Dialogs/ImageHelpDialog.axaml
Normal 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>
|
||||||
11
Aaru.Tui/Views/Dialogs/ImageHelpDialog.axaml.cs
Normal file
11
Aaru.Tui/Views/Dialogs/ImageHelpDialog.axaml.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Iciclecreek.Avalonia.WindowManager;
|
||||||
|
|
||||||
|
namespace Aaru.Tui.Views.Dialogs;
|
||||||
|
|
||||||
|
public partial class ImageHelpDialog : ManagedWindow
|
||||||
|
{
|
||||||
|
public ImageHelpDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,9 @@
|
|||||||
<MenuItem Header="ESC Back"
|
<MenuItem Header="ESC Back"
|
||||||
Command="{Binding BackCommand, Mode=OneWay}"
|
Command="{Binding BackCommand, Mode=OneWay}"
|
||||||
HotKey="Escape" />
|
HotKey="Escape" />
|
||||||
<MenuItem Header="F1 Help" />
|
<MenuItem Header="F1 Help"
|
||||||
|
Command="{Binding HelpCommand, Mode=OneWay}"
|
||||||
|
HotKey="F1" />
|
||||||
<MenuItem Header="F2 ScVw"
|
<MenuItem Header="F2 ScVw"
|
||||||
Command="{Binding SectorViewCommand, Mode=OneWay}"
|
Command="{Binding SectorViewCommand, Mode=OneWay}"
|
||||||
HotKey="F2" />
|
HotKey="F2" />
|
||||||
|
|||||||
Reference in New Issue
Block a user