mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[TUI] Add sector view command to image window and update hex view model
This commit is contained in:
@@ -12,10 +12,10 @@ namespace Aaru.Tui.ViewModels.Windows;
|
|||||||
public sealed partial class HexViewWindowViewModel : ViewModelBase
|
public sealed partial class HexViewWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private const int BYTES_PER_LINE = 16;
|
private const int BYTES_PER_LINE = 16;
|
||||||
|
readonly ulong _currentSector;
|
||||||
readonly IMediaImage _imageFormat;
|
readonly IMediaImage _imageFormat;
|
||||||
readonly Window _parent;
|
readonly Window _parent;
|
||||||
readonly Window _view;
|
readonly Window _view;
|
||||||
readonly ulong _currentSector;
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
string _filePath;
|
string _filePath;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@@ -23,7 +23,8 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
ObservableCollection<HexViewLine> _lines = [];
|
ObservableCollection<HexViewLine> _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);
|
ExitCommand = new RelayCommand(Exit);
|
||||||
BackCommand = new RelayCommand(Back);
|
BackCommand = new RelayCommand(Back);
|
||||||
@@ -31,7 +32,7 @@ public sealed partial class HexViewWindowViewModel : ViewModelBase
|
|||||||
_parent = parent;
|
_parent = parent;
|
||||||
_view = view;
|
_view = view;
|
||||||
_imageFormat = imageFormat;
|
_imageFormat = imageFormat;
|
||||||
_currentSector = 0;
|
_currentSector = currentSector;
|
||||||
FilePath = filePath;
|
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 long Offset { get; init; }
|
||||||
internal byte[] Bytes { get; init; }
|
internal byte[] Bytes { get; init; }
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Windows.Input;
|
|||||||
using Aaru.CommonTypes;
|
using Aaru.CommonTypes;
|
||||||
using Aaru.CommonTypes.Interfaces;
|
using Aaru.CommonTypes.Interfaces;
|
||||||
using Aaru.Tui.Models;
|
using Aaru.Tui.Models;
|
||||||
|
using Aaru.Tui.Views.Windows;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
@@ -61,8 +62,9 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
_view = view;
|
_view = view;
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
||||||
ExitCommand = new RelayCommand(Exit);
|
ExitCommand = new RelayCommand(Exit);
|
||||||
BackCommand = new RelayCommand(Back);
|
BackCommand = new RelayCommand(Back);
|
||||||
|
SectorViewCommand = new RelayCommand(SectorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileSystemModelNode? SelectedNode
|
public FileSystemModelNode? SelectedNode
|
||||||
@@ -74,7 +76,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
if(_selectedNode is null) return;
|
if(_selectedNode is null) return;
|
||||||
|
|
||||||
if(_selectedNode.Partition is not null)
|
if(_selectedNode.Partition is not null && _selectedNode.Filesystem is null)
|
||||||
{
|
{
|
||||||
IsPartitionInformationVisible = true;
|
IsPartitionInformationVisible = true;
|
||||||
|
|
||||||
@@ -116,8 +118,21 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICommand BackCommand { get; }
|
public ICommand BackCommand { get; }
|
||||||
public ICommand ExitCommand { 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()
|
void Back()
|
||||||
{
|
{
|
||||||
@@ -181,6 +196,7 @@ public sealed partial class ImageWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
var fsNode = new FileSystemModelNode(fs.Name)
|
var fsNode = new FileSystemModelNode(fs.Name)
|
||||||
{
|
{
|
||||||
|
Partition = partition,
|
||||||
Filesystem = fs
|
Filesystem = fs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
<MenuItem Header="ESC Back"
|
<MenuItem Header="ESC Back"
|
||||||
Command="{Binding BackCommand, Mode=OneWay}"
|
Command="{Binding BackCommand, Mode=OneWay}"
|
||||||
HotKey="Escape" />
|
HotKey="Escape" />
|
||||||
|
<MenuItem Header="F1 Help" />
|
||||||
|
<MenuItem Header="F2 ScVw"
|
||||||
|
Command="{Binding SectorViewCommand, Mode=OneWay}"
|
||||||
|
HotKey="F2" />
|
||||||
<MenuItem Header="F10 Exit"
|
<MenuItem Header="F10 Exit"
|
||||||
Command="{Binding ExitCommand, Mode=OneWay}"
|
Command="{Binding ExitCommand, Mode=OneWay}"
|
||||||
HotKey="F10" />
|
HotKey="F10" />
|
||||||
|
|||||||
Reference in New Issue
Block a user