From 35df95349132bd289a0070076620dc5294c8ea46 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 16 Oct 2025 15:43:16 +0100 Subject: [PATCH] [TUI] Add Next Sector command and update hex view for sector navigation --- .../Windows/HexViewWindowViewModel.cs | 33 +++++++++++++------ Aaru.Tui/Views/Windows/HexViewWindow.axaml | 22 ++++++++++++- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs index 8c2431617..51b6c821a 100644 --- a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs +++ b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs @@ -12,11 +12,12 @@ namespace Aaru.Tui.ViewModels.Windows; public sealed partial class HexViewWindowViewModel : ViewModelBase { private const int BYTES_PER_LINE = 16; - readonly ulong _currentSector; readonly IMediaImage _imageFormat; readonly Window _parent; readonly Window _view; [ObservableProperty] + ulong _currentSector; + [ObservableProperty] string _filePath; [ObservableProperty] long _fileSize; @@ -26,18 +27,31 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase internal HexViewWindowViewModel(Window parent, Window view, IMediaImage imageFormat, string filePath, ulong currentSector = 0) { - ExitCommand = new RelayCommand(Exit); - BackCommand = new RelayCommand(Back); + ExitCommand = new RelayCommand(Exit); + BackCommand = new RelayCommand(Back); + NextSectorCommand = new RelayCommand(NextSector); _parent = parent; _view = view; _imageFormat = imageFormat; _currentSector = currentSector; FilePath = filePath; + LoadSector(); + } + + public ICommand BackCommand { get; } + public ICommand ExitCommand { get; } + public ICommand NextSectorCommand { get; } + + void NextSector() + { + if(CurrentSector >= _imageFormat.Info.Sectors - 1) return; + + CurrentSector++; + + LoadSector(); } - public ICommand BackCommand { get; } - public ICommand ExitCommand { get; } void Back() { @@ -53,7 +67,9 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase void LoadSector() { - _imageFormat.ReadSector(_currentSector, out byte[]? sector); + Lines.Clear(); + + _imageFormat.ReadSector(CurrentSector, out byte[]? sector); using var stream = new MemoryStream(sector); var buffer = new byte[BYTES_PER_LINE]; @@ -78,10 +94,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase } } - public void LoadComplete() - { - LoadSector(); - } + public void LoadComplete() {} } public sealed class HexViewLine diff --git a/Aaru.Tui/Views/Windows/HexViewWindow.axaml b/Aaru.Tui/Views/Windows/HexViewWindow.axaml index c8cbd5808..ea8c7c9de 100644 --- a/Aaru.Tui/Views/Windows/HexViewWindow.axaml +++ b/Aaru.Tui/Views/Windows/HexViewWindow.axaml @@ -12,6 +12,19 @@ + + + + + @@ -21,7 +34,7 @@ - + @@ -73,6 +86,13 @@ + + + +