mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[GUI] Add image processing commands to MainWindowViewModel and update UI bindings
This commit is contained in:
@@ -16,6 +16,7 @@ using Aaru.Gui.ViewModels.Dialogs;
|
|||||||
using Aaru.Gui.ViewModels.Panels;
|
using Aaru.Gui.ViewModels.Panels;
|
||||||
using Aaru.Gui.Views.Dialogs;
|
using Aaru.Gui.Views.Dialogs;
|
||||||
using Aaru.Gui.Views.Panels;
|
using Aaru.Gui.Views.Panels;
|
||||||
|
using Aaru.Gui.Views.Windows;
|
||||||
using Aaru.Localization;
|
using Aaru.Localization;
|
||||||
using Aaru.Logging;
|
using Aaru.Logging;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
@@ -54,13 +55,15 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
object _contentPanel;
|
object _contentPanel;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
bool _devicesSupported;
|
bool _devicesSupported;
|
||||||
|
ImageModel _image;
|
||||||
|
[ObservableProperty]
|
||||||
|
bool _imageLoaded;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
string _title;
|
string _title;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
ObservableCollection<RootModel> _treeRoot;
|
ObservableCollection<RootModel> _treeRoot;
|
||||||
object _treeViewSelectedItem;
|
object _treeViewSelectedItem;
|
||||||
|
|
||||||
|
|
||||||
public MainWindowViewModel(Window view)
|
public MainWindowViewModel(Window view)
|
||||||
{
|
{
|
||||||
AboutCommand = new AsyncRelayCommand(AboutAsync);
|
AboutCommand = new AsyncRelayCommand(AboutAsync);
|
||||||
@@ -71,6 +74,13 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
SettingsCommand = new AsyncRelayCommand(SettingsAsync);
|
SettingsCommand = new AsyncRelayCommand(SettingsAsync);
|
||||||
ConsoleCommand = new RelayCommand(Console);
|
ConsoleCommand = new RelayCommand(Console);
|
||||||
OpenCommand = new AsyncRelayCommand(OpenAsync);
|
OpenCommand = new AsyncRelayCommand(OpenAsync);
|
||||||
|
CalculateEntropyCommand = new RelayCommand(CalculateEntropy);
|
||||||
|
VerifyImageCommand = new RelayCommand(VerifyImage);
|
||||||
|
ChecksumImageCommand = new RelayCommand(ChecksumImage);
|
||||||
|
ConvertImageCommand = new RelayCommand(ConvertImage);
|
||||||
|
CreateSidecarCommand = new RelayCommand(CreateSidecar);
|
||||||
|
ViewImageSectorsCommand = new RelayCommand(ViewImageSectors);
|
||||||
|
DecodeImageMediaTagsCommand = new RelayCommand(DecodeImageMediaTags);
|
||||||
|
|
||||||
_genericHddIcon =
|
_genericHddIcon =
|
||||||
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-harddisk.png")));
|
new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-harddisk.png")));
|
||||||
@@ -115,6 +125,13 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
public ICommand PluginsCommand { get; }
|
public ICommand PluginsCommand { get; }
|
||||||
public ICommand StatisticsCommand { get; }
|
public ICommand StatisticsCommand { get; }
|
||||||
public ICommand AboutCommand { get; }
|
public ICommand AboutCommand { get; }
|
||||||
|
public ICommand CalculateEntropyCommand { get; }
|
||||||
|
public ICommand VerifyImageCommand { get; }
|
||||||
|
public ICommand ChecksumImageCommand { get; }
|
||||||
|
public ICommand ConvertImageCommand { get; }
|
||||||
|
public ICommand CreateSidecarCommand { get; }
|
||||||
|
public ICommand ViewImageSectorsCommand { get; }
|
||||||
|
public ICommand DecodeImageMediaTagsCommand { get; }
|
||||||
|
|
||||||
public bool NativeMenuSupported
|
public bool NativeMenuSupported
|
||||||
{
|
{
|
||||||
@@ -447,6 +464,8 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
TreeRoot.Clear();
|
TreeRoot.Clear();
|
||||||
TreeRoot.Add(imageModel);
|
TreeRoot.Add(imageModel);
|
||||||
Title = $"Aaru - {imageModel.FileName}";
|
Title = $"Aaru - {imageModel.FileName}";
|
||||||
|
ImageLoaded = true;
|
||||||
|
_image = imageModel;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -545,4 +564,91 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
_console.Show();
|
_console.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalculateEntropy()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
var imageEntropyWindow = new ImageEntropy();
|
||||||
|
imageEntropyWindow.DataContext = new ImageEntropyViewModel(imageModel.Image, imageEntropyWindow);
|
||||||
|
|
||||||
|
imageEntropyWindow.Closed += (_, _) => imageEntropyWindow = null;
|
||||||
|
|
||||||
|
imageEntropyWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerifyImage()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
var imageVerifyWindow = new ImageVerify();
|
||||||
|
imageVerifyWindow.DataContext = new ImageVerifyViewModel(imageModel.Image, imageVerifyWindow);
|
||||||
|
|
||||||
|
imageVerifyWindow.Closed += (_, _) => imageVerifyWindow = null;
|
||||||
|
|
||||||
|
imageVerifyWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChecksumImage()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
var imageChecksumWindow = new ImageChecksum();
|
||||||
|
imageChecksumWindow.DataContext = new ImageChecksumViewModel(imageModel.Image, imageChecksumWindow);
|
||||||
|
|
||||||
|
imageChecksumWindow.Closed += (_, _) => imageChecksumWindow = null;
|
||||||
|
|
||||||
|
imageChecksumWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConvertImage()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
var imageConvertWindow = new ImageConvert();
|
||||||
|
|
||||||
|
imageConvertWindow.DataContext =
|
||||||
|
new ImageConvertViewModel(imageModel.Image, imageModel.Path, imageConvertWindow);
|
||||||
|
|
||||||
|
imageConvertWindow.Closed += (_, _) => imageConvertWindow = null;
|
||||||
|
|
||||||
|
imageConvertWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateSidecar()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
var imageSidecarWindow = new ImageSidecar();
|
||||||
|
|
||||||
|
// TODO: Pass thru chosen default encoding
|
||||||
|
imageSidecarWindow.DataContext =
|
||||||
|
new ImageSidecarViewModel(imageModel.Image,
|
||||||
|
imageModel.Path,
|
||||||
|
imageModel.Filter.Id,
|
||||||
|
null,
|
||||||
|
imageSidecarWindow);
|
||||||
|
|
||||||
|
imageSidecarWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ViewImageSectors()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
new ViewSector
|
||||||
|
{
|
||||||
|
DataContext = new ViewSectorViewModel(imageModel.Image)
|
||||||
|
}.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecodeImageMediaTags()
|
||||||
|
{
|
||||||
|
if(_image is not {} imageModel) return;
|
||||||
|
|
||||||
|
new DecodeMediaTags
|
||||||
|
{
|
||||||
|
DataContext = new DecodeMediaTagsViewModel(imageModel.Image)
|
||||||
|
}.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,23 @@
|
|||||||
IsVisible="{Binding DevicesSupported, Mode=OneWay}">
|
IsVisible="{Binding DevicesSupported, Mode=OneWay}">
|
||||||
<MenuItem Header="TODO" />
|
<MenuItem Header="TODO" />
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem Header="Image"
|
||||||
|
IsEnabled="{Binding ImageLoaded, Mode=OneWay}">
|
||||||
|
<MenuItem Command="{Binding CalculateEntropyCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Calculate_entropy}" />
|
||||||
|
<MenuItem Command="{Binding VerifyImageCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Verify}" />
|
||||||
|
<MenuItem Command="{Binding ChecksumImageCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Checksum}" />
|
||||||
|
<MenuItem Command="{Binding ConvertImageCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Convert_to}" />
|
||||||
|
<MenuItem Command="{Binding CreateSidecarCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Create_Aaru_Metadata_sidecar}" />
|
||||||
|
<MenuItem Command="{Binding ViewImageSectorsCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_View_sectors}" />
|
||||||
|
<MenuItem Command="{Binding DecodeImageMediaTagsCommand, Mode=OneWay}"
|
||||||
|
Header="{x:Static localization:UI.ButtonLabel_Decode_media_tags}" />
|
||||||
|
</MenuItem>
|
||||||
<MenuItem Header="{x:Static localization:UI.Menu_Window}">
|
<MenuItem Header="{x:Static localization:UI.Menu_Window}">
|
||||||
<MenuItem Header="{x:Static localization:UI.Menu_Console}"
|
<MenuItem Header="{x:Static localization:UI.Menu_Console}"
|
||||||
Command="{Binding ConsoleCommand, Mode=OneWay}" />
|
Command="{Binding ConsoleCommand, Mode=OneWay}" />
|
||||||
@@ -83,7 +100,8 @@
|
|||||||
<Image Width="24"
|
<Image Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
<TextBlock Text="{Binding FileName, Mode=OneWay}" VerticalAlignment="Center"/>
|
<TextBlock Text="{Binding FileName, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TreeDataTemplate>
|
</TreeDataTemplate>
|
||||||
<TreeDataTemplate DataType="models:PartitionSchemeModel"
|
<TreeDataTemplate DataType="models:PartitionSchemeModel"
|
||||||
@@ -92,7 +110,8 @@
|
|||||||
<Image Width="24"
|
<Image Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}" VerticalAlignment="Center"/>
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TreeDataTemplate>
|
</TreeDataTemplate>
|
||||||
<TreeDataTemplate DataType="models:PartitionModel"
|
<TreeDataTemplate DataType="models:PartitionModel"
|
||||||
@@ -101,7 +120,8 @@
|
|||||||
<Image Width="24"
|
<Image Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}" VerticalAlignment="Center"/>
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TreeDataTemplate>
|
</TreeDataTemplate>
|
||||||
<TreeDataTemplate DataType="models:FileSystemModel"
|
<TreeDataTemplate DataType="models:FileSystemModel"
|
||||||
@@ -110,7 +130,8 @@
|
|||||||
<Image Width="24"
|
<Image Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
<TextBlock Text="{Binding VolumeName, Mode=OneWay}" VerticalAlignment="Center"/>
|
<TextBlock Text="{Binding VolumeName, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TreeDataTemplate>
|
</TreeDataTemplate>
|
||||||
<TreeDataTemplate DataType="models:SubdirectoryModel"
|
<TreeDataTemplate DataType="models:SubdirectoryModel"
|
||||||
@@ -119,7 +140,8 @@
|
|||||||
<Image Width="24"
|
<Image Width="24"
|
||||||
Height="24"
|
Height="24"
|
||||||
Source="{Binding Icon, Mode=OneWay}" />
|
Source="{Binding Icon, Mode=OneWay}" />
|
||||||
<TextBlock Text="{Binding Name, Mode=OneWay}" VerticalAlignment="Center"/>
|
<TextBlock Text="{Binding Name, Mode=OneWay}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TreeDataTemplate>
|
</TreeDataTemplate>
|
||||||
<DataTemplate DataType="models:RootModel">
|
<DataTemplate DataType="models:RootModel">
|
||||||
|
|||||||
Reference in New Issue
Block a user