[TUI] Add Next Sector command and update hex view for sector navigation

This commit is contained in:
2025-10-16 15:43:16 +01:00
parent 6f29dfa272
commit 35df953491
2 changed files with 44 additions and 11 deletions

View File

@@ -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