diff --git a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs index 7262b12a2..8c2431617 100644 --- a/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs +++ b/Aaru.Tui/ViewModels/Windows/HexViewWindowViewModel.cs @@ -12,10 +12,10 @@ 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; - readonly ulong _currentSector; [ObservableProperty] string _filePath; [ObservableProperty] @@ -23,7 +23,8 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase [ObservableProperty] ObservableCollection _lines = []; - internal HexViewWindowViewModel(Window parent, Window view, IMediaImage imageFormat, string filePath) + internal HexViewWindowViewModel(Window parent, Window view, IMediaImage imageFormat, string filePath, + ulong currentSector = 0) { ExitCommand = new RelayCommand(Exit); BackCommand = new RelayCommand(Back); @@ -31,7 +32,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase _parent = parent; _view = view; _imageFormat = imageFormat; - _currentSector = 0; + _currentSector = currentSector; FilePath = filePath; } @@ -83,7 +84,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase } } -sealed class HexViewLine +public sealed class HexViewLine { internal long Offset { get; init; } internal byte[] Bytes { get; init; } diff --git a/Aaru.Tui/ViewModels/Windows/ImageWindowViewModel.cs b/Aaru.Tui/ViewModels/Windows/ImageWindowViewModel.cs index 65b0655ff..bb6dd9568 100644 --- a/Aaru.Tui/ViewModels/Windows/ImageWindowViewModel.cs +++ b/Aaru.Tui/ViewModels/Windows/ImageWindowViewModel.cs @@ -4,6 +4,7 @@ using System.Windows.Input; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Tui.Models; +using Aaru.Tui.Views.Windows; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; @@ -61,8 +62,9 @@ public sealed partial class ImageWindowViewModel : ViewModelBase _view = view; _parent = parent; - ExitCommand = new RelayCommand(Exit); - BackCommand = new RelayCommand(Back); + ExitCommand = new RelayCommand(Exit); + BackCommand = new RelayCommand(Back); + SectorViewCommand = new RelayCommand(SectorView); } public FileSystemModelNode? SelectedNode @@ -74,7 +76,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase if(_selectedNode is null) return; - if(_selectedNode.Partition is not null) + if(_selectedNode.Partition is not null && _selectedNode.Filesystem is null) { IsPartitionInformationVisible = true; @@ -116,8 +118,21 @@ public sealed partial class ImageWindowViewModel : ViewModelBase } } - public ICommand BackCommand { get; } - public ICommand ExitCommand { get; } + public ICommand BackCommand { get; } + public ICommand ExitCommand { get; } + public ICommand SectorViewCommand { get; } + + void SectorView() + { + if(SelectedNode?.Partition is null) return; + + var view = new HexViewWindow(); + + var vm = new HexViewWindowViewModel(_view, view, _imageFormat, FilePath, SelectedNode.Partition.Value.Start); + view.DataContext = vm; + view.Show(); + _view.Hide(); + } void Back() { @@ -181,6 +196,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase var fsNode = new FileSystemModelNode(fs.Name) { + Partition = partition, Filesystem = fs }; diff --git a/Aaru.Tui/Views/Windows/ImageWindow.axaml b/Aaru.Tui/Views/Windows/ImageWindow.axaml index 556ef9654..94f418773 100644 --- a/Aaru.Tui/Views/Windows/ImageWindow.axaml +++ b/Aaru.Tui/Views/Windows/ImageWindow.axaml @@ -18,6 +18,10 @@ + +