From 65fd89371ccfcc0c73d47126af29828dd4219a10 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 16 Oct 2025 22:16:38 +0100 Subject: [PATCH] [TUI] Add Toggle Long Mode functionality with F5 shortcut in HexView --- .../Windows/HexViewWindowViewModel.cs | 32 ++++++++++++++++++- .../Views/Dialogs/HexViewHelpDialog.axaml | 11 ++++++- Aaru.Tui/Views/Windows/HexViewWindow.axaml | 3 ++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs index 66dbe80a6..a0b7c30bc 100644 --- a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs +++ b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs @@ -27,6 +27,7 @@ using System.Collections.ObjectModel; using System.Windows.Input; +using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Tui.ViewModels.Dialogs; using Aaru.Tui.Views.Dialogs; @@ -53,6 +54,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase long _fileSize; [ObservableProperty] ObservableCollection _lines = []; + bool _longMode; internal HexViewWindowViewModel(Window parent, Window view, IMediaImage imageFormat, string filePath, ulong currentSector = 0) @@ -63,6 +65,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase PreviousSectorCommand = new RelayCommand(PreviousSector); GoToCommand = new AsyncRelayCommand(GoToAsync); HelpCommand = new AsyncRelayCommand(HelpAsync); + ToggleLongCommand = new RelayCommand(ToggleLong); _parent = parent; _view = view; @@ -78,6 +81,19 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase public ICommand PreviousSectorCommand { get; } public ICommand GoToCommand { get; } public ICommand HelpCommand { get; } + public ICommand ToggleLongCommand { get; } + + void ToggleLong() + { + _longMode = !_longMode; + + if(_longMode) + FilePath += " (Long Mode)"; + else + FilePath = FilePath.Replace(" (Long Mode)", string.Empty); + + LoadSector(); + } Task HelpAsync() { @@ -150,7 +166,21 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase { Lines.Clear(); - _imageFormat.ReadSector(CurrentSector, out byte[]? sector); + byte[]? sector; + + if(_longMode) + { + ErrorNumber errno = _imageFormat.ReadSectorLong(CurrentSector, out sector); + + if(errno != ErrorNumber.NoError) + { + ToggleLong(); + + return; + } + } + else + _imageFormat.ReadSector(CurrentSector, out sector); using var stream = new MemoryStream(sector); var buffer = new byte[BYTES_PER_LINE]; diff --git a/Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml b/Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml index 9e19cc108..64f520354 100644 --- a/Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml +++ b/Aaru.Tui/Views/Dialogs/HexViewHelpDialog.axaml @@ -10,7 +10,7 @@ d:DesignHeight="450" x:Class="Aaru.Tui.Views.Dialogs.HexViewHelpDialog" Width="40" - Height="10" + Height="11" WindowStartupLocation="CenterScreen" BorderBrush="Blue" CanResize="False" @@ -69,6 +69,15 @@ Foreground="SlateBlue" Text="Go to the specified sector" /> + + + + +