mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[TUI] Add Main Help dialog with F1 shortcut and Ok command
This commit is contained in:
24
Aaru.Tui/ViewModels/Dialogs/MainHelpDialogViewModel.cs
Normal file
24
Aaru.Tui/ViewModels/Dialogs/MainHelpDialogViewModel.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 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -73,6 +73,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
|
|||||||
ExitCommand = new RelayCommand(Exit);
|
ExitCommand = new RelayCommand(Exit);
|
||||||
SectorViewCommand = new RelayCommand(SectorView);
|
SectorViewCommand = new RelayCommand(SectorView);
|
||||||
GoToPathCommand = new AsyncRelayCommand(GoToPathAsync);
|
GoToPathCommand = new AsyncRelayCommand(GoToPathAsync);
|
||||||
|
HelpCommand = new AsyncRelayCommand(HelpAsync);
|
||||||
OpenSelectedFileCommand = new RelayCommand(OpenSelectedFile, CanOpenSelectedFile);
|
OpenSelectedFileCommand = new RelayCommand(OpenSelectedFile, CanOpenSelectedFile);
|
||||||
|
|
||||||
InformationalVersion =
|
InformationalVersion =
|
||||||
@@ -107,6 +108,7 @@ public sealed partial class MainWindowViewModel : ViewModelBase
|
|||||||
public ICommand ExitCommand { get; }
|
public ICommand ExitCommand { get; }
|
||||||
public ICommand SectorViewCommand { get; }
|
public ICommand SectorViewCommand { get; }
|
||||||
public ICommand GoToPathCommand { get; }
|
public ICommand GoToPathCommand { get; }
|
||||||
|
public ICommand HelpCommand { get; }
|
||||||
public bool IsFileInfoAvailable => SelectedFile?.FileInfo != null;
|
public bool IsFileInfoAvailable => SelectedFile?.FileInfo != null;
|
||||||
public bool SelectedFileIsNotDirectory => SelectedFile?.IsDirectory == false;
|
public bool SelectedFileIsNotDirectory => SelectedFile?.IsDirectory == false;
|
||||||
public long? SelectedFileLength => SelectedFile?.IsDirectory == false ? SelectedFile?.FileInfo?.Length : 0;
|
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;
|
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()
|
async Task GoToPathAsync()
|
||||||
{
|
{
|
||||||
var dialog = new GoToPathDialog
|
var dialog = new GoToPathDialog
|
||||||
|
|||||||
71
Aaru.Tui/Views/Dialogs/MainHelpDialog.axaml
Normal file
71
Aaru.Tui/Views/Dialogs/MainHelpDialog.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.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>
|
||||||
11
Aaru.Tui/Views/Dialogs/MainHelpDialog.axaml.cs
Normal file
11
Aaru.Tui/Views/Dialogs/MainHelpDialog.axaml.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Iciclecreek.Avalonia.WindowManager;
|
||||||
|
|
||||||
|
namespace Aaru.Tui.Views.Dialogs;
|
||||||
|
|
||||||
|
public partial class MainHelpDialog : ManagedWindow
|
||||||
|
{
|
||||||
|
public MainHelpDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,10 @@
|
|||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Menu DockPanel.Dock="Bottom">
|
<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"
|
<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