Move to file scoped namespaces.

This commit is contained in:
2022-03-06 13:29:38 +00:00
parent b6c3a54955
commit 0bc819feab
1322 changed files with 268651 additions and 270003 deletions

View File

@@ -43,76 +43,76 @@ using Aaru.Gui.Views.Dialogs;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class AboutViewModel : ViewModelBase
{
public sealed class AboutViewModel : ViewModelBase
readonly About _view;
string _versionText;
public AboutViewModel(About view)
{
readonly About _view;
string _versionText;
_view = view;
public AboutViewModel(About view)
VersionText =
(Attribute.GetCustomAttribute(typeof(App).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute)?.InformationalVersion;
WebsiteCommand = ReactiveCommand.Create(ExecuteWebsiteCommand);
LicenseCommand = ReactiveCommand.Create(ExecuteLicenseCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
Assemblies = new ObservableCollection<AssemblyModel>();
Task.Run(() =>
{
_view = view;
VersionText =
(Attribute.GetCustomAttribute(typeof(App).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute)?.InformationalVersion;
WebsiteCommand = ReactiveCommand.Create(ExecuteWebsiteCommand);
LicenseCommand = ReactiveCommand.Create(ExecuteLicenseCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
Assemblies = new ObservableCollection<AssemblyModel>();
Task.Run(() =>
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
{
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
string name = assembly.GetName().Name;
string version =
(Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute)?.InformationalVersion;
if(name is null ||
version is null)
continue;
Assemblies.Add(new AssemblyModel
{
string name = assembly.GetName().Name;
Name = name,
Version = version
});
}
});
}
string version =
(Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute)?.InformationalVersion;
if(name is null ||
version is null)
continue;
Assemblies.Add(new AssemblyModel
{
Name = name,
Version = version
});
}
});
}
[NotNull]
public string AboutLabel => "About";
[NotNull]
public string LibrariesLabel => "Libraries";
[NotNull]
public string AuthorsLabel => "Authors";
[NotNull]
public string Title => "About Aaru";
[NotNull]
public string SoftwareName => "Aaru";
[NotNull]
public string SuiteName => "Aaru Data Preservation Suite";
[NotNull]
public string Copyright => "© 2011-2022 Natalia Portillo";
[NotNull]
public string Website => "https://aaru.app";
[NotNull]
public string License => "License: GNU General Public License Version 3";
[NotNull]
public string CloseLabel => "Close";
[NotNull]
public string AssembliesLibraryText => "Library";
[NotNull]
public string AssembliesVersionText => "Version";
[NotNull]
public string Authors => @"Developers:
[NotNull]
public string AboutLabel => "About";
[NotNull]
public string LibrariesLabel => "Libraries";
[NotNull]
public string AuthorsLabel => "Authors";
[NotNull]
public string Title => "About Aaru";
[NotNull]
public string SoftwareName => "Aaru";
[NotNull]
public string SuiteName => "Aaru Data Preservation Suite";
[NotNull]
public string Copyright => "© 2011-2022 Natalia Portillo";
[NotNull]
public string Website => "https://aaru.app";
[NotNull]
public string License => "License: GNU General Public License Version 3";
[NotNull]
public string CloseLabel => "Close";
[NotNull]
public string AssembliesLibraryText => "Library";
[NotNull]
public string AssembliesVersionText => "Version";
[NotNull]
public string Authors => @"Developers:
Natalia Portillo
Michael Drüing
Rebecca Wallander
@@ -125,51 +125,50 @@ Public relations:
Logo and art:
Juan Carlos Pastor Segura (Denymetanol)";
public ReactiveCommand<Unit, Unit> WebsiteCommand { get; }
public ReactiveCommand<Unit, Unit> LicenseCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<AssemblyModel> Assemblies { get; }
public ReactiveCommand<Unit, Unit> WebsiteCommand { get; }
public ReactiveCommand<Unit, Unit> LicenseCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<AssemblyModel> Assemblies { get; }
public string VersionText
{
get => _versionText;
set => this.RaiseAndSetIfChanged(ref _versionText, value);
}
void ExecuteWebsiteCommand()
{
var process = new Process
{
StartInfo =
{
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "https://aaru.app"
}
};
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
process.StartInfo.FileName = "cmd";
process.StartInfo.Arguments = $"/c start {process.StartInfo.Arguments.Replace("&", "^&")}";
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
process.StartInfo.FileName = "xdg-open";
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
process.StartInfo.FileName = "open";
else
return;
process.Start();
}
void ExecuteLicenseCommand()
{
var dialog = new LicenseDialog();
dialog.DataContext = new LicenseViewModel(dialog);
dialog.ShowDialog(_view);
}
void ExecuteCloseCommand() => _view.Close();
public string VersionText
{
get => _versionText;
set => this.RaiseAndSetIfChanged(ref _versionText, value);
}
void ExecuteWebsiteCommand()
{
var process = new Process
{
StartInfo =
{
UseShellExecute = false,
CreateNoWindow = true,
Arguments = "https://aaru.app"
}
};
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
process.StartInfo.FileName = "cmd";
process.StartInfo.Arguments = $"/c start {process.StartInfo.Arguments.Replace("&", "^&")}";
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
process.StartInfo.FileName = "xdg-open";
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
process.StartInfo.FileName = "open";
else
return;
process.Start();
}
void ExecuteLicenseCommand()
{
var dialog = new LicenseDialog();
dialog.DataContext = new LicenseViewModel(dialog);
dialog.ShowDialog(_view);
}
void ExecuteCloseCommand() => _view.Close();
}

View File

@@ -46,116 +46,115 @@ using ReactiveUI;
using PlatformID = Aaru.CommonTypes.Interop.PlatformID;
using Version = Aaru.CommonTypes.Interop.Version;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class ConsoleViewModel : ViewModelBase
{
public sealed class ConsoleViewModel : ViewModelBase
readonly Views.Dialogs.Console _view;
bool _debugChecked;
public ConsoleViewModel(Views.Dialogs.Console view)
{
readonly Views.Dialogs.Console _view;
bool _debugChecked;
public ConsoleViewModel(Views.Dialogs.Console view)
{
_view = view;
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
ClearCommand = ReactiveCommand.Create(ExecuteClearCommand);
}
[NotNull]
public string Title => "Console";
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
public ObservableCollection<LogEntry> Entries => ConsoleHandler.Entries;
[NotNull]
public string DebugText => "Enable debug console";
[NotNull]
public string SaveLabel => "Save";
[NotNull]
public string ClearLabel => "Clear";
public bool DebugChecked
{
get => _debugChecked;
set
{
ConsoleHandler.Debug = value;
this.RaiseAndSetIfChanged(ref _debugChecked, value);
}
}
async void ExecuteSaveCommand()
{
var dlgSave = new SaveFileDialog();
dlgSave.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"log"
}),
Name = "Log files"
});
string result = await dlgSave.ShowAsync(_view);
if(result is null)
return;
try
{
var logFs = new FileStream(result, FileMode.Create, FileAccess.ReadWrite);
var logSw = new StreamWriter(logFs);
logSw.WriteLine("Log saved at {0}", DateTime.Now);
PlatformID platId = DetectOS.GetRealPlatformID();
string platVer = DetectOS.GetVersion();
var assemblyVersion =
Attribute.GetCustomAttribute(typeof(AaruConsole).Assembly,
typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute;
logSw.WriteLine("################# System information #################");
logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer,
Environment.Is64BitOperatingSystem ? 64 : 32);
logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion());
logSw.WriteLine();
logSw.WriteLine("################# Program information ################");
logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion);
logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32);
#if DEBUG
logSw.WriteLine("DEBUG version");
#endif
logSw.WriteLine("Command line: {0}", Environment.CommandLine);
logSw.WriteLine();
logSw.WriteLine("################# Console ################");
foreach(LogEntry entry in ConsoleHandler.Entries)
if(entry.Type != "Info")
logSw.WriteLine("{0}: ({1}) {2}", entry.Timestamp, entry.Type.ToLower(), entry.Message);
else
logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message);
logSw.Close();
logFs.Close();
}
catch(Exception exception)
{
await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Exception {exception.Message} trying to save logfile, details has been sent to console.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
AaruConsole.ErrorWriteLine("Console", exception.Message);
AaruConsole.ErrorWriteLine("Console", exception.StackTrace);
}
}
void ExecuteClearCommand() => ConsoleHandler.Entries.Clear();
_view = view;
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
ClearCommand = ReactiveCommand.Create(ExecuteClearCommand);
}
[NotNull]
public string Title => "Console";
public ReactiveCommand<Unit, Unit> ClearCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
public ObservableCollection<LogEntry> Entries => ConsoleHandler.Entries;
[NotNull]
public string DebugText => "Enable debug console";
[NotNull]
public string SaveLabel => "Save";
[NotNull]
public string ClearLabel => "Clear";
public bool DebugChecked
{
get => _debugChecked;
set
{
ConsoleHandler.Debug = value;
this.RaiseAndSetIfChanged(ref _debugChecked, value);
}
}
async void ExecuteSaveCommand()
{
var dlgSave = new SaveFileDialog();
dlgSave.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"log"
}),
Name = "Log files"
});
string result = await dlgSave.ShowAsync(_view);
if(result is null)
return;
try
{
var logFs = new FileStream(result, FileMode.Create, FileAccess.ReadWrite);
var logSw = new StreamWriter(logFs);
logSw.WriteLine("Log saved at {0}", DateTime.Now);
PlatformID platId = DetectOS.GetRealPlatformID();
string platVer = DetectOS.GetVersion();
var assemblyVersion =
Attribute.GetCustomAttribute(typeof(AaruConsole).Assembly,
typeof(AssemblyInformationalVersionAttribute)) as
AssemblyInformationalVersionAttribute;
logSw.WriteLine("################# System information #################");
logSw.WriteLine("{0} {1} ({2}-bit)", DetectOS.GetPlatformName(platId, platVer), platVer,
Environment.Is64BitOperatingSystem ? 64 : 32);
logSw.WriteLine(".NET Core {0}", Version.GetNetCoreVersion());
logSw.WriteLine();
logSw.WriteLine("################# Program information ################");
logSw.WriteLine("Aaru {0}", assemblyVersion?.InformationalVersion);
logSw.WriteLine("Running in {0}-bit", Environment.Is64BitProcess ? 64 : 32);
#if DEBUG
logSw.WriteLine("DEBUG version");
#endif
logSw.WriteLine("Command line: {0}", Environment.CommandLine);
logSw.WriteLine();
logSw.WriteLine("################# Console ################");
foreach(LogEntry entry in ConsoleHandler.Entries)
if(entry.Type != "Info")
logSw.WriteLine("{0}: ({1}) {2}", entry.Timestamp, entry.Type.ToLower(), entry.Message);
else
logSw.WriteLine("{0}: {1}", entry.Timestamp, entry.Message);
logSw.Close();
logFs.Close();
}
catch(Exception exception)
{
await MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Exception {exception.Message} trying to save logfile, details has been sent to console.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
AaruConsole.ErrorWriteLine("Console", exception.Message);
AaruConsole.ErrorWriteLine("Console", exception.StackTrace);
}
}
void ExecuteClearCommand() => ConsoleHandler.Entries.Clear();
}

View File

@@ -41,44 +41,43 @@ using Aaru.Gui.Views.Dialogs;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class EncodingsViewModel : ViewModelBase
{
public sealed class EncodingsViewModel : ViewModelBase
readonly Encodings _view;
public EncodingsViewModel(Encodings view)
{
readonly Encodings _view;
_view = view;
Encodings = new ObservableCollection<EncodingModel>();
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
public EncodingsViewModel(Encodings view)
Task.Run(() =>
{
_view = view;
Encodings = new ObservableCollection<EncodingModel>();
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
Task.Run(() =>
List<EncodingModel> encodings = Encoding.GetEncodings().Select(info => new EncodingModel
{
List<EncodingModel> encodings = Encoding.GetEncodings().Select(info => new EncodingModel
{
Name = info.Name,
DisplayName = info.GetEncoding().EncodingName
}).ToList();
Name = info.Name,
DisplayName = info.GetEncoding().EncodingName
}).ToList();
encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new EncodingModel
{
Name = info.Name,
DisplayName = info.DisplayName
}));
encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new EncodingModel
{
Name = info.Name,
DisplayName = info.DisplayName
}));
foreach(EncodingModel encoding in encodings.OrderBy(t => t.DisplayName))
Encodings.Add(encoding);
});
}
[NotNull]
public string Title => "Encodings";
[NotNull]
public string CloseLabel => "Close";
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<EncodingModel> Encodings { get; }
void ExecuteCloseCommand() => _view.Close();
foreach(EncodingModel encoding in encodings.OrderBy(t => t.DisplayName))
Encodings.Add(encoding);
});
}
[NotNull]
public string Title => "Encodings";
[NotNull]
public string CloseLabel => "Close";
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<EncodingModel> Encodings { get; }
void ExecuteCloseCommand() => _view.Close();
}

View File

@@ -37,35 +37,34 @@ using Aaru.Gui.Views.Dialogs;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class LicenseViewModel : ViewModelBase
{
public sealed class LicenseViewModel : ViewModelBase
readonly LicenseDialog _view;
string _versionText;
public LicenseViewModel(LicenseDialog view)
{
readonly LicenseDialog _view;
string _versionText;
_view = view;
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
public LicenseViewModel(LicenseDialog view)
{
_view = view;
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Gui.LICENSE");
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Gui.LICENSE");
if(stream == null)
return;
if(stream == null)
return;
using var reader = new StreamReader(stream);
using var reader = new StreamReader(stream);
LicenseText = reader.ReadToEnd();
}
[NotNull]
public string Title => "Aaru's license";
[NotNull]
public string CloseLabel => "Close";
public string LicenseText { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
void ExecuteCloseCommand() => _view.Close();
LicenseText = reader.ReadToEnd();
}
[NotNull]
public string Title => "Aaru's license";
[NotNull]
public string CloseLabel => "Close";
public string LicenseText { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
void ExecuteCloseCommand() => _view.Close();
}

View File

@@ -40,129 +40,128 @@ using Aaru.Gui.Views.Dialogs;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class PluginsViewModel : ViewModelBase
{
public sealed class PluginsViewModel : ViewModelBase
readonly PluginsDialog _view;
public PluginsViewModel(PluginsDialog view)
{
readonly PluginsDialog _view;
_view = view;
Filters = new ObservableCollection<PluginModel>();
PartitionSchemes = new ObservableCollection<PluginModel>();
Filesystems = new ObservableCollection<PluginModel>();
ReadOnlyFilesystems = new ObservableCollection<PluginModel>();
Images = new ObservableCollection<PluginModel>();
WritableImages = new ObservableCollection<PluginModel>();
FloppyImages = new ObservableCollection<PluginModel>();
WritableFloppyImages = new ObservableCollection<PluginModel>();
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
public PluginsViewModel(PluginsDialog view)
{
_view = view;
Filters = new ObservableCollection<PluginModel>();
PartitionSchemes = new ObservableCollection<PluginModel>();
Filesystems = new ObservableCollection<PluginModel>();
ReadOnlyFilesystems = new ObservableCollection<PluginModel>();
Images = new ObservableCollection<PluginModel>();
WritableImages = new ObservableCollection<PluginModel>();
FloppyImages = new ObservableCollection<PluginModel>();
WritableFloppyImages = new ObservableCollection<PluginModel>();
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
// TODO: Takes too much time
foreach(IFilter filter in GetPluginBase.Instance.Filters.Values)
Filters.Add(new PluginModel
{
Name = filter.Name,
Uuid = filter.Id,
Version = Assembly.GetAssembly(filter.GetType())?.GetName().Version?.ToString(),
Author = filter.Author
});
// TODO: Takes too much time
foreach(IFilter filter in GetPluginBase.Instance.Filters.Values)
Filters.Add(new PluginModel
{
Name = filter.Name,
Uuid = filter.Id,
Version = Assembly.GetAssembly(filter.GetType())?.GetName().Version?.ToString(),
Author = filter.Author
});
foreach(IFloppyImage floppyImage in GetPluginBase.Instance.FloppyImages.Values)
FloppyImages.Add(new PluginModel
{
Name = floppyImage.Name,
Uuid = floppyImage.Id,
Version = Assembly.GetAssembly(floppyImage.GetType())?.GetName().Version?.ToString(),
Author = floppyImage.Author
});
foreach(IFloppyImage floppyImage in GetPluginBase.Instance.FloppyImages.Values)
FloppyImages.Add(new PluginModel
{
Name = floppyImage.Name,
Uuid = floppyImage.Id,
Version = Assembly.GetAssembly(floppyImage.GetType())?.GetName().Version?.ToString(),
Author = floppyImage.Author
});
foreach(IMediaImage mediaImage in GetPluginBase.Instance.ImagePluginsList.Values)
Images.Add(new PluginModel
{
Name = mediaImage.Name,
Uuid = mediaImage.Id,
Version = Assembly.GetAssembly(mediaImage.GetType())?.GetName().Version?.ToString(),
Author = mediaImage.Author
});
foreach(IMediaImage mediaImage in GetPluginBase.Instance.ImagePluginsList.Values)
Images.Add(new PluginModel
{
Name = mediaImage.Name,
Uuid = mediaImage.Id,
Version = Assembly.GetAssembly(mediaImage.GetType())?.GetName().Version?.ToString(),
Author = mediaImage.Author
});
foreach(IPartition partition in GetPluginBase.Instance.PartPluginsList.Values)
PartitionSchemes.Add(new PluginModel
{
Name = partition.Name,
Uuid = partition.Id,
Version = Assembly.GetAssembly(partition.GetType())?.GetName().Version?.ToString(),
Author = partition.Author
});
foreach(IPartition partition in GetPluginBase.Instance.PartPluginsList.Values)
PartitionSchemes.Add(new PluginModel
{
Name = partition.Name,
Uuid = partition.Id,
Version = Assembly.GetAssembly(partition.GetType())?.GetName().Version?.ToString(),
Author = partition.Author
});
foreach(IFilesystem filesystem in GetPluginBase.Instance.PluginsList.Values)
Filesystems.Add(new PluginModel
{
Name = filesystem.Name,
Uuid = filesystem.Id,
Version = Assembly.GetAssembly(filesystem.GetType())?.GetName().Version?.ToString(),
Author = filesystem.Author
});
foreach(IFilesystem filesystem in GetPluginBase.Instance.PluginsList.Values)
Filesystems.Add(new PluginModel
{
Name = filesystem.Name,
Uuid = filesystem.Id,
Version = Assembly.GetAssembly(filesystem.GetType())?.GetName().Version?.ToString(),
Author = filesystem.Author
});
foreach(IReadOnlyFilesystem readOnlyFilesystem in GetPluginBase.Instance.ReadOnlyFilesystems.Values)
ReadOnlyFilesystems.Add(new PluginModel
{
Name = readOnlyFilesystem.Name,
Uuid = readOnlyFilesystem.Id,
Version = Assembly.GetAssembly(readOnlyFilesystem.GetType())?.GetName().Version?.ToString(),
Author = readOnlyFilesystem.Author
});
foreach(IReadOnlyFilesystem readOnlyFilesystem in GetPluginBase.Instance.ReadOnlyFilesystems.Values)
ReadOnlyFilesystems.Add(new PluginModel
{
Name = readOnlyFilesystem.Name,
Uuid = readOnlyFilesystem.Id,
Version = Assembly.GetAssembly(readOnlyFilesystem.GetType())?.GetName().Version?.ToString(),
Author = readOnlyFilesystem.Author
});
foreach(IWritableFloppyImage writableFloppyImage in GetPluginBase.Instance.WritableFloppyImages.Values)
WritableFloppyImages.Add(new PluginModel
{
Name = writableFloppyImage.Name,
Uuid = writableFloppyImage.Id,
Version = Assembly.GetAssembly(writableFloppyImage.GetType())?.GetName().Version?.ToString(),
Author = writableFloppyImage.Author
});
foreach(IWritableFloppyImage writableFloppyImage in GetPluginBase.Instance.WritableFloppyImages.Values)
WritableFloppyImages.Add(new PluginModel
{
Name = writableFloppyImage.Name,
Uuid = writableFloppyImage.Id,
Version = Assembly.GetAssembly(writableFloppyImage.GetType())?.GetName().Version?.ToString(),
Author = writableFloppyImage.Author
});
foreach(IWritableImage writableImage in GetPluginBase.Instance.WritableImages.Values)
WritableImages.Add(new PluginModel
{
Name = writableImage.Name,
Uuid = writableImage.Id,
Version = Assembly.GetAssembly(writableImage.GetType())?.GetName().Version?.ToString(),
Author = writableImage.Author
});
}
[NotNull]
public string Title => "Plugins";
[NotNull]
public string FiltersLabel => "Filters";
[NotNull]
public string PartitionsLabel => "Partitions";
[NotNull]
public string FilesystemsLabel => "Filesystems";
[NotNull]
public string IdentifyLabel => "Identify only:";
[NotNull]
public string ImagesLabel => "Media images";
[NotNull]
public string FloppyImagesLabel => "Floppy images";
[NotNull]
public string ReadableLabel => "Readable:";
[NotNull]
public string WritableLabel => "Writable:";
[NotNull]
public string CloseLabel => "Close";
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<PluginModel> Filters { get; }
public ObservableCollection<PluginModel> PartitionSchemes { get; }
public ObservableCollection<PluginModel> Filesystems { get; }
public ObservableCollection<PluginModel> ReadOnlyFilesystems { get; }
public ObservableCollection<PluginModel> Images { get; }
public ObservableCollection<PluginModel> WritableImages { get; }
public ObservableCollection<PluginModel> FloppyImages { get; }
public ObservableCollection<PluginModel> WritableFloppyImages { get; }
void ExecuteCloseCommand() => _view.Close();
foreach(IWritableImage writableImage in GetPluginBase.Instance.WritableImages.Values)
WritableImages.Add(new PluginModel
{
Name = writableImage.Name,
Uuid = writableImage.Id,
Version = Assembly.GetAssembly(writableImage.GetType())?.GetName().Version?.ToString(),
Author = writableImage.Author
});
}
[NotNull]
public string Title => "Plugins";
[NotNull]
public string FiltersLabel => "Filters";
[NotNull]
public string PartitionsLabel => "Partitions";
[NotNull]
public string FilesystemsLabel => "Filesystems";
[NotNull]
public string IdentifyLabel => "Identify only:";
[NotNull]
public string ImagesLabel => "Media images";
[NotNull]
public string FloppyImagesLabel => "Floppy images";
[NotNull]
public string ReadableLabel => "Readable:";
[NotNull]
public string WritableLabel => "Writable:";
[NotNull]
public string CloseLabel => "Close";
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<PluginModel> Filters { get; }
public ObservableCollection<PluginModel> PartitionSchemes { get; }
public ObservableCollection<PluginModel> Filesystems { get; }
public ObservableCollection<PluginModel> ReadOnlyFilesystems { get; }
public ObservableCollection<PluginModel> Images { get; }
public ObservableCollection<PluginModel> WritableImages { get; }
public ObservableCollection<PluginModel> FloppyImages { get; }
public ObservableCollection<PluginModel> WritableFloppyImages { get; }
void ExecuteCloseCommand() => _view.Close();
}

View File

@@ -36,91 +36,91 @@ using Aaru.Settings;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Dialogs
namespace Aaru.Gui.ViewModels.Dialogs;
public sealed class SettingsViewModel : ViewModelBase
{
public sealed class SettingsViewModel : ViewModelBase
readonly SettingsDialog _view;
bool _commandStatsChecked;
bool _deviceStatsChecked;
bool _filesystemStatsChecked;
bool _filterStatsChecked;
bool _gdprVisible;
bool _mediaImageStatsChecked;
bool _mediaScanStatsChecked;
bool _mediaStatsChecked;
bool _partitionStatsChecked;
bool _saveReportsGloballyChecked;
bool _saveStatsChecked;
bool _shareReportsChecked;
bool _shareStatsChecked;
int _tabControlSelectedIndex;
bool _verifyStatsChecked;
public SettingsViewModel(SettingsDialog view, bool gdprChange)
{
readonly SettingsDialog _view;
bool _commandStatsChecked;
bool _deviceStatsChecked;
bool _filesystemStatsChecked;
bool _filterStatsChecked;
bool _gdprVisible;
bool _mediaImageStatsChecked;
bool _mediaScanStatsChecked;
bool _mediaStatsChecked;
bool _partitionStatsChecked;
bool _saveReportsGloballyChecked;
bool _saveStatsChecked;
bool _shareReportsChecked;
bool _shareStatsChecked;
int _tabControlSelectedIndex;
bool _verifyStatsChecked;
_view = view;
GdprVisible = gdprChange;
SaveReportsGloballyChecked = Settings.Settings.Current.SaveReportsGlobally;
ShareReportsChecked = Settings.Settings.Current.ShareReports;
public SettingsViewModel(SettingsDialog view, bool gdprChange)
if(Settings.Settings.Current.Stats != null)
{
_view = view;
GdprVisible = gdprChange;
SaveReportsGloballyChecked = Settings.Settings.Current.SaveReportsGlobally;
ShareReportsChecked = Settings.Settings.Current.ShareReports;
if(Settings.Settings.Current.Stats != null)
{
SaveStatsChecked = true;
ShareStatsChecked = Settings.Settings.Current.Stats.ShareStats;
CommandStatsChecked = Settings.Settings.Current.Stats.CommandStats;
DeviceStatsChecked = Settings.Settings.Current.Stats.DeviceStats;
FilesystemStatsChecked = Settings.Settings.Current.Stats.FilesystemStats;
FilterStatsChecked = Settings.Settings.Current.Stats.FilterStats;
MediaImageStatsChecked = Settings.Settings.Current.Stats.MediaImageStats;
MediaScanStatsChecked = Settings.Settings.Current.Stats.MediaScanStats;
PartitionStatsChecked = Settings.Settings.Current.Stats.PartitionStats;
MediaStatsChecked = Settings.Settings.Current.Stats.MediaStats;
VerifyStatsChecked = Settings.Settings.Current.Stats.VerifyStats;
}
else
SaveStatsChecked = false;
CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand);
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
if(!_gdprVisible)
_tabControlSelectedIndex = 1;
SaveStatsChecked = true;
ShareStatsChecked = Settings.Settings.Current.Stats.ShareStats;
CommandStatsChecked = Settings.Settings.Current.Stats.CommandStats;
DeviceStatsChecked = Settings.Settings.Current.Stats.DeviceStats;
FilesystemStatsChecked = Settings.Settings.Current.Stats.FilesystemStats;
FilterStatsChecked = Settings.Settings.Current.Stats.FilterStats;
MediaImageStatsChecked = Settings.Settings.Current.Stats.MediaImageStats;
MediaScanStatsChecked = Settings.Settings.Current.Stats.MediaScanStats;
PartitionStatsChecked = Settings.Settings.Current.Stats.PartitionStats;
MediaStatsChecked = Settings.Settings.Current.Stats.MediaStats;
VerifyStatsChecked = Settings.Settings.Current.Stats.VerifyStats;
}
else
SaveStatsChecked = false;
// TODO: Show Preferences in macOS
[NotNull]
public string Title => "Settings";
[NotNull]
public string GdprLabel => "GDPR";
[NotNull]
public string ReportsLabel => "Reports";
[NotNull]
public string StatisticsLabel => "Statistics";
[NotNull]
public string SaveLabel => "Save";
[NotNull]
public string CancelLabel => "Cancel";
[NotNull]
public string GdprText1 =>
@"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),
CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand);
SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
if(!_gdprVisible)
_tabControlSelectedIndex = 1;
}
// TODO: Show Preferences in macOS
[NotNull]
public string Title => "Settings";
[NotNull]
public string GdprLabel => "GDPR";
[NotNull]
public string ReportsLabel => "Reports";
[NotNull]
public string StatisticsLabel => "Statistics";
[NotNull]
public string SaveLabel => "Save";
[NotNull]
public string CancelLabel => "Cancel";
[NotNull]
public string GdprText1 =>
@"In compliance with the European Union General Data Protection Regulation 2016/679 (GDPR),
we must give you the following information about Aaru and ask if you want to opt-in
in some information sharing.";
[NotNull]
public string GdprText2 =>
@"Disclaimer: Because Aaru is an open source software this information, and therefore,
[NotNull]
public string GdprText2 =>
@"Disclaimer: Because Aaru is an open source software this information, and therefore,
compliance with GDPR only holds true if you obtained a certificated copy from its original
authors. In case of doubt, close Aaru now and ask in our IRC support channel.";
[NotNull]
public string GdprText3 =>
@"For any information sharing your IP address may be stored in our server, in a way that is not
[NotNull]
public string GdprText3 =>
@"For any information sharing your IP address may be stored in our server, in a way that is not
possible for any person, manual, or automated process, to link with your identity, unless
specified otherwise.";
[NotNull]
public string ReportsGloballyText =>
@"With the 'device-report' command, Aaru creates a report of a device, that includes its
[NotNull]
public string ReportsGloballyText =>
@"With the 'device-report' command, Aaru creates a report of a device, that includes its
manufacturer, model, firmware revision and/or version, attached bus, size, and supported commands.
The serial number of the device is not stored in the report. If used with the debug parameter,
extra information about the device will be stored in the report. This information is known to contain
@@ -128,169 +128,168 @@ the device serial number in non-standard places that prevent the automatic remov
of devices. A human-readable copy of the report in XML format is always created in the same directory
where Aaru is being run from.";
[NotNull]
public string SaveReportsGloballyText => "Save device reports in shared folder of your computer?";
[NotNull]
public string SaveReportsGloballyText => "Save device reports in shared folder of your computer?";
[NotNull]
public string ReportsText =>
@"Sharing a report with us will send it to our server, that's in the european union territory, where it
[NotNull]
public string ReportsText =>
@"Sharing a report with us will send it to our server, that's in the european union territory, where it
will be manually analyzed by an european union citizen to remove any trace of personal identification
from it. Once that is done, it will be shared in our stats website, https://www.aaru.app
These report will be used to improve Aaru support, and in some cases, to provide emulation of the
devices to other open-source projects. In any case, no information linking the report to you will be stored.";
[NotNull]
public string ShareReportsText => "Share your device reports with us?";
[NotNull]
public string StatisticsText =>
@"Aaru can store some usage statistics. These statistics are limited to the number of times a
[NotNull]
public string ShareReportsText => "Share your device reports with us?";
[NotNull]
public string StatisticsText =>
@"Aaru can store some usage statistics. These statistics are limited to the number of times a
command is executed, a filesystem, partition, or device is used, the operating system version, and other.
In no case, any information besides pure statistical usage numbers is stored, and they're just joint to the
pool with no way of using them to identify you.";
[NotNull]
public string SaveStatsText => "Save stats about your Aaru usage?";
[NotNull]
public string ShareStatsText => "Share your stats (anonymously)?";
[NotNull]
public string CommandStatsText => "Gather statistics about command usage?";
[NotNull]
public string DeviceStatsText => "Gather statistics about found devices?";
[NotNull]
public string FilesystemStatsText => "Gather statistics about found filesystems?";
[NotNull]
public string FilterStatsText => "Gather statistics about found file filters?";
[NotNull]
public string MediaImageStatsText => "Gather statistics about found media image formats?";
[NotNull]
public string MediaScanStatsText => "Gather statistics about scanned media?";
[NotNull]
public string PartitionStatsText => "Gather statistics about found partitioning schemes?";
[NotNull]
public string MediaStatsText => "Gather statistics about media types?";
[NotNull]
public string VerifyStatsText => "Gather statistics about media image verifications?";
[NotNull]
public string SaveStatsText => "Save stats about your Aaru usage?";
[NotNull]
public string ShareStatsText => "Share your stats (anonymously)?";
[NotNull]
public string CommandStatsText => "Gather statistics about command usage?";
[NotNull]
public string DeviceStatsText => "Gather statistics about found devices?";
[NotNull]
public string FilesystemStatsText => "Gather statistics about found filesystems?";
[NotNull]
public string FilterStatsText => "Gather statistics about found file filters?";
[NotNull]
public string MediaImageStatsText => "Gather statistics about found media image formats?";
[NotNull]
public string MediaScanStatsText => "Gather statistics about scanned media?";
[NotNull]
public string PartitionStatsText => "Gather statistics about found partitioning schemes?";
[NotNull]
public string MediaStatsText => "Gather statistics about media types?";
[NotNull]
public string VerifyStatsText => "Gather statistics about media image verifications?";
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
public ReactiveCommand<Unit, Unit> CancelCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCommand { get; }
public bool GdprVisible
{
get => _gdprVisible;
set => this.RaiseAndSetIfChanged(ref _gdprVisible, value);
}
public bool SaveReportsGloballyChecked
{
get => _saveReportsGloballyChecked;
set => this.RaiseAndSetIfChanged(ref _saveReportsGloballyChecked, value);
}
public bool ShareReportsChecked
{
get => _shareReportsChecked;
set => this.RaiseAndSetIfChanged(ref _shareReportsChecked, value);
}
public bool SaveStatsChecked
{
get => _saveStatsChecked;
set => this.RaiseAndSetIfChanged(ref _saveStatsChecked, value);
}
public bool ShareStatsChecked
{
get => _shareStatsChecked;
set => this.RaiseAndSetIfChanged(ref _shareStatsChecked, value);
}
public bool CommandStatsChecked
{
get => _commandStatsChecked;
set => this.RaiseAndSetIfChanged(ref _commandStatsChecked, value);
}
public bool DeviceStatsChecked
{
get => _deviceStatsChecked;
set => this.RaiseAndSetIfChanged(ref _deviceStatsChecked, value);
}
public bool FilesystemStatsChecked
{
get => _filesystemStatsChecked;
set => this.RaiseAndSetIfChanged(ref _filesystemStatsChecked, value);
}
public bool FilterStatsChecked
{
get => _filterStatsChecked;
set => this.RaiseAndSetIfChanged(ref _filterStatsChecked, value);
}
public bool MediaImageStatsChecked
{
get => _mediaImageStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaImageStatsChecked, value);
}
public bool MediaScanStatsChecked
{
get => _mediaScanStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaScanStatsChecked, value);
}
public bool PartitionStatsChecked
{
get => _partitionStatsChecked;
set => this.RaiseAndSetIfChanged(ref _partitionStatsChecked, value);
}
public bool MediaStatsChecked
{
get => _mediaStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaStatsChecked, value);
}
public bool VerifyStatsChecked
{
get => _verifyStatsChecked;
set => this.RaiseAndSetIfChanged(ref _verifyStatsChecked, value);
}
public int TabControlSelectedIndex
{
get => _tabControlSelectedIndex;
set => this.RaiseAndSetIfChanged(ref _tabControlSelectedIndex, value);
}
void ExecuteSaveCommand()
{
Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked;
Settings.Settings.Current.ShareReports = ShareReportsChecked;
if(SaveStatsChecked)
Settings.Settings.Current.Stats = new StatsSettings
{
ShareStats = ShareStatsChecked,
CommandStats = CommandStatsChecked,
DeviceStats = DeviceStatsChecked,
FilesystemStats = FilesystemStatsChecked,
FilterStats = FilterStatsChecked,
MediaImageStats = MediaImageStatsChecked,
MediaScanStats = MediaScanStatsChecked,
PartitionStats = PartitionStatsChecked,
MediaStats = MediaStatsChecked,
VerifyStats = VerifyStatsChecked
};
else
Settings.Settings.Current.Stats = null;
Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
Settings.Settings.SaveSettings();
_view.Close();
}
void ExecuteCancelCommand() => _view.Close();
public bool GdprVisible
{
get => _gdprVisible;
set => this.RaiseAndSetIfChanged(ref _gdprVisible, value);
}
public bool SaveReportsGloballyChecked
{
get => _saveReportsGloballyChecked;
set => this.RaiseAndSetIfChanged(ref _saveReportsGloballyChecked, value);
}
public bool ShareReportsChecked
{
get => _shareReportsChecked;
set => this.RaiseAndSetIfChanged(ref _shareReportsChecked, value);
}
public bool SaveStatsChecked
{
get => _saveStatsChecked;
set => this.RaiseAndSetIfChanged(ref _saveStatsChecked, value);
}
public bool ShareStatsChecked
{
get => _shareStatsChecked;
set => this.RaiseAndSetIfChanged(ref _shareStatsChecked, value);
}
public bool CommandStatsChecked
{
get => _commandStatsChecked;
set => this.RaiseAndSetIfChanged(ref _commandStatsChecked, value);
}
public bool DeviceStatsChecked
{
get => _deviceStatsChecked;
set => this.RaiseAndSetIfChanged(ref _deviceStatsChecked, value);
}
public bool FilesystemStatsChecked
{
get => _filesystemStatsChecked;
set => this.RaiseAndSetIfChanged(ref _filesystemStatsChecked, value);
}
public bool FilterStatsChecked
{
get => _filterStatsChecked;
set => this.RaiseAndSetIfChanged(ref _filterStatsChecked, value);
}
public bool MediaImageStatsChecked
{
get => _mediaImageStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaImageStatsChecked, value);
}
public bool MediaScanStatsChecked
{
get => _mediaScanStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaScanStatsChecked, value);
}
public bool PartitionStatsChecked
{
get => _partitionStatsChecked;
set => this.RaiseAndSetIfChanged(ref _partitionStatsChecked, value);
}
public bool MediaStatsChecked
{
get => _mediaStatsChecked;
set => this.RaiseAndSetIfChanged(ref _mediaStatsChecked, value);
}
public bool VerifyStatsChecked
{
get => _verifyStatsChecked;
set => this.RaiseAndSetIfChanged(ref _verifyStatsChecked, value);
}
public int TabControlSelectedIndex
{
get => _tabControlSelectedIndex;
set => this.RaiseAndSetIfChanged(ref _tabControlSelectedIndex, value);
}
void ExecuteSaveCommand()
{
Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked;
Settings.Settings.Current.ShareReports = ShareReportsChecked;
if(SaveStatsChecked)
Settings.Settings.Current.Stats = new StatsSettings
{
ShareStats = ShareStatsChecked,
CommandStats = CommandStatsChecked,
DeviceStats = DeviceStatsChecked,
FilesystemStats = FilesystemStatsChecked,
FilterStats = FilterStatsChecked,
MediaImageStats = MediaImageStatsChecked,
MediaScanStats = MediaScanStatsChecked,
PartitionStats = PartitionStatsChecked,
MediaStats = MediaStatsChecked,
VerifyStats = VerifyStatsChecked
};
else
Settings.Settings.Current.Stats = null;
Settings.Settings.Current.GdprCompliance = DicSettings.GDPR_LEVEL;
Settings.Settings.SaveSettings();
_view.Close();
}
void ExecuteCancelCommand() => _view.Close();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -33,71 +33,70 @@
using JetBrains.Annotations;
using Schemas;
namespace Aaru.Gui.ViewModels.Panels
namespace Aaru.Gui.ViewModels.Panels;
public sealed class FileSystemViewModel
{
public sealed class FileSystemViewModel
public FileSystemViewModel([NotNull] FileSystemType xmlFsType, string information)
{
public FileSystemViewModel([NotNull] FileSystemType xmlFsType, string information)
{
TypeText = $"Filesystem type: {xmlFsType.Type}";
VolumeNameText = $"Volume name: {xmlFsType.VolumeName}";
SerialNumberText = $"Serial number: {xmlFsType.VolumeSerial}";
ApplicationIdentifierText = $"Application identifier: {xmlFsType.ApplicationIdentifier}";
SystemIdentifierText = $"System identifier: {xmlFsType.SystemIdentifier}";
VolumeSetIdentifierText = $"Volume set identifier: {xmlFsType.VolumeSetIdentifier}";
DataPreparerIdentifierText = $"Data preparer identifier: {xmlFsType.DataPreparerIdentifier}";
PublisherIdentifierText = $"Publisher identifier: {xmlFsType.PublisherIdentifier}";
CreationDateText = $"Volume created on {xmlFsType.CreationDate:F}";
EffectiveDateText = $"Volume effective from {xmlFsType.EffectiveDate:F}";
ModificationDateText = $"Volume last modified on {xmlFsType.ModificationDate:F}";
ExpirationDateText = $"Volume expired on {xmlFsType.ExpirationDate:F}";
BackupDateText = $"Volume last backed up on {xmlFsType.BackupDate:F}";
TypeText = $"Filesystem type: {xmlFsType.Type}";
VolumeNameText = $"Volume name: {xmlFsType.VolumeName}";
SerialNumberText = $"Serial number: {xmlFsType.VolumeSerial}";
ApplicationIdentifierText = $"Application identifier: {xmlFsType.ApplicationIdentifier}";
SystemIdentifierText = $"System identifier: {xmlFsType.SystemIdentifier}";
VolumeSetIdentifierText = $"Volume set identifier: {xmlFsType.VolumeSetIdentifier}";
DataPreparerIdentifierText = $"Data preparer identifier: {xmlFsType.DataPreparerIdentifier}";
PublisherIdentifierText = $"Publisher identifier: {xmlFsType.PublisherIdentifier}";
CreationDateText = $"Volume created on {xmlFsType.CreationDate:F}";
EffectiveDateText = $"Volume effective from {xmlFsType.EffectiveDate:F}";
ModificationDateText = $"Volume last modified on {xmlFsType.ModificationDate:F}";
ExpirationDateText = $"Volume expired on {xmlFsType.ExpirationDate:F}";
BackupDateText = $"Volume last backed up on {xmlFsType.BackupDate:F}";
ClustersText =
$"Volume has {xmlFsType.Clusters} clusters of {xmlFsType.ClusterSize} bytes each (total of {xmlFsType.Clusters * xmlFsType.ClusterSize} bytes)";
ClustersText =
$"Volume has {xmlFsType.Clusters} clusters of {xmlFsType.ClusterSize} bytes each (total of {xmlFsType.Clusters * xmlFsType.ClusterSize} bytes)";
FreeClustersText =
$"Volume has {xmlFsType.FreeClusters} clusters free ({xmlFsType.FreeClusters / xmlFsType.Clusters:P})";
FreeClustersText =
$"Volume has {xmlFsType.FreeClusters} clusters free ({xmlFsType.FreeClusters / xmlFsType.Clusters:P})";
FilesText = $"Volume contains {xmlFsType.Files} files";
BootableChecked = xmlFsType.Bootable;
DirtyChecked = xmlFsType.Dirty;
InformationText = information;
FilesText = $"Volume contains {xmlFsType.Files} files";
BootableChecked = xmlFsType.Bootable;
DirtyChecked = xmlFsType.Dirty;
InformationText = information;
CreationDateVisible = xmlFsType.CreationDateSpecified;
EffectiveDateVisible = xmlFsType.EffectiveDateSpecified;
ModificationDateVisible = xmlFsType.ModificationDateSpecified;
ExpirationDateVisible = xmlFsType.ExpirationDateSpecified;
BackupDateVisible = xmlFsType.BackupDateSpecified;
FreeClustersVisible = xmlFsType.FreeClustersSpecified;
FilesVisible = xmlFsType.FilesSpecified;
}
public string TypeText { get; }
public string VolumeNameText { get; }
public string SerialNumberText { get; }
public string ApplicationIdentifierText { get; }
public string SystemIdentifierText { get; }
public string VolumeSetIdentifierText { get; }
public string DataPreparerIdentifierText { get; }
public string PublisherIdentifierText { get; }
public string CreationDateText { get; }
public string EffectiveDateText { get; }
public string ModificationDateText { get; }
public string ExpirationDateText { get; }
public string BackupDateText { get; }
public string ClustersText { get; }
public string FreeClustersText { get; }
public string FilesText { get; }
public bool BootableChecked { get; }
public bool DirtyChecked { get; }
public string InformationText { get; }
public bool CreationDateVisible { get; }
public bool EffectiveDateVisible { get; }
public bool ModificationDateVisible { get; }
public bool ExpirationDateVisible { get; }
public bool BackupDateVisible { get; }
public bool FreeClustersVisible { get; }
public bool FilesVisible { get; }
CreationDateVisible = xmlFsType.CreationDateSpecified;
EffectiveDateVisible = xmlFsType.EffectiveDateSpecified;
ModificationDateVisible = xmlFsType.ModificationDateSpecified;
ExpirationDateVisible = xmlFsType.ExpirationDateSpecified;
BackupDateVisible = xmlFsType.BackupDateSpecified;
FreeClustersVisible = xmlFsType.FreeClustersSpecified;
FilesVisible = xmlFsType.FilesSpecified;
}
public string TypeText { get; }
public string VolumeNameText { get; }
public string SerialNumberText { get; }
public string ApplicationIdentifierText { get; }
public string SystemIdentifierText { get; }
public string VolumeSetIdentifierText { get; }
public string DataPreparerIdentifierText { get; }
public string PublisherIdentifierText { get; }
public string CreationDateText { get; }
public string EffectiveDateText { get; }
public string ModificationDateText { get; }
public string ExpirationDateText { get; }
public string BackupDateText { get; }
public string ClustersText { get; }
public string FreeClustersText { get; }
public string FilesText { get; }
public bool BootableChecked { get; }
public bool DirtyChecked { get; }
public string InformationText { get; }
public bool CreationDateVisible { get; }
public bool EffectiveDateVisible { get; }
public bool ModificationDateVisible { get; }
public bool ExpirationDateVisible { get; }
public bool BackupDateVisible { get; }
public bool FreeClustersVisible { get; }
public bool FilesVisible { get; }
}

File diff suppressed because it is too large Load Diff

View File

@@ -48,405 +48,404 @@ using MessageBox.Avalonia.Enums;
using ReactiveUI;
using ScsiInfo = Aaru.Core.Media.Info.ScsiInfo;
namespace Aaru.Gui.ViewModels.Panels
namespace Aaru.Gui.ViewModels.Panels;
public sealed class MediaInfoViewModel : ViewModelBase
{
public sealed class MediaInfoViewModel : ViewModelBase
readonly string _devicePath;
readonly ScsiInfo _scsiInfo;
readonly Window _view;
BlurayInfo _blurayInfo;
CompactDiscInfo _compactDiscInfo;
string _densitySupport;
DvdInfo _dvdInfo;
DvdWritableInfo _dvdWritableInfo;
string _generalVisible;
Bitmap _mediaLogo;
string _mediaSerial;
string _mediaSize;
string _mediaType;
string _mediumSupport;
bool _mmcVisible;
bool _saveDensitySupportVisible;
bool _saveGetConfigurationVisible;
bool _saveMediumSupportVisible;
bool _saveReadCapacity16Visible;
bool _saveReadCapacityVisible;
bool _saveReadMediaSerialVisible;
bool _saveRecognizedFormatLayersVisible;
bool _saveWriteProtectionStatusVisible;
bool _sscVisible;
XboxInfo _xboxInfo;
public MediaInfoViewModel(ScsiInfo scsiInfo, string devicePath, Window view)
{
readonly string _devicePath;
readonly ScsiInfo _scsiInfo;
readonly Window _view;
BlurayInfo _blurayInfo;
CompactDiscInfo _compactDiscInfo;
string _densitySupport;
DvdInfo _dvdInfo;
DvdWritableInfo _dvdWritableInfo;
string _generalVisible;
Bitmap _mediaLogo;
string _mediaSerial;
string _mediaSize;
string _mediaType;
string _mediumSupport;
bool _mmcVisible;
bool _saveDensitySupportVisible;
bool _saveGetConfigurationVisible;
bool _saveMediumSupportVisible;
bool _saveReadCapacity16Visible;
bool _saveReadCapacityVisible;
bool _saveReadMediaSerialVisible;
bool _saveRecognizedFormatLayersVisible;
bool _saveWriteProtectionStatusVisible;
bool _sscVisible;
XboxInfo _xboxInfo;
_view = view;
SaveReadMediaSerialCommand = ReactiveCommand.Create(ExecuteSaveReadMediaSerialCommand);
SaveReadCapacityCommand = ReactiveCommand.Create(ExecuteSaveReadCapacityCommand);
SaveReadCapacity16Command = ReactiveCommand.Create(ExecuteSaveReadCapacity16Command);
SaveGetConfigurationCommand = ReactiveCommand.Create(ExecuteSaveGetConfigurationCommand);
SaveRecognizedFormatLayersCommand = ReactiveCommand.Create(ExecuteSaveRecognizedFormatLayersCommand);
SaveWriteProtectionStatusCommand = ReactiveCommand.Create(ExecuteSaveWriteProtectionStatusCommand);
SaveDensitySupportCommand = ReactiveCommand.Create(ExecuteSaveDensitySupportCommand);
SaveMediumSupportCommand = ReactiveCommand.Create(ExecuteSaveMediumSupportCommand);
DumpCommand = ReactiveCommand.Create(ExecuteDumpCommand);
ScanCommand = ReactiveCommand.Create(ExecuteScanCommand);
IAssetLoader assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
_devicePath = devicePath;
_scsiInfo = scsiInfo;
public MediaInfoViewModel(ScsiInfo scsiInfo, string devicePath, Window view)
var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png");
MediaLogo = assets.Exists(mediaResource) ? new Bitmap(assets.Open(mediaResource)) : null;
MediaType = scsiInfo.MediaType.ToString();
if(scsiInfo.Blocks != 0 &&
scsiInfo.BlockSize != 0)
{
_view = view;
SaveReadMediaSerialCommand = ReactiveCommand.Create(ExecuteSaveReadMediaSerialCommand);
SaveReadCapacityCommand = ReactiveCommand.Create(ExecuteSaveReadCapacityCommand);
SaveReadCapacity16Command = ReactiveCommand.Create(ExecuteSaveReadCapacity16Command);
SaveGetConfigurationCommand = ReactiveCommand.Create(ExecuteSaveGetConfigurationCommand);
SaveRecognizedFormatLayersCommand = ReactiveCommand.Create(ExecuteSaveRecognizedFormatLayersCommand);
SaveWriteProtectionStatusCommand = ReactiveCommand.Create(ExecuteSaveWriteProtectionStatusCommand);
SaveDensitySupportCommand = ReactiveCommand.Create(ExecuteSaveDensitySupportCommand);
SaveMediumSupportCommand = ReactiveCommand.Create(ExecuteSaveMediumSupportCommand);
DumpCommand = ReactiveCommand.Create(ExecuteDumpCommand);
ScanCommand = ReactiveCommand.Create(ExecuteScanCommand);
IAssetLoader assets = AvaloniaLocator.Current.GetService<IAssetLoader>();
_devicePath = devicePath;
_scsiInfo = scsiInfo;
ulong totalSize = scsiInfo.Blocks * scsiInfo.BlockSize;
var mediaResource = new Uri($"avares://Aaru.Gui/Assets/Logos/Media/{scsiInfo.MediaType}.png");
if(totalSize > 1099511627776)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)";
else if(totalSize > 1073741824)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)";
else if(totalSize > 1048576)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)";
else if(totalSize > 1024)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)";
else
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize} bytes)";
}
MediaLogo = assets.Exists(mediaResource) ? new Bitmap(assets.Open(mediaResource)) : null;
if(scsiInfo.MediaSerialNumber != null)
{
var sbSerial = new StringBuilder();
MediaType = scsiInfo.MediaType.ToString();
for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
if(scsiInfo.Blocks != 0 &&
scsiInfo.BlockSize != 0)
MediaSerial = sbSerial.ToString();
}
SaveReadMediaSerialVisible = scsiInfo.MediaSerialNumber != null;
SaveReadCapacityVisible = scsiInfo.ReadCapacity != null;
SaveReadCapacity16Visible = scsiInfo.ReadCapacity16 != null;
SaveGetConfigurationVisible = scsiInfo.MmcConfiguration != null;
SaveRecognizedFormatLayersVisible = scsiInfo.RecognizedFormatLayers != null;
SaveWriteProtectionStatusVisible = scsiInfo.WriteProtectionStatus != null;
MmcVisible = SaveGetConfigurationVisible || SaveRecognizedFormatLayersVisible ||
SaveWriteProtectionStatusVisible;
if(scsiInfo.DensitySupportHeader.HasValue)
DensitySupport = Decoders.SCSI.SSC.DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
if(scsiInfo.MediaTypeSupportHeader.HasValue)
MediumSupport = Decoders.SCSI.SSC.DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
SaveDensitySupportVisible = scsiInfo.DensitySupport != null;
SaveMediumSupportVisible = scsiInfo.MediaTypeSupport != null;
SscVisible = SaveDensitySupportVisible || SaveMediumSupportVisible;
CompactDiscInfo = new CompactDiscInfo
{
DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.DiscInformation,
scsiInfo.Session, scsiInfo.RawToc, scsiInfo.Pma,
scsiInfo.CdTextLeadIn, scsiInfo.DecodedToc,
scsiInfo.DecodedAtip, scsiInfo.DecodedSession,
scsiInfo.FullToc, scsiInfo.DecodedCdTextLeadIn,
scsiInfo.DecodedDiscInformation, scsiInfo.Mcn,
scsiInfo.Isrcs, _view)
};
DvdInfo = new DvdInfo
{
DataContext = new DvdInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi,
scsiInfo.DvdCmi, scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca,
scsiInfo.DvdAacs, scsiInfo.DecodedPfi, _view)
};
XboxInfo = new XboxInfo
{
DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,
scsiInfo.DecodedXboxSecuritySector, _view)
};
DvdWritableInfo = new DvdWritableInfo
{
DataContext = new DvdWritableInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdRamDds,
scsiInfo.DvdRamCartridgeStatus, scsiInfo.DvdRamSpareArea,
scsiInfo.LastBorderOutRmd, scsiInfo.DvdPreRecordedInfo,
scsiInfo.DvdrMediaIdentifier,
scsiInfo.DvdrPhysicalInformation,
scsiInfo.HddvdrMediumStatus, scsiInfo.HddvdrLastRmd,
scsiInfo.DvdrLayerCapacity, scsiInfo.DvdrDlMiddleZoneStart,
scsiInfo.DvdrDlJumpIntervalSize,
scsiInfo.DvdrDlManualLayerJumpStartLba,
scsiInfo.DvdrDlRemapAnchorPoint, scsiInfo.DvdPlusAdip,
scsiInfo.DvdPlusDcb, _view)
};
BlurayInfo = new BlurayInfo
{
DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea,
scsiInfo.BlurayDds, scsiInfo.BlurayCartridgeStatus,
scsiInfo.BluraySpareAreaInformation, scsiInfo.BlurayPowResources,
scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl,
scsiInfo.BlurayPac, _view)
};
}
public ReactiveCommand<Unit, Unit> SaveReadMediaSerialCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacityCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacity16Command { get; }
public ReactiveCommand<Unit, Unit> SaveGetConfigurationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveRecognizedFormatLayersCommand { get; }
public ReactiveCommand<Unit, Unit> SaveWriteProtectionStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDensitySupportCommand { get; }
public ReactiveCommand<Unit, Unit> SaveMediumSupportCommand { get; }
public ReactiveCommand<Unit, Unit> DumpCommand { get; }
public ReactiveCommand<Unit, Unit> ScanCommand { get; }
public Bitmap MediaLogo
{
get => _mediaLogo;
set => this.RaiseAndSetIfChanged(ref _mediaLogo, value);
}
public string GeneralVisible
{
get => _generalVisible;
set => this.RaiseAndSetIfChanged(ref _generalVisible, value);
}
public string MediaType
{
get => _mediaType;
set => this.RaiseAndSetIfChanged(ref _mediaType, value);
}
public string MediaSize
{
get => _mediaSize;
set => this.RaiseAndSetIfChanged(ref _mediaSize, value);
}
public string MediaSerial
{
get => _mediaSerial;
set => this.RaiseAndSetIfChanged(ref _mediaSerial, value);
}
public bool SaveReadMediaSerialVisible
{
get => _saveReadMediaSerialVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadMediaSerialVisible, value);
}
public bool SaveReadCapacityVisible
{
get => _saveReadCapacityVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacityVisible, value);
}
public bool SaveReadCapacity16Visible
{
get => _saveReadCapacity16Visible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacity16Visible, value);
}
public bool MmcVisible
{
get => _mmcVisible;
set => this.RaiseAndSetIfChanged(ref _mmcVisible, value);
}
public bool SaveGetConfigurationVisible
{
get => _saveGetConfigurationVisible;
set => this.RaiseAndSetIfChanged(ref _saveGetConfigurationVisible, value);
}
public bool SaveRecognizedFormatLayersVisible
{
get => _saveRecognizedFormatLayersVisible;
set => this.RaiseAndSetIfChanged(ref _saveRecognizedFormatLayersVisible, value);
}
public bool SaveWriteProtectionStatusVisible
{
get => _saveWriteProtectionStatusVisible;
set => this.RaiseAndSetIfChanged(ref _saveWriteProtectionStatusVisible, value);
}
public bool SscVisible
{
get => _sscVisible;
set => this.RaiseAndSetIfChanged(ref _sscVisible, value);
}
public string DensitySupport
{
get => _densitySupport;
set => this.RaiseAndSetIfChanged(ref _densitySupport, value);
}
public string MediumSupport
{
get => _mediumSupport;
set => this.RaiseAndSetIfChanged(ref _mediumSupport, value);
}
public bool SaveDensitySupportVisible
{
get => _saveDensitySupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveDensitySupportVisible, value);
}
public bool SaveMediumSupportVisible
{
get => _saveMediumSupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveMediumSupportVisible, value);
}
public CompactDiscInfo CompactDiscInfo
{
get => _compactDiscInfo;
set => this.RaiseAndSetIfChanged(ref _compactDiscInfo, value);
}
public DvdInfo DvdInfo
{
get => _dvdInfo;
set => this.RaiseAndSetIfChanged(ref _dvdInfo, value);
}
public DvdWritableInfo DvdWritableInfo
{
get => _dvdWritableInfo;
set => this.RaiseAndSetIfChanged(ref _dvdWritableInfo, value);
}
public XboxInfo XboxInfo
{
get => _xboxInfo;
set => this.RaiseAndSetIfChanged(ref _xboxInfo, value);
}
public BlurayInfo BlurayInfo
{
get => _blurayInfo;
set => this.RaiseAndSetIfChanged(ref _blurayInfo, value);
}
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
ulong totalSize = scsiInfo.Blocks * scsiInfo.BlockSize;
"*.bin"
}),
Name = "Binary"
});
if(totalSize > 1099511627776)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1099511627776d:F3} TiB)";
else if(totalSize > 1073741824)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1073741824d:F3} GiB)";
else if(totalSize > 1048576)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1048576d:F3} MiB)";
else if(totalSize > 1024)
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize / 1024d:F3} KiB)";
else
MediaSize =
$"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {totalSize} bytes)";
}
string result = await dlgSaveBinary.ShowAsync(_view);
if(scsiInfo.MediaSerialNumber != null)
{
var sbSerial = new StringBuilder();
if(result is null)
return;
for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
MediaSerial = sbSerial.ToString();
}
saveFs.Close();
}
SaveReadMediaSerialVisible = scsiInfo.MediaSerialNumber != null;
SaveReadCapacityVisible = scsiInfo.ReadCapacity != null;
SaveReadCapacity16Visible = scsiInfo.ReadCapacity16 != null;
void ExecuteSaveReadMediaSerialCommand() => SaveElement(_scsiInfo.MediaSerialNumber);
SaveGetConfigurationVisible = scsiInfo.MmcConfiguration != null;
SaveRecognizedFormatLayersVisible = scsiInfo.RecognizedFormatLayers != null;
SaveWriteProtectionStatusVisible = scsiInfo.WriteProtectionStatus != null;
void ExecuteSaveReadCapacityCommand() => SaveElement(_scsiInfo.ReadCapacity);
MmcVisible = SaveGetConfigurationVisible || SaveRecognizedFormatLayersVisible ||
SaveWriteProtectionStatusVisible;
void ExecuteSaveReadCapacity16Command() => SaveElement(_scsiInfo.ReadCapacity16);
if(scsiInfo.DensitySupportHeader.HasValue)
DensitySupport = Decoders.SCSI.SSC.DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
void ExecuteSaveGetConfigurationCommand() => SaveElement(_scsiInfo.MmcConfiguration);
if(scsiInfo.MediaTypeSupportHeader.HasValue)
MediumSupport = Decoders.SCSI.SSC.DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
void ExecuteSaveRecognizedFormatLayersCommand() => SaveElement(_scsiInfo.RecognizedFormatLayers);
SaveDensitySupportVisible = scsiInfo.DensitySupport != null;
SaveMediumSupportVisible = scsiInfo.MediaTypeSupport != null;
void ExecuteSaveWriteProtectionStatusCommand() => SaveElement(_scsiInfo.WriteProtectionStatus);
SscVisible = SaveDensitySupportVisible || SaveMediumSupportVisible;
void ExecuteSaveDensitySupportCommand() => SaveElement(_scsiInfo.DensitySupport);
CompactDiscInfo = new CompactDiscInfo
{
DataContext = new CompactDiscInfoViewModel(scsiInfo.Toc, scsiInfo.Atip, scsiInfo.DiscInformation,
scsiInfo.Session, scsiInfo.RawToc, scsiInfo.Pma,
scsiInfo.CdTextLeadIn, scsiInfo.DecodedToc,
scsiInfo.DecodedAtip, scsiInfo.DecodedSession,
scsiInfo.FullToc, scsiInfo.DecodedCdTextLeadIn,
scsiInfo.DecodedDiscInformation, scsiInfo.Mcn,
scsiInfo.Isrcs, _view)
};
void ExecuteSaveMediumSupportCommand() => SaveElement(_scsiInfo.MediaTypeSupport);
DvdInfo = new DvdInfo
{
DataContext = new DvdInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdPfi, scsiInfo.DvdDmi,
scsiInfo.DvdCmi, scsiInfo.HddvdCopyrightInformation, scsiInfo.DvdBca,
scsiInfo.DvdAacs, scsiInfo.DecodedPfi, _view)
};
async void ExecuteDumpCommand()
{
if(_scsiInfo.MediaType == CommonTypes.MediaType.GDR ||
_scsiInfo.MediaType == CommonTypes.MediaType.GDROM)
{
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "GD-ROM dump support is not yet implemented.", ButtonEnum.Ok,
Icon.Error).ShowDialog(_view);
XboxInfo = new XboxInfo
{
DataContext = new XboxInfoViewModel(scsiInfo.XgdInfo, scsiInfo.DvdDmi, scsiInfo.XboxSecuritySector,
scsiInfo.DecodedXboxSecuritySector, _view)
};
DvdWritableInfo = new DvdWritableInfo
{
DataContext = new DvdWritableInfoViewModel(scsiInfo.MediaType, scsiInfo.DvdRamDds,
scsiInfo.DvdRamCartridgeStatus, scsiInfo.DvdRamSpareArea,
scsiInfo.LastBorderOutRmd, scsiInfo.DvdPreRecordedInfo,
scsiInfo.DvdrMediaIdentifier,
scsiInfo.DvdrPhysicalInformation,
scsiInfo.HddvdrMediumStatus, scsiInfo.HddvdrLastRmd,
scsiInfo.DvdrLayerCapacity, scsiInfo.DvdrDlMiddleZoneStart,
scsiInfo.DvdrDlJumpIntervalSize,
scsiInfo.DvdrDlManualLayerJumpStartLba,
scsiInfo.DvdrDlRemapAnchorPoint, scsiInfo.DvdPlusAdip,
scsiInfo.DvdPlusDcb, _view)
};
BlurayInfo = new BlurayInfo
{
DataContext = new BlurayInfoViewModel(scsiInfo.BlurayDiscInformation, scsiInfo.BlurayBurstCuttingArea,
scsiInfo.BlurayDds, scsiInfo.BlurayCartridgeStatus,
scsiInfo.BluraySpareAreaInformation, scsiInfo.BlurayPowResources,
scsiInfo.BlurayTrackResources, scsiInfo.BlurayRawDfl,
scsiInfo.BlurayPac, _view)
};
return;
}
public ReactiveCommand<Unit, Unit> SaveReadMediaSerialCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacityCommand { get; }
public ReactiveCommand<Unit, Unit> SaveReadCapacity16Command { get; }
public ReactiveCommand<Unit, Unit> SaveGetConfigurationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveRecognizedFormatLayersCommand { get; }
public ReactiveCommand<Unit, Unit> SaveWriteProtectionStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDensitySupportCommand { get; }
public ReactiveCommand<Unit, Unit> SaveMediumSupportCommand { get; }
public ReactiveCommand<Unit, Unit> DumpCommand { get; }
public ReactiveCommand<Unit, Unit> ScanCommand { get; }
public Bitmap MediaLogo
if((_scsiInfo.MediaType == CommonTypes.MediaType.XGD || _scsiInfo.MediaType == CommonTypes.MediaType.XGD2 ||
_scsiInfo.MediaType == CommonTypes.MediaType.XGD3) &&
_scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true)
{
get => _mediaLogo;
set => this.RaiseAndSetIfChanged(ref _mediaLogo, value);
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "Dumping Xbox discs require a Kreon drive.", ButtonEnum.Ok,
Icon.Error).ShowDialog(_view);
return;
}
public string GeneralVisible
var mediaDumpWindow = new MediaDump();
mediaDumpWindow.DataContext =
new MediaDumpViewModel(_devicePath, _scsiInfo.DeviceInfo, mediaDumpWindow, _scsiInfo);
mediaDumpWindow.Show();
}
async void ExecuteScanCommand()
{
switch(_scsiInfo.MediaType)
{
get => _generalVisible;
set => this.RaiseAndSetIfChanged(ref _generalVisible, value);
}
public string MediaType
{
get => _mediaType;
set => this.RaiseAndSetIfChanged(ref _mediaType, value);
}
public string MediaSize
{
get => _mediaSize;
set => this.RaiseAndSetIfChanged(ref _mediaSize, value);
}
public string MediaSerial
{
get => _mediaSerial;
set => this.RaiseAndSetIfChanged(ref _mediaSerial, value);
}
public bool SaveReadMediaSerialVisible
{
get => _saveReadMediaSerialVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadMediaSerialVisible, value);
}
public bool SaveReadCapacityVisible
{
get => _saveReadCapacityVisible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacityVisible, value);
}
public bool SaveReadCapacity16Visible
{
get => _saveReadCapacity16Visible;
set => this.RaiseAndSetIfChanged(ref _saveReadCapacity16Visible, value);
}
public bool MmcVisible
{
get => _mmcVisible;
set => this.RaiseAndSetIfChanged(ref _mmcVisible, value);
}
public bool SaveGetConfigurationVisible
{
get => _saveGetConfigurationVisible;
set => this.RaiseAndSetIfChanged(ref _saveGetConfigurationVisible, value);
}
public bool SaveRecognizedFormatLayersVisible
{
get => _saveRecognizedFormatLayersVisible;
set => this.RaiseAndSetIfChanged(ref _saveRecognizedFormatLayersVisible, value);
}
public bool SaveWriteProtectionStatusVisible
{
get => _saveWriteProtectionStatusVisible;
set => this.RaiseAndSetIfChanged(ref _saveWriteProtectionStatusVisible, value);
}
public bool SscVisible
{
get => _sscVisible;
set => this.RaiseAndSetIfChanged(ref _sscVisible, value);
}
public string DensitySupport
{
get => _densitySupport;
set => this.RaiseAndSetIfChanged(ref _densitySupport, value);
}
public string MediumSupport
{
get => _mediumSupport;
set => this.RaiseAndSetIfChanged(ref _mediumSupport, value);
}
public bool SaveDensitySupportVisible
{
get => _saveDensitySupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveDensitySupportVisible, value);
}
public bool SaveMediumSupportVisible
{
get => _saveMediumSupportVisible;
set => this.RaiseAndSetIfChanged(ref _saveMediumSupportVisible, value);
}
public CompactDiscInfo CompactDiscInfo
{
get => _compactDiscInfo;
set => this.RaiseAndSetIfChanged(ref _compactDiscInfo, value);
}
public DvdInfo DvdInfo
{
get => _dvdInfo;
set => this.RaiseAndSetIfChanged(ref _dvdInfo, value);
}
public DvdWritableInfo DvdWritableInfo
{
get => _dvdWritableInfo;
set => this.RaiseAndSetIfChanged(ref _dvdWritableInfo, value);
}
public XboxInfo XboxInfo
{
get => _xboxInfo;
set => this.RaiseAndSetIfChanged(ref _xboxInfo, value);
}
public BlurayInfo BlurayInfo
{
get => _blurayInfo;
set => this.RaiseAndSetIfChanged(ref _blurayInfo, value);
}
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveReadMediaSerialCommand() => SaveElement(_scsiInfo.MediaSerialNumber);
void ExecuteSaveReadCapacityCommand() => SaveElement(_scsiInfo.ReadCapacity);
void ExecuteSaveReadCapacity16Command() => SaveElement(_scsiInfo.ReadCapacity16);
void ExecuteSaveGetConfigurationCommand() => SaveElement(_scsiInfo.MmcConfiguration);
void ExecuteSaveRecognizedFormatLayersCommand() => SaveElement(_scsiInfo.RecognizedFormatLayers);
void ExecuteSaveWriteProtectionStatusCommand() => SaveElement(_scsiInfo.WriteProtectionStatus);
void ExecuteSaveDensitySupportCommand() => SaveElement(_scsiInfo.DensitySupport);
void ExecuteSaveMediumSupportCommand() => SaveElement(_scsiInfo.MediaTypeSupport);
async void ExecuteDumpCommand()
{
if(_scsiInfo.MediaType == CommonTypes.MediaType.GDR ||
_scsiInfo.MediaType == CommonTypes.MediaType.GDROM)
{
// TODO: GD-ROM
case CommonTypes.MediaType.GDR:
case CommonTypes.MediaType.GDROM:
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "GD-ROM dump support is not yet implemented.", ButtonEnum.Ok,
Icon.Error).ShowDialog(_view);
GetMessageBoxStandardWindow("Error", "GD-ROM scan support is not yet implemented.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
return;
}
if((_scsiInfo.MediaType == CommonTypes.MediaType.XGD || _scsiInfo.MediaType == CommonTypes.MediaType.XGD2 ||
_scsiInfo.MediaType == CommonTypes.MediaType.XGD3) &&
_scsiInfo.DeviceInfo.ScsiInquiry?.KreonPresent != true)
{
// TODO: Xbox
case CommonTypes.MediaType.XGD:
case CommonTypes.MediaType.XGD2:
case CommonTypes.MediaType.XGD3:
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "Dumping Xbox discs require a Kreon drive.", ButtonEnum.Ok,
Icon.Error).ShowDialog(_view);
GetMessageBoxStandardWindow("Error", "Scanning Xbox discs is not yet supported.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
return;
}
var mediaDumpWindow = new MediaDump();
mediaDumpWindow.DataContext =
new MediaDumpViewModel(_devicePath, _scsiInfo.DeviceInfo, mediaDumpWindow, _scsiInfo);
mediaDumpWindow.Show();
}
async void ExecuteScanCommand()
{
switch(_scsiInfo.MediaType)
{
// TODO: GD-ROM
case CommonTypes.MediaType.GDR:
case CommonTypes.MediaType.GDROM:
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "GD-ROM scan support is not yet implemented.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
var mediaScanWindow = new MediaScan();
return;
mediaScanWindow.DataContext = new MediaScanViewModel(_devicePath, mediaScanWindow);
// TODO: Xbox
case CommonTypes.MediaType.XGD:
case CommonTypes.MediaType.XGD2:
case CommonTypes.MediaType.XGD3:
await MessageBoxManager.
GetMessageBoxStandardWindow("Error", "Scanning Xbox discs is not yet supported.",
ButtonEnum.Ok, Icon.Error).ShowDialog(_view);
return;
}
var mediaScanWindow = new MediaScan();
mediaScanWindow.DataContext = new MediaScanViewModel(_devicePath, mediaScanWindow);
mediaScanWindow.Show();
}
mediaScanWindow.Show();
}
}

View File

@@ -32,25 +32,24 @@
using Aaru.CommonTypes;
namespace Aaru.Gui.ViewModels.Panels
{
public sealed class PartitionViewModel
{
public PartitionViewModel(Partition partition)
{
NameText = $"Partition name: {partition.Name}";
TypeText = $"Partition type: {partition.Type}";
StartText = $"Partition start: sector {partition.Start}, byte {partition.Offset}";
LengthText = $"Partition length: {partition.Length} sectors, {partition.Size} bytes";
DescriptionLabelText = "Partition description:";
DescriptionText = partition.Description;
}
namespace Aaru.Gui.ViewModels.Panels;
public string NameText { get; }
public string TypeText { get; }
public string StartText { get; }
public string LengthText { get; }
public string DescriptionLabelText { get; }
public string DescriptionText { get; }
public sealed class PartitionViewModel
{
public PartitionViewModel(Partition partition)
{
NameText = $"Partition name: {partition.Name}";
TypeText = $"Partition type: {partition.Type}";
StartText = $"Partition start: sector {partition.Start}, byte {partition.Offset}";
LengthText = $"Partition length: {partition.Length} sectors, {partition.Size} bytes";
DescriptionLabelText = "Partition description:";
DescriptionText = partition.Description;
}
public string NameText { get; }
public string TypeText { get; }
public string StartText { get; }
public string LengthText { get; }
public string DescriptionLabelText { get; }
public string DescriptionText { get; }
}

View File

@@ -49,221 +49,204 @@ using MessageBox.Avalonia.Enums;
using ReactiveUI;
using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes;
namespace Aaru.Gui.ViewModels.Panels
namespace Aaru.Gui.ViewModels.Panels;
public sealed class SubdirectoryViewModel
{
public sealed class SubdirectoryViewModel
readonly SubdirectoryModel _model;
readonly Window _view;
public SubdirectoryViewModel([NotNull] SubdirectoryModel model, Window view)
{
readonly SubdirectoryModel _model;
readonly Window _view;
Entries = new ObservableCollection<FileModel>();
SelectedEntries = new List<FileModel>();
ExtractFilesCommand = ReactiveCommand.Create(ExecuteExtractFilesCommand);
_model = model;
_view = view;
public SubdirectoryViewModel([NotNull] SubdirectoryModel model, Window view)
ErrorNumber errno = model.Plugin.ReadDir(model.Path, out List<string> dirents);
if(errno != ErrorNumber.NoError)
{
Entries = new ObservableCollection<FileModel>();
SelectedEntries = new List<FileModel>();
ExtractFilesCommand = ReactiveCommand.Create(ExecuteExtractFilesCommand);
_model = model;
_view = view;
MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} trying to read \"{model.Path}\" of chosen filesystem",
ButtonEnum.Ok, Icon.Error).ShowDialog(view);
ErrorNumber errno = model.Plugin.ReadDir(model.Path, out List<string> dirents);
return;
}
foreach(string dirent in dirents)
{
errno = model.Plugin.Stat(model.Path + "/" + dirent, out FileEntryInfo stat);
if(errno != ErrorNumber.NoError)
{
MessageBoxManager.
GetMessageBoxStandardWindow("Error",
$"Error {errno} trying to read \"{model.Path}\" of chosen filesystem",
ButtonEnum.Ok, Icon.Error).ShowDialog(view);
AaruConsole.
ErrorWriteLine($"Error {errno} trying to get information about filesystem entry named {dirent}");
return;
continue;
}
foreach(string dirent in dirents)
if(stat.Attributes.HasFlag(FileAttributes.Directory) &&
!model.Listed)
{
errno = model.Plugin.Stat(model.Path + "/" + dirent, out FileEntryInfo stat);
if(errno != ErrorNumber.NoError)
model.Subdirectories.Add(new SubdirectoryModel
{
AaruConsole.
ErrorWriteLine($"Error {errno} trying to get information about filesystem entry named {dirent}");
continue;
}
if(stat.Attributes.HasFlag(FileAttributes.Directory) &&
!model.Listed)
{
model.Subdirectories.Add(new SubdirectoryModel
{
Name = dirent,
Path = model.Path + "/" + dirent,
Plugin = model.Plugin
});
continue;
}
Entries.Add(new FileModel
{
Name = dirent,
Stat = stat
Name = dirent,
Path = model.Path + "/" + dirent,
Plugin = model.Plugin
});
continue;
}
Entries.Add(new FileModel
{
Name = dirent,
Stat = stat
});
}
}
public ObservableCollection<FileModel> Entries { get; }
public List<FileModel> SelectedEntries { get; }
public ReactiveCommand<Unit, Unit> ExtractFilesCommand { get; }
public ObservableCollection<FileModel> Entries { get; }
public List<FileModel> SelectedEntries { get; }
public ReactiveCommand<Unit, Unit> ExtractFilesCommand { get; }
async void ExecuteExtractFilesCommand()
async void ExecuteExtractFilesCommand()
{
if(SelectedEntries.Count == 0)
return;
ButtonResult mboxResult;
var saveFilesFolderDialog = new OpenFolderDialog
{
if(SelectedEntries.Count == 0)
return;
Title = "Choose destination folder..."
};
ButtonResult mboxResult;
string result = await saveFilesFolderDialog.ShowAsync(_view);
var saveFilesFolderDialog = new OpenFolderDialog
{
Title = "Choose destination folder..."
};
if(result is null)
return;
string result = await saveFilesFolderDialog.ShowAsync(_view);
Statistics.AddCommand("extract-files");
if(result is null)
return;
string folder = saveFilesFolderDialog.Directory;
Statistics.AddCommand("extract-files");
foreach(FileModel file in SelectedEntries)
{
string filename = file.Name;
string folder = saveFilesFolderDialog.Directory;
if(DetectOS.IsWindows)
if(filename.Contains('<') ||
filename.Contains('>') ||
filename.Contains(':') ||
filename.Contains('\\') ||
filename.Contains('/') ||
filename.Contains('|') ||
filename.Contains('?') ||
filename.Contains('*') ||
filename.Any(c => c < 32) ||
filename.ToUpperInvariant() == "CON" ||
filename.ToUpperInvariant() == "PRN" ||
filename.ToUpperInvariant() == "AUX" ||
filename.ToUpperInvariant() == "COM1" ||
filename.ToUpperInvariant() == "COM2" ||
filename.ToUpperInvariant() == "COM3" ||
filename.ToUpperInvariant() == "COM4" ||
filename.ToUpperInvariant() == "COM5" ||
filename.ToUpperInvariant() == "COM6" ||
filename.ToUpperInvariant() == "COM7" ||
filename.ToUpperInvariant() == "COM8" ||
filename.ToUpperInvariant() == "COM9" ||
filename.ToUpperInvariant() == "LPT1" ||
filename.ToUpperInvariant() == "LPT2" ||
filename.ToUpperInvariant() == "LPT3" ||
filename.ToUpperInvariant() == "LPT4" ||
filename.ToUpperInvariant() == "LPT5" ||
filename.ToUpperInvariant() == "LPT6" ||
filename.ToUpperInvariant() == "LPT7" ||
filename.ToUpperInvariant() == "LPT8" ||
filename.ToUpperInvariant() == "LPT9" ||
filename.Last() == '.' ||
filename.Last() == ' ')
{
char[] chars;
foreach(FileModel file in SelectedEntries)
{
string filename = file.Name;
if(filename.Last() == '.' ||
filename.Last() == ' ')
chars = new char[filename.Length - 1];
else
chars = new char[filename.Length];
if(DetectOS.IsWindows)
if(filename.Contains('<') ||
filename.Contains('>') ||
filename.Contains(':') ||
filename.Contains('\\') ||
filename.Contains('/') ||
filename.Contains('|') ||
filename.Contains('?') ||
filename.Contains('*') ||
filename.Any(c => c < 32) ||
filename.ToUpperInvariant() == "CON" ||
filename.ToUpperInvariant() == "PRN" ||
filename.ToUpperInvariant() == "AUX" ||
filename.ToUpperInvariant() == "COM1" ||
filename.ToUpperInvariant() == "COM2" ||
filename.ToUpperInvariant() == "COM3" ||
filename.ToUpperInvariant() == "COM4" ||
filename.ToUpperInvariant() == "COM5" ||
filename.ToUpperInvariant() == "COM6" ||
filename.ToUpperInvariant() == "COM7" ||
filename.ToUpperInvariant() == "COM8" ||
filename.ToUpperInvariant() == "COM9" ||
filename.ToUpperInvariant() == "LPT1" ||
filename.ToUpperInvariant() == "LPT2" ||
filename.ToUpperInvariant() == "LPT3" ||
filename.ToUpperInvariant() == "LPT4" ||
filename.ToUpperInvariant() == "LPT5" ||
filename.ToUpperInvariant() == "LPT6" ||
filename.ToUpperInvariant() == "LPT7" ||
filename.ToUpperInvariant() == "LPT8" ||
filename.ToUpperInvariant() == "LPT9" ||
filename.Last() == '.' ||
filename.Last() == ' ')
{
char[] chars;
if(filename.Last() == '.' ||
filename.Last() == ' ')
chars = new char[filename.Length - 1];
else
chars = new char[filename.Length];
for(int ci = 0; ci < chars.Length; ci++)
switch(filename[ci])
{
case '<':
case '>':
case ':':
case '\\':
case '/':
case '|':
case '?':
case '*':
case '\u0000':
case '\u0001':
case '\u0002':
case '\u0003':
case '\u0004':
case '\u0005':
case '\u0006':
case '\u0007':
case '\u0008':
case '\u0009':
case '\u000A':
case '\u000B':
case '\u000C':
case '\u000D':
case '\u000E':
case '\u000F':
case '\u0010':
case '\u0011':
case '\u0012':
case '\u0013':
case '\u0014':
case '\u0015':
case '\u0016':
case '\u0017':
case '\u0018':
case '\u0019':
case '\u001A':
case '\u001B':
case '\u001C':
case '\u001D':
case '\u001E':
case '\u001F':
chars[ci] = '_';
break;
default:
chars[ci] = filename[ci];
break;
}
if(filename.StartsWith("CON", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("PRN", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("AUX", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("COM", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("LPT", StringComparison.InvariantCultureIgnoreCase))
for(int ci = 0; ci < chars.Length; ci++)
switch(filename[ci])
{
chars[0] = '_';
chars[1] = '_';
chars[2] = '_';
case '<':
case '>':
case ':':
case '\\':
case '/':
case '|':
case '?':
case '*':
case '\u0000':
case '\u0001':
case '\u0002':
case '\u0003':
case '\u0004':
case '\u0005':
case '\u0006':
case '\u0007':
case '\u0008':
case '\u0009':
case '\u000A':
case '\u000B':
case '\u000C':
case '\u000D':
case '\u000E':
case '\u000F':
case '\u0010':
case '\u0011':
case '\u0012':
case '\u0013':
case '\u0014':
case '\u0015':
case '\u0016':
case '\u0017':
case '\u0018':
case '\u0019':
case '\u001A':
case '\u001B':
case '\u001C':
case '\u001D':
case '\u001E':
case '\u001F':
chars[ci] = '_';
break;
default:
chars[ci] = filename[ci];
break;
}
string corrected = new(chars);
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Unsupported filename",
$"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?",
ButtonEnum.YesNoCancel, Icon.Warning).ShowDialog(_view);
if(mboxResult == ButtonResult.Cancel)
return;
if(mboxResult == ButtonResult.No)
continue;
filename = corrected;
if(filename.StartsWith("CON", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("PRN", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("AUX", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("COM", StringComparison.InvariantCultureIgnoreCase) ||
filename.StartsWith("LPT", StringComparison.InvariantCultureIgnoreCase))
{
chars[0] = '_';
chars[1] = '_';
chars[2] = '_';
}
string outputPath = Path.Combine(folder, filename);
string corrected = new(chars);
if(File.Exists(outputPath))
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Existing file",
$"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?",
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Unsupported filename",
$"The file name {filename} is not supported on this platform.\nDo you want to rename it to {corrected}?",
ButtonEnum.YesNoCancel, Icon.Warning).ShowDialog(_view);
if(mboxResult == ButtonResult.Cancel)
@@ -272,87 +255,103 @@ namespace Aaru.Gui.ViewModels.Panels
if(mboxResult == ButtonResult.No)
continue;
try
{
File.Delete(outputPath);
}
catch(IOException)
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot delete",
"Could not delete existing file.\nDo you want to continue?",
ButtonEnum.YesNo, Icon.Error).ShowDialog(_view);
if(mboxResult == ButtonResult.No)
return;
}
filename = corrected;
}
string outputPath = Path.Combine(folder, filename);
if(File.Exists(outputPath))
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Existing file",
$"A file named {filename} already exists on the destination folder.\nDo you want to overwrite it?",
ButtonEnum.YesNoCancel, Icon.Warning).ShowDialog(_view);
if(mboxResult == ButtonResult.Cancel)
return;
if(mboxResult == ButtonResult.No)
continue;
try
{
byte[] outBuf = Array.Empty<byte>();
ErrorNumber error =
_model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf);
if(error != ErrorNumber.NoError)
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Error reading file",
$"Error {error} reading file.\nDo you want to continue?",
ButtonEnum.YesNo, Icon.Error).ShowDialog(_view);
if(mboxResult == ButtonResult.No)
return;
continue;
}
var fs = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
fs.Write(outBuf, 0, outBuf.Length);
fs.Close();
var fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
if(file.Stat.CreationTimeUtc.HasValue)
fi.CreationTimeUtc = file.Stat.CreationTimeUtc.Value;
}
catch
{
// ignored
}
try
{
if(file.Stat.LastWriteTimeUtc.HasValue)
fi.LastWriteTimeUtc = file.Stat.LastWriteTimeUtc.Value;
}
catch
{
// ignored
}
try
{
if(file.Stat.AccessTimeUtc.HasValue)
fi.LastAccessTimeUtc = file.Stat.AccessTimeUtc.Value;
}
catch
{
// ignored
}
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
File.Delete(outputPath);
}
catch(IOException)
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot create file",
"Could not create destination file.\nDo you want to continue?",
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot delete",
"Could not delete existing file.\nDo you want to continue?",
ButtonEnum.YesNo, Icon.Error).ShowDialog(_view);
if(mboxResult == ButtonResult.No)
return;
}
}
try
{
byte[] outBuf = Array.Empty<byte>();
ErrorNumber error =
_model.Plugin.Read(_model.Path + "/" + file.Name, 0, file.Stat.Length, ref outBuf);
if(error != ErrorNumber.NoError)
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Error reading file",
$"Error {error} reading file.\nDo you want to continue?",
ButtonEnum.YesNo, Icon.Error).ShowDialog(_view);
if(mboxResult == ButtonResult.No)
return;
continue;
}
var fs = new FileStream(outputPath, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None);
fs.Write(outBuf, 0, outBuf.Length);
fs.Close();
var fi = new FileInfo(outputPath);
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
try
{
if(file.Stat.CreationTimeUtc.HasValue)
fi.CreationTimeUtc = file.Stat.CreationTimeUtc.Value;
}
catch
{
// ignored
}
try
{
if(file.Stat.LastWriteTimeUtc.HasValue)
fi.LastWriteTimeUtc = file.Stat.LastWriteTimeUtc.Value;
}
catch
{
// ignored
}
try
{
if(file.Stat.AccessTimeUtc.HasValue)
fi.LastAccessTimeUtc = file.Stat.AccessTimeUtc.Value;
}
catch
{
// ignored
}
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
}
catch(IOException)
{
mboxResult = await MessageBoxManager.GetMessageBoxStandardWindow("Cannot create file",
"Could not create destination file.\nDo you want to continue?",
ButtonEnum.YesNo, Icon.Error).ShowDialog(_view);
if(mboxResult == ButtonResult.No)
return;
}
}
}
}

View File

@@ -38,143 +38,142 @@ using Avalonia.Controls;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class AtaInfoViewModel : ViewModelBase
{
public sealed class AtaInfoViewModel : ViewModelBase
readonly byte[] _ata;
readonly byte[] _atapi;
readonly Window _view;
public AtaInfoViewModel([CanBeNull] byte[] ataIdentify, byte[] atapiIdentify,
AtaErrorRegistersChs? ataMcptError, Window view)
{
readonly byte[] _ata;
readonly byte[] _atapi;
readonly Window _view;
SaveAtaBinaryCommand = ReactiveCommand.Create(ExecuteSaveAtaBinaryCommand);
SaveAtaTextCommand = ReactiveCommand.Create(ExecuteSaveAtaTextCommand);
public AtaInfoViewModel([CanBeNull] byte[] ataIdentify, byte[] atapiIdentify,
AtaErrorRegistersChs? ataMcptError, Window view)
_ata = ataIdentify;
_atapi = atapiIdentify;
_view = view;
if(ataIdentify == null &&
atapiIdentify == null)
return;
if(ataIdentify != null)
{
SaveAtaBinaryCommand = ReactiveCommand.Create(ExecuteSaveAtaBinaryCommand);
SaveAtaTextCommand = ReactiveCommand.Create(ExecuteSaveAtaTextCommand);
AtaMcptVisible = true;
AtaMcptChecked = ataMcptError.HasValue;
AtaOrAtapiText = "ATA IDENTIFY DEVICE";
_ata = ataIdentify;
_atapi = atapiIdentify;
_view = view;
if(ataIdentify == null &&
atapiIdentify == null)
return;
if(ataIdentify != null)
if(ataMcptError.HasValue)
{
AtaMcptVisible = true;
AtaMcptChecked = ataMcptError.HasValue;
AtaOrAtapiText = "ATA IDENTIFY DEVICE";
if(ataMcptError.HasValue)
switch(ataMcptError.Value.DeviceHead & 0x7)
{
switch(ataMcptError.Value.DeviceHead & 0x7)
{
case 0:
AtaMcptText = "Device reports incorrect media card type";
case 0:
AtaMcptText = "Device reports incorrect media card type";
break;
case 1:
AtaMcptText = "Device contains a Secure Digital card";
break;
case 1:
AtaMcptText = "Device contains a Secure Digital card";
break;
case 2:
AtaMcptText = "Device contains a MultiMediaCard ";
break;
case 2:
AtaMcptText = "Device contains a MultiMediaCard ";
break;
case 3:
AtaMcptText = "Device contains a Secure Digital I/O card";
break;
case 3:
AtaMcptText = "Device contains a Secure Digital I/O card";
break;
case 4:
AtaMcptText = "Device contains a Smart Media card";
break;
case 4:
AtaMcptText = "Device contains a Smart Media card";
break;
default:
AtaMcptText =
$"Device contains unknown media card type {ataMcptError.Value.DeviceHead & 0x07}";
break;
default:
AtaMcptText =
$"Device contains unknown media card type {ataMcptError.Value.DeviceHead & 0x07}";
break;
}
AtaMcptWriteProtectionChecked = (ataMcptError.Value.DeviceHead & 0x08) == 0x08;
ushort specificData = (ushort)((ataMcptError.Value.CylinderHigh * 0x100) +
ataMcptError.Value.CylinderLow);
AtaMcptSpecificDataText = $"Card specific data: 0x{specificData:X4}";
break;
}
AtaIdentifyText = Identify.Prettify(_ata);
}
else
{
AtaOrAtapiText = "ATA PACKET IDENTIFY DEVICE";
AtaIdentifyText = Identify.Prettify(_atapi);
AtaMcptWriteProtectionChecked = (ataMcptError.Value.DeviceHead & 0x08) == 0x08;
ushort specificData = (ushort)((ataMcptError.Value.CylinderHigh * 0x100) +
ataMcptError.Value.CylinderLow);
AtaMcptSpecificDataText = $"Card specific data: 0x{specificData:X4}";
}
AtaIdentifyText = Identify.Prettify(_ata);
}
public string AtaIdentifyText { get; }
public string AtaMcptText { get; }
public string AtaMcptSpecificDataText { get; }
public bool AtaMcptChecked { get; }
public bool AtaMcptWriteProtectionChecked { get; }
public bool AtaMcptVisible { get; }
public ReactiveCommand<Unit, Unit> SaveAtaBinaryCommand { get; }
public ReactiveCommand<Unit, Unit> SaveAtaTextCommand { get; }
public string AtaOrAtapiText { get; }
async void ExecuteSaveAtaBinaryCommand()
else
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
if(_ata != null)
saveFs.Write(_ata, 0, _ata.Length);
else if(_atapi != null)
saveFs.Write(_atapi, 0, _atapi.Length);
saveFs.Close();
}
async void ExecuteSaveAtaTextCommand()
{
var dlgSaveText = new SaveFileDialog();
dlgSaveText.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.txt"
}),
Name = "Text"
});
string result = await dlgSaveText.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
var saveSw = new StreamWriter(saveFs);
saveSw.Write(AtaIdentifyText);
saveFs.Close();
AtaOrAtapiText = "ATA PACKET IDENTIFY DEVICE";
AtaIdentifyText = Identify.Prettify(_atapi);
}
}
public string AtaIdentifyText { get; }
public string AtaMcptText { get; }
public string AtaMcptSpecificDataText { get; }
public bool AtaMcptChecked { get; }
public bool AtaMcptWriteProtectionChecked { get; }
public bool AtaMcptVisible { get; }
public ReactiveCommand<Unit, Unit> SaveAtaBinaryCommand { get; }
public ReactiveCommand<Unit, Unit> SaveAtaTextCommand { get; }
public string AtaOrAtapiText { get; }
async void ExecuteSaveAtaBinaryCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
if(_ata != null)
saveFs.Write(_ata, 0, _ata.Length);
else if(_atapi != null)
saveFs.Write(_atapi, 0, _atapi.Length);
saveFs.Close();
}
async void ExecuteSaveAtaTextCommand()
{
var dlgSaveText = new SaveFileDialog();
dlgSaveText.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.txt"
}),
Name = "Text"
});
string result = await dlgSaveText.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
var saveSw = new StreamWriter(saveFs);
saveSw.Write(AtaIdentifyText);
saveFs.Close();
}
}

View File

@@ -39,162 +39,161 @@ using Avalonia.Controls;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class BlurayInfoViewModel
{
public sealed class BlurayInfoViewModel
readonly byte[] _burstCuttingArea;
readonly byte[] _cartridgeStatus;
readonly byte[] _dds;
readonly byte[] _discInformation;
readonly byte[] _pac;
readonly byte[] _powResources;
readonly byte[] _rawDfl;
readonly byte[] _spareAreaInformation;
readonly byte[] _trackResources;
readonly Window _view;
public BlurayInfoViewModel([CanBeNull] byte[] blurayDiscInformation, [CanBeNull] byte[] blurayBurstCuttingArea,
[CanBeNull] byte[] blurayDds, [CanBeNull] byte[] blurayCartridgeStatus,
[CanBeNull] byte[] bluraySpareAreaInformation, [CanBeNull] byte[] blurayPowResources,
[CanBeNull] byte[] blurayTrackResources, [CanBeNull] byte[] blurayRawDfl,
[CanBeNull] byte[] blurayPac, Window view)
{
readonly byte[] _burstCuttingArea;
readonly byte[] _cartridgeStatus;
readonly byte[] _dds;
readonly byte[] _discInformation;
readonly byte[] _pac;
readonly byte[] _powResources;
readonly byte[] _rawDfl;
readonly byte[] _spareAreaInformation;
readonly byte[] _trackResources;
readonly Window _view;
_view = view;
_discInformation = blurayDiscInformation;
_burstCuttingArea = blurayBurstCuttingArea;
_dds = blurayDds;
_cartridgeStatus = blurayCartridgeStatus;
_spareAreaInformation = bluraySpareAreaInformation;
_powResources = blurayPowResources;
_trackResources = blurayTrackResources;
_rawDfl = blurayRawDfl;
_pac = blurayPac;
SaveBlurayDiscInformationCommand = ReactiveCommand.Create(ExecuteSaveBlurayDiscInformationCommand);
SaveBlurayBurstCuttingAreaCommand = ReactiveCommand.Create(ExecuteSaveBlurayBurstCuttingAreaCommand);
SaveBlurayDdsCommand = ReactiveCommand.Create(ExecuteSaveBlurayDdsCommand);
SaveBlurayCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveBlurayCartridgeStatusCommand);
public BlurayInfoViewModel([CanBeNull] byte[] blurayDiscInformation, [CanBeNull] byte[] blurayBurstCuttingArea,
[CanBeNull] byte[] blurayDds, [CanBeNull] byte[] blurayCartridgeStatus,
[CanBeNull] byte[] bluraySpareAreaInformation, [CanBeNull] byte[] blurayPowResources,
[CanBeNull] byte[] blurayTrackResources, [CanBeNull] byte[] blurayRawDfl,
[CanBeNull] byte[] blurayPac, Window view)
SaveBluraySpareAreaInformationCommand =
ReactiveCommand.Create(ExecuteSaveBluraySpareAreaInformationCommand);
SaveBlurayPowResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayPowResourcesCommand);
SaveBlurayTrackResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayTrackResourcesCommand);
SaveBlurayRawDflCommand = ReactiveCommand.Create(ExecuteSaveBlurayRawDflCommand);
SaveBlurayPacCommand = ReactiveCommand.Create(ExecuteSaveBlurayPacCommand);
if(blurayDiscInformation != null)
{
_view = view;
_discInformation = blurayDiscInformation;
_burstCuttingArea = blurayBurstCuttingArea;
_dds = blurayDds;
_cartridgeStatus = blurayCartridgeStatus;
_spareAreaInformation = bluraySpareAreaInformation;
_powResources = blurayPowResources;
_trackResources = blurayTrackResources;
_rawDfl = blurayRawDfl;
_pac = blurayPac;
SaveBlurayDiscInformationCommand = ReactiveCommand.Create(ExecuteSaveBlurayDiscInformationCommand);
SaveBlurayBurstCuttingAreaCommand = ReactiveCommand.Create(ExecuteSaveBlurayBurstCuttingAreaCommand);
SaveBlurayDdsCommand = ReactiveCommand.Create(ExecuteSaveBlurayDdsCommand);
SaveBlurayCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveBlurayCartridgeStatusCommand);
SaveBluraySpareAreaInformationCommand =
ReactiveCommand.Create(ExecuteSaveBluraySpareAreaInformationCommand);
SaveBlurayPowResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayPowResourcesCommand);
SaveBlurayTrackResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayTrackResourcesCommand);
SaveBlurayRawDflCommand = ReactiveCommand.Create(ExecuteSaveBlurayRawDflCommand);
SaveBlurayPacCommand = ReactiveCommand.Create(ExecuteSaveBlurayPacCommand);
if(blurayDiscInformation != null)
{
SaveBlurayDiscInformationVisible = true;
BlurayDiscInformationText = DI.Prettify(blurayDiscInformation);
}
if(blurayBurstCuttingArea != null)
{
SaveBlurayBurstCuttingAreaVisible = true;
BlurayBurstCuttingAreaText = BCA.Prettify(blurayBurstCuttingArea);
}
if(blurayDds != null)
{
SaveBlurayDdsVisible = true;
BlurayDdsText = DDS.Prettify(blurayDds);
}
if(blurayCartridgeStatus != null)
{
SaveBlurayCartridgeStatusVisible = true;
BlurayCartridgeStatusText = Cartridge.Prettify(blurayCartridgeStatus);
}
if(bluraySpareAreaInformation != null)
{
SaveBluraySpareAreaInformationVisible = true;
BluraySpareAreaInformationText = Spare.Prettify(bluraySpareAreaInformation);
}
if(blurayPowResources != null)
{
SaveBlurayPowResourcesVisible = true;
BlurayPowResourcesText = DiscInformation.Prettify(blurayPowResources);
}
if(blurayTrackResources != null)
{
SaveBlurayTrackResourcesVisible = true;
BlurayTrackResourcesText = DiscInformation.Prettify(blurayTrackResources);
}
SaveBlurayRawDflVisible = blurayRawDfl != null;
SaveBlurayPacVisible = blurayPac != null;
SaveBlurayDiscInformationVisible = true;
BlurayDiscInformationText = DI.Prettify(blurayDiscInformation);
}
public string BlurayDiscInformationText { get; }
public string BlurayBurstCuttingAreaText { get; }
public string BlurayDdsText { get; }
public string BlurayCartridgeStatusText { get; }
public string BluraySpareAreaInformationText { get; }
public string BlurayPowResourcesText { get; }
public string BlurayTrackResourcesText { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayDiscInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayBurstCuttingAreaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayDdsCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayCartridgeStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBluraySpareAreaInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayPowResourcesCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayTrackResourcesCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayRawDflCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayPacCommand { get; }
public bool SaveBlurayDiscInformationVisible { get; }
public bool SaveBlurayBurstCuttingAreaVisible { get; }
public bool SaveBlurayDdsVisible { get; }
public bool SaveBlurayCartridgeStatusVisible { get; }
public bool SaveBluraySpareAreaInformationVisible { get; }
public bool SaveBlurayPowResourcesVisible { get; }
public bool SaveBlurayTrackResourcesVisible { get; }
public bool SaveBlurayRawDflVisible { get; }
public bool SaveBlurayPacVisible { get; }
async void SaveElement(byte[] data)
if(blurayBurstCuttingArea != null)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
SaveBlurayBurstCuttingAreaVisible = true;
BlurayBurstCuttingAreaText = BCA.Prettify(blurayBurstCuttingArea);
}
void ExecuteSaveBlurayDiscInformationCommand() => SaveElement(_discInformation);
if(blurayDds != null)
{
SaveBlurayDdsVisible = true;
BlurayDdsText = DDS.Prettify(blurayDds);
}
void ExecuteSaveBlurayBurstCuttingAreaCommand() => SaveElement(_burstCuttingArea);
if(blurayCartridgeStatus != null)
{
SaveBlurayCartridgeStatusVisible = true;
BlurayCartridgeStatusText = Cartridge.Prettify(blurayCartridgeStatus);
}
void ExecuteSaveBlurayDdsCommand() => SaveElement(_dds);
if(bluraySpareAreaInformation != null)
{
SaveBluraySpareAreaInformationVisible = true;
BluraySpareAreaInformationText = Spare.Prettify(bluraySpareAreaInformation);
}
void ExecuteSaveBlurayCartridgeStatusCommand() => SaveElement(_cartridgeStatus);
if(blurayPowResources != null)
{
SaveBlurayPowResourcesVisible = true;
BlurayPowResourcesText = DiscInformation.Prettify(blurayPowResources);
}
void ExecuteSaveBluraySpareAreaInformationCommand() => SaveElement(_spareAreaInformation);
if(blurayTrackResources != null)
{
SaveBlurayTrackResourcesVisible = true;
BlurayTrackResourcesText = DiscInformation.Prettify(blurayTrackResources);
}
void ExecuteSaveBlurayPowResourcesCommand() => SaveElement(_powResources);
void ExecuteSaveBlurayTrackResourcesCommand() => SaveElement(_trackResources);
void ExecuteSaveBlurayRawDflCommand() => SaveElement(_rawDfl);
void ExecuteSaveBlurayPacCommand() => SaveElement(_pac);
SaveBlurayRawDflVisible = blurayRawDfl != null;
SaveBlurayPacVisible = blurayPac != null;
}
public string BlurayDiscInformationText { get; }
public string BlurayBurstCuttingAreaText { get; }
public string BlurayDdsText { get; }
public string BlurayCartridgeStatusText { get; }
public string BluraySpareAreaInformationText { get; }
public string BlurayPowResourcesText { get; }
public string BlurayTrackResourcesText { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayDiscInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayBurstCuttingAreaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayDdsCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayCartridgeStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBluraySpareAreaInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayPowResourcesCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayTrackResourcesCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayRawDflCommand { get; }
public ReactiveCommand<Unit, Unit> SaveBlurayPacCommand { get; }
public bool SaveBlurayDiscInformationVisible { get; }
public bool SaveBlurayBurstCuttingAreaVisible { get; }
public bool SaveBlurayDdsVisible { get; }
public bool SaveBlurayCartridgeStatusVisible { get; }
public bool SaveBluraySpareAreaInformationVisible { get; }
public bool SaveBlurayPowResourcesVisible { get; }
public bool SaveBlurayTrackResourcesVisible { get; }
public bool SaveBlurayRawDflVisible { get; }
public bool SaveBlurayPacVisible { get; }
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveBlurayDiscInformationCommand() => SaveElement(_discInformation);
void ExecuteSaveBlurayBurstCuttingAreaCommand() => SaveElement(_burstCuttingArea);
void ExecuteSaveBlurayDdsCommand() => SaveElement(_dds);
void ExecuteSaveBlurayCartridgeStatusCommand() => SaveElement(_cartridgeStatus);
void ExecuteSaveBluraySpareAreaInformationCommand() => SaveElement(_spareAreaInformation);
void ExecuteSaveBlurayPowResourcesCommand() => SaveElement(_powResources);
void ExecuteSaveBlurayTrackResourcesCommand() => SaveElement(_trackResources);
void ExecuteSaveBlurayRawDflCommand() => SaveElement(_rawDfl);
void ExecuteSaveBlurayPacCommand() => SaveElement(_pac);
}

View File

@@ -40,263 +40,262 @@ using Aaru.Gui.Models;
using Avalonia.Controls;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class CompactDiscInfoViewModel : ViewModelBase
{
public sealed class CompactDiscInfoViewModel : ViewModelBase
readonly byte[] _atipData;
readonly byte[] _cdTextLeadInData;
readonly byte[] _compactDiscInformationData;
readonly byte[] _pmaData;
readonly byte[] _rawTocData;
readonly byte[] _sessionData;
readonly byte[] _tocData;
readonly Window _view;
public CompactDiscInfoViewModel(byte[] toc, byte[] atip, byte[] compactDiscInformation, byte[] session,
byte[] rawToc, byte[] pma, byte[] cdTextLeadIn, TOC.CDTOC? decodedToc,
ATIP.CDATIP decodedAtip, Session.CDSessionInfo? decodedSession,
FullTOC.CDFullTOC? fullToc, CDTextOnLeadIn.CDText? decodedCdTextLeadIn,
DiscInformation.StandardDiscInformation? decodedCompactDiscInformation,
string mcn, Dictionary<byte, string> isrcs, Window view)
{
readonly byte[] _atipData;
readonly byte[] _cdTextLeadInData;
readonly byte[] _compactDiscInformationData;
readonly byte[] _pmaData;
readonly byte[] _rawTocData;
readonly byte[] _sessionData;
readonly byte[] _tocData;
readonly Window _view;
_tocData = toc;
_atipData = atip;
_compactDiscInformationData = compactDiscInformation;
_sessionData = session;
_rawTocData = rawToc;
_pmaData = pma;
_cdTextLeadInData = cdTextLeadIn;
_view = view;
IsrcList = new ObservableCollection<IsrcModel>();
SaveCdInformationCommand = ReactiveCommand.Create(ExecuteSaveCdInformationCommand);
SaveCdTocCommand = ReactiveCommand.Create(ExecuteSaveCdTocCommand);
SaveCdFullTocCommand = ReactiveCommand.Create(ExecuteSaveCdFullTocCommand);
SaveCdSessionCommand = ReactiveCommand.Create(ExecuteSaveCdSessionCommand);
SaveCdTextCommand = ReactiveCommand.Create(ExecuteSaveCdTextCommand);
SaveCdAtipCommand = ReactiveCommand.Create(ExecuteSaveCdAtipCommand);
SaveCdPmaCommand = ReactiveCommand.Create(ExecuteSaveCdPmaCommand);
public CompactDiscInfoViewModel(byte[] toc, byte[] atip, byte[] compactDiscInformation, byte[] session,
byte[] rawToc, byte[] pma, byte[] cdTextLeadIn, TOC.CDTOC? decodedToc,
ATIP.CDATIP decodedAtip, Session.CDSessionInfo? decodedSession,
FullTOC.CDFullTOC? fullToc, CDTextOnLeadIn.CDText? decodedCdTextLeadIn,
DiscInformation.StandardDiscInformation? decodedCompactDiscInformation,
string mcn, Dictionary<byte, string> isrcs, Window view)
if(decodedCompactDiscInformation.HasValue)
CdInformationText = DiscInformation.Prettify000b(decodedCompactDiscInformation);
if(decodedToc.HasValue)
CdTocText = TOC.Prettify(decodedToc);
if(fullToc.HasValue)
CdFullTocText = FullTOC.Prettify(fullToc);
if(decodedSession.HasValue)
CdSessionText = Session.Prettify(decodedSession);
if(decodedCdTextLeadIn.HasValue)
CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn);
if(decodedAtip != null)
CdAtipText = ATIP.Prettify(atip);
if(!string.IsNullOrEmpty(mcn))
McnText = mcn;
if(isrcs != null &&
isrcs.Count > 0)
{
_tocData = toc;
_atipData = atip;
_compactDiscInformationData = compactDiscInformation;
_sessionData = session;
_rawTocData = rawToc;
_pmaData = pma;
_cdTextLeadInData = cdTextLeadIn;
_view = view;
IsrcList = new ObservableCollection<IsrcModel>();
SaveCdInformationCommand = ReactiveCommand.Create(ExecuteSaveCdInformationCommand);
SaveCdTocCommand = ReactiveCommand.Create(ExecuteSaveCdTocCommand);
SaveCdFullTocCommand = ReactiveCommand.Create(ExecuteSaveCdFullTocCommand);
SaveCdSessionCommand = ReactiveCommand.Create(ExecuteSaveCdSessionCommand);
SaveCdTextCommand = ReactiveCommand.Create(ExecuteSaveCdTextCommand);
SaveCdAtipCommand = ReactiveCommand.Create(ExecuteSaveCdAtipCommand);
SaveCdPmaCommand = ReactiveCommand.Create(ExecuteSaveCdPmaCommand);
if(decodedCompactDiscInformation.HasValue)
CdInformationText = DiscInformation.Prettify000b(decodedCompactDiscInformation);
if(decodedToc.HasValue)
CdTocText = TOC.Prettify(decodedToc);
if(fullToc.HasValue)
CdFullTocText = FullTOC.Prettify(fullToc);
if(decodedSession.HasValue)
CdSessionText = Session.Prettify(decodedSession);
if(decodedCdTextLeadIn.HasValue)
CdTextText = CDTextOnLeadIn.Prettify(decodedCdTextLeadIn);
if(decodedAtip != null)
CdAtipText = ATIP.Prettify(atip);
if(!string.IsNullOrEmpty(mcn))
McnText = mcn;
if(isrcs != null &&
isrcs.Count > 0)
{
foreach(KeyValuePair<byte, string> isrc in isrcs)
IsrcList.Add(new IsrcModel
{
Track = isrc.Key.ToString(),
Isrc = isrc.Value
});
}
MiscellaneousVisible = McnText != null || isrcs?.Count > 0 || pma != null;
CdPmaVisible = pma != null;
}
public string CdInformationText { get; }
public string CdTocText { get; }
public string CdFullTocText { get; }
public string CdSessionText { get; }
public string CdTextText { get; }
public string CdAtipText { get; }
public bool MiscellaneousVisible { get; }
public string McnText { get; }
public bool CdPmaVisible { get; }
public ReactiveCommand<Unit, Unit> SaveCdInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdTocCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdFullTocCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdSessionCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdTextCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdAtipCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdPmaCommand { get; }
public ObservableCollection<IsrcModel> IsrcList { get; }
async void ExecuteSaveCdInformationCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
foreach(KeyValuePair<byte, string> isrc in isrcs)
IsrcList.Add(new IsrcModel
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_compactDiscInformationData, 0, _compactDiscInformationData.Length);
saveFs.Close();
Track = isrc.Key.ToString(),
Isrc = isrc.Value
});
}
async void ExecuteSaveCdTocCommand()
MiscellaneousVisible = McnText != null || isrcs?.Count > 0 || pma != null;
CdPmaVisible = pma != null;
}
public string CdInformationText { get; }
public string CdTocText { get; }
public string CdFullTocText { get; }
public string CdSessionText { get; }
public string CdTextText { get; }
public string CdAtipText { get; }
public bool MiscellaneousVisible { get; }
public string McnText { get; }
public bool CdPmaVisible { get; }
public ReactiveCommand<Unit, Unit> SaveCdInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdTocCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdFullTocCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdSessionCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdTextCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdAtipCommand { get; }
public ReactiveCommand<Unit, Unit> SaveCdPmaCommand { get; }
public ObservableCollection<IsrcModel> IsrcList { get; }
async void ExecuteSaveCdInformationCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_tocData, 0, _tocData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_compactDiscInformationData, 0, _compactDiscInformationData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdFullTocCommand()
async void ExecuteSaveCdTocCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_rawTocData, 0, _rawTocData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_tocData, 0, _tocData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdSessionCommand()
async void ExecuteSaveCdFullTocCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_sessionData, 0, _sessionData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_rawTocData, 0, _rawTocData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdTextCommand()
async void ExecuteSaveCdSessionCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_cdTextLeadInData, 0, _cdTextLeadInData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_sessionData, 0, _sessionData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdAtipCommand()
async void ExecuteSaveCdTextCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_atipData, 0, _atipData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_cdTextLeadInData, 0, _cdTextLeadInData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdPmaCommand()
async void ExecuteSaveCdAtipCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
Extensions = new List<string>(new[]
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_pmaData, 0, _pmaData.Length);
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_atipData, 0, _atipData.Length);
saveFs.Close();
}
saveFs.Close();
}
async void ExecuteSaveCdPmaCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_pmaData, 0, _pmaData.Length);
saveFs.Close();
}
}

View File

@@ -39,119 +39,118 @@ using Avalonia.Controls;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class DvdInfoViewModel
{
public sealed class DvdInfoViewModel
readonly byte[] _dvdAacs;
readonly byte[] _dvdBca;
readonly byte[] _dvdCmi;
readonly byte[] _dvdDmi;
readonly byte[] _dvdPfi;
readonly byte[] _hddvdCopyrightInformation;
readonly Window _view;
public DvdInfoViewModel(MediaType mediaType, [CanBeNull] byte[] pfi, [CanBeNull] byte[] dmi,
[CanBeNull] byte[] cmi, [CanBeNull] byte[] hdCopyrightInformation,
[CanBeNull] byte[] bca, [CanBeNull] byte[] aacs,
PFI.PhysicalFormatInformation? decodedPfi, Window view)
{
readonly byte[] _dvdAacs;
readonly byte[] _dvdBca;
readonly byte[] _dvdCmi;
readonly byte[] _dvdDmi;
readonly byte[] _dvdPfi;
readonly byte[] _hddvdCopyrightInformation;
readonly Window _view;
_dvdPfi = pfi;
_dvdDmi = dmi;
_dvdCmi = cmi;
_hddvdCopyrightInformation = hdCopyrightInformation;
_dvdBca = bca;
_dvdAacs = aacs;
_view = view;
SaveDvdPfiCommand = ReactiveCommand.Create(ExecuteSaveDvdPfiCommand);
SaveDvdDmiCommand = ReactiveCommand.Create(ExecuteSaveDvdDmiCommand);
SaveDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveDvdCmiCommand);
SaveHdDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveHdDvdCmiCommand);
SaveDvdBcaCommand = ReactiveCommand.Create(ExecuteSaveDvdBcaCommand);
SaveDvdAacsCommand = ReactiveCommand.Create(ExecuteSaveDvdAacsCommand);
public DvdInfoViewModel(MediaType mediaType, [CanBeNull] byte[] pfi, [CanBeNull] byte[] dmi,
[CanBeNull] byte[] cmi, [CanBeNull] byte[] hdCopyrightInformation,
[CanBeNull] byte[] bca, [CanBeNull] byte[] aacs,
PFI.PhysicalFormatInformation? decodedPfi, Window view)
/* TODO: Pass back
switch(mediaType)
{
_dvdPfi = pfi;
_dvdDmi = dmi;
_dvdCmi = cmi;
_hddvdCopyrightInformation = hdCopyrightInformation;
_dvdBca = bca;
_dvdAacs = aacs;
_view = view;
SaveDvdPfiCommand = ReactiveCommand.Create(ExecuteSaveDvdPfiCommand);
SaveDvdDmiCommand = ReactiveCommand.Create(ExecuteSaveDvdDmiCommand);
SaveDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveDvdCmiCommand);
SaveHdDvdCmiCommand = ReactiveCommand.Create(ExecuteSaveHdDvdCmiCommand);
SaveDvdBcaCommand = ReactiveCommand.Create(ExecuteSaveDvdBcaCommand);
SaveDvdAacsCommand = ReactiveCommand.Create(ExecuteSaveDvdAacsCommand);
case MediaType.HDDVDROM:
case MediaType.HDDVDRAM:
case MediaType.HDDVDR:
case MediaType.HDDVDRW:
case MediaType.HDDVDRDL:
case MediaType.HDDVDRWDL:
Text = "HD DVD";
/* TODO: Pass back
switch(mediaType)
{
case MediaType.HDDVDROM:
case MediaType.HDDVDRAM:
case MediaType.HDDVDR:
case MediaType.HDDVDRW:
case MediaType.HDDVDRDL:
case MediaType.HDDVDRWDL:
Text = "HD DVD";
break;
default:
Text = "DVD";
break;
default:
Text = "DVD";
break;
}
*/
if(decodedPfi.HasValue)
DvdPfiText = PFI.Prettify(decodedPfi);
if(cmi != null)
DvdCmiText = CSS_CPRM.PrettifyLeadInCopyright(cmi);
SaveDvdPfiVisible = pfi != null;
SaveDvdDmiVisible = dmi != null;
SaveDvdCmiVisible = cmi != null;
SaveHdDvdCmiVisible = hdCopyrightInformation != null;
SaveDvdBcaVisible = bca != null;
SaveDvdAacsVisible = aacs != null;
break;
}
*/
public ReactiveCommand<Unit, Unit> SaveDvdPfiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdDmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHdDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdBcaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdAacsCommand { get; }
public string DvdPfiText { get; }
public string DvdCmiText { get; }
public bool SaveDvdPfiVisible { get; }
public bool SaveDvdDmiVisible { get; }
public bool SaveDvdCmiVisible { get; }
public bool SaveHdDvdCmiVisible { get; }
public bool SaveDvdBcaVisible { get; }
public bool SaveDvdAacsVisible { get; }
if(decodedPfi.HasValue)
DvdPfiText = PFI.Prettify(decodedPfi);
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
if(cmi != null)
DvdCmiText = CSS_CPRM.PrettifyLeadInCopyright(cmi);
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveDvdPfiCommand() => SaveElement(_dvdPfi);
void ExecuteSaveDvdDmiCommand() => SaveElement(_dvdDmi);
void ExecuteSaveDvdCmiCommand() => SaveElement(_dvdCmi);
void ExecuteSaveHdDvdCmiCommand() => SaveElement(_hddvdCopyrightInformation);
void ExecuteSaveDvdBcaCommand() => SaveElement(_dvdBca);
void ExecuteSaveDvdAacsCommand() => SaveElement(_dvdAacs);
SaveDvdPfiVisible = pfi != null;
SaveDvdDmiVisible = dmi != null;
SaveDvdCmiVisible = cmi != null;
SaveHdDvdCmiVisible = hdCopyrightInformation != null;
SaveDvdBcaVisible = bca != null;
SaveDvdAacsVisible = aacs != null;
}
public ReactiveCommand<Unit, Unit> SaveDvdPfiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdDmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHdDvdCmiCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdBcaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdAacsCommand { get; }
public string DvdPfiText { get; }
public string DvdCmiText { get; }
public bool SaveDvdPfiVisible { get; }
public bool SaveDvdDmiVisible { get; }
public bool SaveDvdCmiVisible { get; }
public bool SaveHdDvdCmiVisible { get; }
public bool SaveDvdBcaVisible { get; }
public bool SaveDvdAacsVisible { get; }
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveDvdPfiCommand() => SaveElement(_dvdPfi);
void ExecuteSaveDvdDmiCommand() => SaveElement(_dvdDmi);
void ExecuteSaveDvdCmiCommand() => SaveElement(_dvdCmi);
void ExecuteSaveHdDvdCmiCommand() => SaveElement(_hddvdCopyrightInformation);
void ExecuteSaveDvdBcaCommand() => SaveElement(_dvdBca);
void ExecuteSaveDvdAacsCommand() => SaveElement(_dvdAacs);
}

View File

@@ -38,255 +38,254 @@ using Aaru.Decoders.DVD;
using Avalonia.Controls;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class DvdWritableInfoViewModel
{
public sealed class DvdWritableInfoViewModel
readonly byte[] _dvdLastBorderOutRmd;
readonly byte[] _dvdPlusAdip;
readonly byte[] _dvdPlusDcb;
readonly byte[] _dvdPreRecordedInfo;
readonly byte[] _dvdRamCartridgeStatus;
readonly byte[] _dvdRamDds;
readonly byte[] _dvdRamSpareArea;
readonly byte[] _dvdrDlJumpIntervalSize;
readonly byte[] _dvdrDlManualLayerJumpStartLba;
readonly byte[] _dvdrDlMiddleZoneStart;
readonly byte[] _dvdrDlRemapAnchorPoint;
readonly byte[] _dvdrLayerCapacity;
readonly byte[] _dvdrMediaIdentifier;
readonly byte[] _dvdrPhysicalInformation;
readonly byte[] _hddvdrLastRmd;
readonly byte[] _hddvdrMediumStatus;
readonly Window _view;
public DvdWritableInfoViewModel(MediaType mediaType, byte[] dds, byte[] cartridgeStatus, byte[] spareArea,
byte[] lastBorderOutRmd, byte[] preRecordedInfo, byte[] mediaIdentifier,
byte[] physicalInformation, byte[] mediumStatus, byte[] hdLastRmd,
byte[] layerCapacity, byte[] middleZoneStart, byte[] jumpIntervalSize,
byte[] manualLayerJumpStartLba, byte[] remapAnchorPoint, byte[] adip,
byte[] dcb, Window view)
{
readonly byte[] _dvdLastBorderOutRmd;
readonly byte[] _dvdPlusAdip;
readonly byte[] _dvdPlusDcb;
readonly byte[] _dvdPreRecordedInfo;
readonly byte[] _dvdRamCartridgeStatus;
readonly byte[] _dvdRamDds;
readonly byte[] _dvdRamSpareArea;
readonly byte[] _dvdrDlJumpIntervalSize;
readonly byte[] _dvdrDlManualLayerJumpStartLba;
readonly byte[] _dvdrDlMiddleZoneStart;
readonly byte[] _dvdrDlRemapAnchorPoint;
readonly byte[] _dvdrLayerCapacity;
readonly byte[] _dvdrMediaIdentifier;
readonly byte[] _dvdrPhysicalInformation;
readonly byte[] _hddvdrLastRmd;
readonly byte[] _hddvdrMediumStatus;
readonly Window _view;
_view = view;
SaveDvdRamDdsCommand = ReactiveCommand.Create(ExecuteSaveDvdRamDdsCommand);
SaveDvdRamCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveDvdRamCartridgeStatusCommand);
public DvdWritableInfoViewModel(MediaType mediaType, byte[] dds, byte[] cartridgeStatus, byte[] spareArea,
byte[] lastBorderOutRmd, byte[] preRecordedInfo, byte[] mediaIdentifier,
byte[] physicalInformation, byte[] mediumStatus, byte[] hdLastRmd,
byte[] layerCapacity, byte[] middleZoneStart, byte[] jumpIntervalSize,
byte[] manualLayerJumpStartLba, byte[] remapAnchorPoint, byte[] adip,
byte[] dcb, Window view)
SaveDvdRamSpareAreaInformationCommand =
ReactiveCommand.Create(ExecuteSaveDvdRamSpareAreaInformationCommand);
SaveLastBorderOutRmdCommand = ReactiveCommand.Create(ExecuteSaveLastBorderOutRmdCommand);
SaveDvdPreRecordedInfoCommand = ReactiveCommand.Create(ExecuteSaveDvdPreRecordedInfoCommand);
SaveDvdrMediaIdentifierCommand = ReactiveCommand.Create(ExecuteSaveDvdrMediaIdentifierCommand);
SaveDvdrPhysicalInformationCommand = ReactiveCommand.Create(ExecuteSaveDvdrPhysicalInformationCommand);
SaveHddvdrMediumStatusCommand = ReactiveCommand.Create(ExecuteSaveHddvdrMediumStatusCommand);
SaveHddvdrLastRmdCommand = ReactiveCommand.Create(ExecuteSaveHddvdrLastRmdCommand);
SaveDvdrLayerCapacityCommand = ReactiveCommand.Create(ExecuteSaveDvdrLayerCapacityCommand);
SaveDvdrDlMiddleZoneStartCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlMiddleZoneStartCommand);
SaveDvdrDlJumpIntervalSizeCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlJumpIntervalSizeCommand);
SaveDvdrDlManualLayerJumpStartLbaCommand =
ReactiveCommand.Create(ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand);
SaveDvdrDlRemapAnchorPointCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlRemapAnchorPointCommand);
SaveDvdPlusAdipCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusAdipCommand);
SaveDvdPlusDcbCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusDcbCommand);
_dvdRamDds = dds;
_dvdRamCartridgeStatus = cartridgeStatus;
_dvdRamSpareArea = spareArea;
_dvdLastBorderOutRmd = lastBorderOutRmd;
_dvdPreRecordedInfo = preRecordedInfo;
_dvdrMediaIdentifier = mediaIdentifier;
_dvdrPhysicalInformation = physicalInformation;
_hddvdrMediumStatus = mediumStatus;
_hddvdrLastRmd = hdLastRmd;
_dvdrLayerCapacity = layerCapacity;
_dvdrDlMiddleZoneStart = middleZoneStart;
_dvdrDlJumpIntervalSize = jumpIntervalSize;
_dvdrDlManualLayerJumpStartLba = manualLayerJumpStartLba;
_dvdrDlRemapAnchorPoint = remapAnchorPoint;
_dvdPlusAdip = adip;
_dvdPlusDcb = dcb;
/* TODO: Pass back
switch(mediaType)
{
_view = view;
SaveDvdRamDdsCommand = ReactiveCommand.Create(ExecuteSaveDvdRamDdsCommand);
SaveDvdRamCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveDvdRamCartridgeStatusCommand);
case MediaType.DVDR:
Text = "DVD-R";
SaveDvdRamSpareAreaInformationCommand =
ReactiveCommand.Create(ExecuteSaveDvdRamSpareAreaInformationCommand);
break;
case MediaType.DVDRW:
Text = "DVD-RW";
SaveLastBorderOutRmdCommand = ReactiveCommand.Create(ExecuteSaveLastBorderOutRmdCommand);
SaveDvdPreRecordedInfoCommand = ReactiveCommand.Create(ExecuteSaveDvdPreRecordedInfoCommand);
SaveDvdrMediaIdentifierCommand = ReactiveCommand.Create(ExecuteSaveDvdrMediaIdentifierCommand);
SaveDvdrPhysicalInformationCommand = ReactiveCommand.Create(ExecuteSaveDvdrPhysicalInformationCommand);
SaveHddvdrMediumStatusCommand = ReactiveCommand.Create(ExecuteSaveHddvdrMediumStatusCommand);
SaveHddvdrLastRmdCommand = ReactiveCommand.Create(ExecuteSaveHddvdrLastRmdCommand);
SaveDvdrLayerCapacityCommand = ReactiveCommand.Create(ExecuteSaveDvdrLayerCapacityCommand);
SaveDvdrDlMiddleZoneStartCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlMiddleZoneStartCommand);
SaveDvdrDlJumpIntervalSizeCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlJumpIntervalSizeCommand);
break;
case MediaType.DVDPR:
Text = "DVD+R";
SaveDvdrDlManualLayerJumpStartLbaCommand =
ReactiveCommand.Create(ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand);
break;
case MediaType.DVDPRW:
Text = "DVD+RW";
SaveDvdrDlRemapAnchorPointCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlRemapAnchorPointCommand);
SaveDvdPlusAdipCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusAdipCommand);
SaveDvdPlusDcbCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusDcbCommand);
break;
case MediaType.DVDPRWDL:
Text = "DVD+RW DL";
_dvdRamDds = dds;
_dvdRamCartridgeStatus = cartridgeStatus;
_dvdRamSpareArea = spareArea;
_dvdLastBorderOutRmd = lastBorderOutRmd;
_dvdPreRecordedInfo = preRecordedInfo;
_dvdrMediaIdentifier = mediaIdentifier;
_dvdrPhysicalInformation = physicalInformation;
_hddvdrMediumStatus = mediumStatus;
_hddvdrLastRmd = hdLastRmd;
_dvdrLayerCapacity = layerCapacity;
_dvdrDlMiddleZoneStart = middleZoneStart;
_dvdrDlJumpIntervalSize = jumpIntervalSize;
_dvdrDlManualLayerJumpStartLba = manualLayerJumpStartLba;
_dvdrDlRemapAnchorPoint = remapAnchorPoint;
_dvdPlusAdip = adip;
_dvdPlusDcb = dcb;
break;
case MediaType.DVDRDL:
Text = "DVD-R DL";
/* TODO: Pass back
switch(mediaType)
{
case MediaType.DVDR:
Text = "DVD-R";
break;
case MediaType.DVDPRDL:
Text = "DVD+R DL";
break;
case MediaType.DVDRW:
Text = "DVD-RW";
break;
case MediaType.DVDRAM:
Text = "DVD-RAM";
break;
case MediaType.DVDPR:
Text = "DVD+R";
break;
case MediaType.DVDRWDL:
Text = "DVD-RW DL";
break;
case MediaType.DVDPRW:
Text = "DVD+RW";
break;
case MediaType.HDDVDRAM:
Text = "HD DVD-RAM";
break;
case MediaType.DVDPRWDL:
Text = "DVD+RW DL";
break;
case MediaType.HDDVDR:
Text = "HD DVD-R";
break;
case MediaType.DVDRDL:
Text = "DVD-R DL";
break;
case MediaType.HDDVDRW:
Text = "HD DVD-RW";
break;
case MediaType.DVDPRDL:
Text = "DVD+R DL";
break;
case MediaType.HDDVDRDL:
Text = "HD DVD-R DL";
break;
case MediaType.DVDRAM:
Text = "DVD-RAM";
break;
case MediaType.HDDVDRWDL:
Text = "HD DVD-RW DL";
break;
case MediaType.DVDRWDL:
Text = "DVD-RW DL";
break;
case MediaType.HDDVDRAM:
Text = "HD DVD-RAM";
break;
case MediaType.HDDVDR:
Text = "HD DVD-R";
break;
case MediaType.HDDVDRW:
Text = "HD DVD-RW";
break;
case MediaType.HDDVDRDL:
Text = "HD DVD-R DL";
break;
case MediaType.HDDVDRWDL:
Text = "HD DVD-RW DL";
break;
}
*/
if(dds != null)
DvdRamDdsText = DDS.Prettify(dds);
if(cartridgeStatus != null)
DvdRamCartridgeStatusText = Cartridge.Prettify(cartridgeStatus);
if(spareArea != null)
DvdRamSpareAreaInformationText = Spare.Prettify(spareArea);
SaveDvdRamDdsVisible = dds != null;
SaveDvdRamCartridgeStatusVisible = cartridgeStatus != null;
SaveDvdRamSpareAreaInformationVisible = spareArea != null;
SaveLastBorderOutRmdVisible = lastBorderOutRmd != null;
SaveDvdPreRecordedInfoVisible = preRecordedInfo != null;
SaveDvdrMediaIdentifierVisible = mediaIdentifier != null;
SaveDvdrPhysicalInformationVisible = physicalInformation != null;
SaveHddvdrMediumStatusVisible = mediumStatus != null;
SaveHddvdrLastRmdVisible = hdLastRmd != null;
SaveDvdrLayerCapacityVisible = layerCapacity != null;
SaveDvdrDlMiddleZoneStartVisible = middleZoneStart != null;
SaveDvdrDlJumpIntervalSizeVisible = jumpIntervalSize != null;
SaveDvdrDlManualLayerJumpStartLbaVisible = manualLayerJumpStartLba != null;
SaveDvdrDlRemapAnchorPointVisible = remapAnchorPoint != null;
SaveDvdPlusAdipVisible = adip != null;
SaveDvdPlusDcbVisible = dcb != null;
break;
}
*/
public string DvdRamDdsText { get; }
public string DvdRamCartridgeStatusText { get; }
public string DvdRamSpareAreaInformationText { get; }
public bool SaveDvdRamDdsVisible { get; }
public bool SaveDvdRamCartridgeStatusVisible { get; }
public bool SaveDvdRamSpareAreaInformationVisible { get; }
public bool SaveLastBorderOutRmdVisible { get; }
public bool SaveDvdPreRecordedInfoVisible { get; }
public bool SaveDvdrMediaIdentifierVisible { get; }
public bool SaveDvdrPhysicalInformationVisible { get; }
public bool SaveHddvdrMediumStatusVisible { get; }
public bool SaveHddvdrLastRmdVisible { get; }
public bool SaveDvdrLayerCapacityVisible { get; }
public bool SaveDvdrDlMiddleZoneStartVisible { get; }
public bool SaveDvdrDlJumpIntervalSizeVisible { get; }
public bool SaveDvdrDlManualLayerJumpStartLbaVisible { get; }
public bool SaveDvdrDlRemapAnchorPointVisible { get; }
public bool SaveDvdPlusAdipVisible { get; }
public bool SaveDvdPlusDcbVisible { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamDdsCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamCartridgeStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamSpareAreaInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveLastBorderOutRmdCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPreRecordedInfoCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrMediaIdentifierCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrPhysicalInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHddvdrMediumStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHddvdrLastRmdCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrLayerCapacityCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlMiddleZoneStartCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlJumpIntervalSizeCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlManualLayerJumpStartLbaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlRemapAnchorPointCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPlusAdipCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPlusDcbCommand { get; }
if(dds != null)
DvdRamDdsText = DDS.Prettify(dds);
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
if(cartridgeStatus != null)
DvdRamCartridgeStatusText = Cartridge.Prettify(cartridgeStatus);
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
if(spareArea != null)
DvdRamSpareAreaInformationText = Spare.Prettify(spareArea);
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveDvdRamDdsCommand() => SaveElement(_dvdRamDds);
void ExecuteSaveDvdRamCartridgeStatusCommand() => SaveElement(_dvdRamCartridgeStatus);
void ExecuteSaveDvdRamSpareAreaInformationCommand() => SaveElement(_dvdRamSpareArea);
void ExecuteSaveLastBorderOutRmdCommand() => SaveElement(_dvdLastBorderOutRmd);
void ExecuteSaveDvdPreRecordedInfoCommand() => SaveElement(_dvdPreRecordedInfo);
void ExecuteSaveDvdrMediaIdentifierCommand() => SaveElement(_dvdrMediaIdentifier);
void ExecuteSaveDvdrPhysicalInformationCommand() => SaveElement(_dvdrPhysicalInformation);
void ExecuteSaveHddvdrMediumStatusCommand() => SaveElement(_hddvdrMediumStatus);
void ExecuteSaveHddvdrLastRmdCommand() => SaveElement(_hddvdrLastRmd);
void ExecuteSaveDvdrLayerCapacityCommand() => SaveElement(_dvdrLayerCapacity);
void ExecuteSaveDvdrDlMiddleZoneStartCommand() => SaveElement(_dvdrDlMiddleZoneStart);
void ExecuteSaveDvdrDlJumpIntervalSizeCommand() => SaveElement(_dvdrDlJumpIntervalSize);
void ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand() => SaveElement(_dvdrDlManualLayerJumpStartLba);
void ExecuteSaveDvdrDlRemapAnchorPointCommand() => SaveElement(_dvdrDlRemapAnchorPoint);
void ExecuteSaveDvdPlusAdipCommand() => SaveElement(_dvdPlusAdip);
void ExecuteSaveDvdPlusDcbCommand() => SaveElement(_dvdPlusDcb);
SaveDvdRamDdsVisible = dds != null;
SaveDvdRamCartridgeStatusVisible = cartridgeStatus != null;
SaveDvdRamSpareAreaInformationVisible = spareArea != null;
SaveLastBorderOutRmdVisible = lastBorderOutRmd != null;
SaveDvdPreRecordedInfoVisible = preRecordedInfo != null;
SaveDvdrMediaIdentifierVisible = mediaIdentifier != null;
SaveDvdrPhysicalInformationVisible = physicalInformation != null;
SaveHddvdrMediumStatusVisible = mediumStatus != null;
SaveHddvdrLastRmdVisible = hdLastRmd != null;
SaveDvdrLayerCapacityVisible = layerCapacity != null;
SaveDvdrDlMiddleZoneStartVisible = middleZoneStart != null;
SaveDvdrDlJumpIntervalSizeVisible = jumpIntervalSize != null;
SaveDvdrDlManualLayerJumpStartLbaVisible = manualLayerJumpStartLba != null;
SaveDvdrDlRemapAnchorPointVisible = remapAnchorPoint != null;
SaveDvdPlusAdipVisible = adip != null;
SaveDvdPlusDcbVisible = dcb != null;
}
public string DvdRamDdsText { get; }
public string DvdRamCartridgeStatusText { get; }
public string DvdRamSpareAreaInformationText { get; }
public bool SaveDvdRamDdsVisible { get; }
public bool SaveDvdRamCartridgeStatusVisible { get; }
public bool SaveDvdRamSpareAreaInformationVisible { get; }
public bool SaveLastBorderOutRmdVisible { get; }
public bool SaveDvdPreRecordedInfoVisible { get; }
public bool SaveDvdrMediaIdentifierVisible { get; }
public bool SaveDvdrPhysicalInformationVisible { get; }
public bool SaveHddvdrMediumStatusVisible { get; }
public bool SaveHddvdrLastRmdVisible { get; }
public bool SaveDvdrLayerCapacityVisible { get; }
public bool SaveDvdrDlMiddleZoneStartVisible { get; }
public bool SaveDvdrDlJumpIntervalSizeVisible { get; }
public bool SaveDvdrDlManualLayerJumpStartLbaVisible { get; }
public bool SaveDvdrDlRemapAnchorPointVisible { get; }
public bool SaveDvdPlusAdipVisible { get; }
public bool SaveDvdPlusDcbVisible { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamDdsCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamCartridgeStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdRamSpareAreaInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveLastBorderOutRmdCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPreRecordedInfoCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrMediaIdentifierCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrPhysicalInformationCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHddvdrMediumStatusCommand { get; }
public ReactiveCommand<Unit, Unit> SaveHddvdrLastRmdCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrLayerCapacityCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlMiddleZoneStartCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlJumpIntervalSizeCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlManualLayerJumpStartLbaCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdrDlRemapAnchorPointCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPlusAdipCommand { get; }
public ReactiveCommand<Unit, Unit> SaveDvdPlusDcbCommand { get; }
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
void ExecuteSaveDvdRamDdsCommand() => SaveElement(_dvdRamDds);
void ExecuteSaveDvdRamCartridgeStatusCommand() => SaveElement(_dvdRamCartridgeStatus);
void ExecuteSaveDvdRamSpareAreaInformationCommand() => SaveElement(_dvdRamSpareArea);
void ExecuteSaveLastBorderOutRmdCommand() => SaveElement(_dvdLastBorderOutRmd);
void ExecuteSaveDvdPreRecordedInfoCommand() => SaveElement(_dvdPreRecordedInfo);
void ExecuteSaveDvdrMediaIdentifierCommand() => SaveElement(_dvdrMediaIdentifier);
void ExecuteSaveDvdrPhysicalInformationCommand() => SaveElement(_dvdrPhysicalInformation);
void ExecuteSaveHddvdrMediumStatusCommand() => SaveElement(_hddvdrMediumStatus);
void ExecuteSaveHddvdrLastRmdCommand() => SaveElement(_hddvdrLastRmd);
void ExecuteSaveDvdrLayerCapacityCommand() => SaveElement(_dvdrLayerCapacity);
void ExecuteSaveDvdrDlMiddleZoneStartCommand() => SaveElement(_dvdrDlMiddleZoneStart);
void ExecuteSaveDvdrDlJumpIntervalSizeCommand() => SaveElement(_dvdrDlJumpIntervalSize);
void ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand() => SaveElement(_dvdrDlManualLayerJumpStartLba);
void ExecuteSaveDvdrDlRemapAnchorPointCommand() => SaveElement(_dvdrDlRemapAnchorPoint);
void ExecuteSaveDvdPlusAdipCommand() => SaveElement(_dvdPlusAdip);
void ExecuteSaveDvdPlusDcbCommand() => SaveElement(_dvdPlusDcb);
}

View File

@@ -41,154 +41,153 @@ using Avalonia.Controls;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public class PcmciaInfoViewModel : ViewModelBase
{
public class PcmciaInfoViewModel : ViewModelBase
readonly byte[] _cis;
readonly Window _view;
string _pcmciaCisText;
PcmciaCisModel _selectedCis;
internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view)
{
readonly byte[] _cis;
readonly Window _view;
string _pcmciaCisText;
PcmciaCisModel _selectedCis;
if(pcmciaCis == null)
return;
internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view)
{
if(pcmciaCis == null)
return;
_cis = pcmciaCis;
CisList = new ObservableCollection<PcmciaCisModel>();
SavePcmciaCisCommand = ReactiveCommand.Create(ExecuteSavePcmciaCisCommand);
_cis = pcmciaCis;
CisList = new ObservableCollection<PcmciaCisModel>();
SavePcmciaCisCommand = ReactiveCommand.Create(ExecuteSavePcmciaCisCommand);
_view = view;
_view = view;
Tuple[] tuples = CIS.GetTuples(_cis);
Tuple[] tuples = CIS.GetTuples(_cis);
if(tuples != null)
foreach(Tuple tuple in tuples)
{
string tupleCode;
string tupleDescription;
if(tuples != null)
foreach(Tuple tuple in tuples)
switch(tuple.Code)
{
string tupleCode;
string tupleDescription;
case TupleCodes.CISTPL_NULL:
case TupleCodes.CISTPL_END: continue;
case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A:
tupleCode = "Device Geometry Tuples";
tupleDescription = CIS.PrettifyDeviceGeometryTuple(tuple);
switch(tuple.Code)
{
case TupleCodes.CISTPL_NULL:
case TupleCodes.CISTPL_END: continue;
case TupleCodes.CISTPL_DEVICEGEO:
case TupleCodes.CISTPL_DEVICEGEO_A:
tupleCode = "Device Geometry Tuples";
tupleDescription = CIS.PrettifyDeviceGeometryTuple(tuple);
break;
case TupleCodes.CISTPL_MANFID:
tupleCode = "Manufacturer Identification Tuple";
tupleDescription = CIS.PrettifyManufacturerIdentificationTuple(tuple);
break;
case TupleCodes.CISTPL_MANFID:
tupleCode = "Manufacturer Identification Tuple";
tupleDescription = CIS.PrettifyManufacturerIdentificationTuple(tuple);
break;
case TupleCodes.CISTPL_VERS_1:
tupleCode = "Level 1 Version / Product Information Tuple";
tupleDescription = CIS.PrettifyLevel1VersionTuple(tuple);
break;
case TupleCodes.CISTPL_VERS_1:
tupleCode = "Level 1 Version / Product Information Tuple";
tupleDescription = CIS.PrettifyLevel1VersionTuple(tuple);
break;
case TupleCodes.CISTPL_ALTSTR:
case TupleCodes.CISTPL_BAR:
case TupleCodes.CISTPL_BATTERY:
case TupleCodes.CISTPL_BYTEORDER:
case TupleCodes.CISTPL_CFTABLE_ENTRY:
case TupleCodes.CISTPL_CFTABLE_ENTRY_CB:
case TupleCodes.CISTPL_CHECKSUM:
case TupleCodes.CISTPL_CONFIG:
case TupleCodes.CISTPL_CONFIG_CB:
case TupleCodes.CISTPL_DATE:
case TupleCodes.CISTPL_DEVICE:
case TupleCodes.CISTPL_DEVICE_A:
case TupleCodes.CISTPL_DEVICE_OA:
case TupleCodes.CISTPL_DEVICE_OC:
case TupleCodes.CISTPL_EXTDEVIC:
case TupleCodes.CISTPL_FORMAT:
case TupleCodes.CISTPL_FORMAT_A:
case TupleCodes.CISTPL_FUNCE:
case TupleCodes.CISTPL_FUNCID:
case TupleCodes.CISTPL_GEOMETRY:
case TupleCodes.CISTPL_INDIRECT:
case TupleCodes.CISTPL_JEDEC_A:
case TupleCodes.CISTPL_JEDEC_C:
case TupleCodes.CISTPL_LINKTARGET:
case TupleCodes.CISTPL_LONGLINK_A:
case TupleCodes.CISTPL_LONGLINK_C:
case TupleCodes.CISTPL_LONGLINK_CB:
case TupleCodes.CISTPL_LONGLINK_MFC:
case TupleCodes.CISTPL_NO_LINK:
case TupleCodes.CISTPL_ORG:
case TupleCodes.CISTPL_PWR_MGMNT:
case TupleCodes.CISTPL_SPCL:
case TupleCodes.CISTPL_SWIL:
case TupleCodes.CISTPL_VERS_2:
tupleCode = $"Undecoded tuple ID {tuple.Code}";
tupleDescription = $"Undecoded tuple ID {tuple.Code}";
break;
case TupleCodes.CISTPL_ALTSTR:
case TupleCodes.CISTPL_BAR:
case TupleCodes.CISTPL_BATTERY:
case TupleCodes.CISTPL_BYTEORDER:
case TupleCodes.CISTPL_CFTABLE_ENTRY:
case TupleCodes.CISTPL_CFTABLE_ENTRY_CB:
case TupleCodes.CISTPL_CHECKSUM:
case TupleCodes.CISTPL_CONFIG:
case TupleCodes.CISTPL_CONFIG_CB:
case TupleCodes.CISTPL_DATE:
case TupleCodes.CISTPL_DEVICE:
case TupleCodes.CISTPL_DEVICE_A:
case TupleCodes.CISTPL_DEVICE_OA:
case TupleCodes.CISTPL_DEVICE_OC:
case TupleCodes.CISTPL_EXTDEVIC:
case TupleCodes.CISTPL_FORMAT:
case TupleCodes.CISTPL_FORMAT_A:
case TupleCodes.CISTPL_FUNCE:
case TupleCodes.CISTPL_FUNCID:
case TupleCodes.CISTPL_GEOMETRY:
case TupleCodes.CISTPL_INDIRECT:
case TupleCodes.CISTPL_JEDEC_A:
case TupleCodes.CISTPL_JEDEC_C:
case TupleCodes.CISTPL_LINKTARGET:
case TupleCodes.CISTPL_LONGLINK_A:
case TupleCodes.CISTPL_LONGLINK_C:
case TupleCodes.CISTPL_LONGLINK_CB:
case TupleCodes.CISTPL_LONGLINK_MFC:
case TupleCodes.CISTPL_NO_LINK:
case TupleCodes.CISTPL_ORG:
case TupleCodes.CISTPL_PWR_MGMNT:
case TupleCodes.CISTPL_SPCL:
case TupleCodes.CISTPL_SWIL:
case TupleCodes.CISTPL_VERS_2:
tupleCode = $"Undecoded tuple ID {tuple.Code}";
tupleDescription = $"Undecoded tuple ID {tuple.Code}";
break;
default:
tupleCode = $"0x{(byte)tuple.Code:X2}";
tupleDescription = $"Found unknown tuple ID 0x{(byte)tuple.Code:X2}";
break;
default:
tupleCode = $"0x{(byte)tuple.Code:X2}";
tupleDescription = $"Found unknown tuple ID 0x{(byte)tuple.Code:X2}";
break;
}
CisList.Add(new PcmciaCisModel
{
Code = tupleCode,
Description = tupleDescription
});
break;
}
else
AaruConsole.DebugWriteLine("Device-Info command", "PCMCIA CIS returned no tuples");
}
public ObservableCollection<PcmciaCisModel> CisList { get; }
public string PcmciaCisText
{
get => _pcmciaCisText;
set => this.RaiseAndSetIfChanged(ref _pcmciaCisText, value);
}
public PcmciaCisModel SelectedCis
{
get => _selectedCis;
set
{
if(_selectedCis == value)
return;
PcmciaCisText = value?.Description;
this.RaiseAndSetIfChanged(ref _selectedCis, value);
}
}
public ReactiveCommand<Unit, Unit> SavePcmciaCisCommand { get; }
async void ExecuteSavePcmciaCisCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
CisList.Add(new PcmciaCisModel
{
"*.bin"
}),
Name = "Binary"
});
Code = tupleCode,
Description = tupleDescription
});
}
else
AaruConsole.DebugWriteLine("Device-Info command", "PCMCIA CIS returned no tuples");
}
string result = await dlgSaveBinary.ShowAsync(_view);
public ObservableCollection<PcmciaCisModel> CisList { get; }
if(result is null)
public string PcmciaCisText
{
get => _pcmciaCisText;
set => this.RaiseAndSetIfChanged(ref _pcmciaCisText, value);
}
public PcmciaCisModel SelectedCis
{
get => _selectedCis;
set
{
if(_selectedCis == value)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_cis, 0, _cis.Length);
saveFs.Close();
PcmciaCisText = value?.Description;
this.RaiseAndSetIfChanged(ref _selectedCis, value);
}
}
public ReactiveCommand<Unit, Unit> SavePcmciaCisCommand { get; }
async void ExecuteSavePcmciaCisCommand()
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(_cis, 0, _cis.Length);
saveFs.Close();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -33,58 +33,57 @@
using Aaru.CommonTypes.Enums;
using JetBrains.Annotations;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class SdMmcInfoViewModel
{
public sealed class SdMmcInfoViewModel
public SdMmcInfoViewModel(DeviceType deviceType, [CanBeNull] byte[] cid, [CanBeNull] byte[] csd,
[CanBeNull] byte[] ocr, [CanBeNull] byte[] extendedCsd, [CanBeNull] byte[] scr)
{
public SdMmcInfoViewModel(DeviceType deviceType, [CanBeNull] byte[] cid, [CanBeNull] byte[] csd,
[CanBeNull] byte[] ocr, [CanBeNull] byte[] extendedCsd, [CanBeNull] byte[] scr)
switch(deviceType)
{
switch(deviceType)
case DeviceType.MMC:
{
case DeviceType.MMC:
{
//Text = "MultiMediaCard";
//Text = "MultiMediaCard";
if(cid != null)
CidText = Decoders.MMC.Decoders.PrettifyCID(cid);
if(cid != null)
CidText = Decoders.MMC.Decoders.PrettifyCID(cid);
if(csd != null)
CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd);
if(csd != null)
CsdText = Decoders.MMC.Decoders.PrettifyCSD(csd);
if(ocr != null)
OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr);
if(ocr != null)
OcrText = Decoders.MMC.Decoders.PrettifyOCR(ocr);
if(extendedCsd != null)
ExtendedCsdText = Decoders.MMC.Decoders.PrettifyExtendedCSD(extendedCsd);
}
break;
case DeviceType.SecureDigital:
{
//Text = "SecureDigital";
if(cid != null)
CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid);
if(csd != null)
CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd);
if(ocr != null)
OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr);
if(scr != null)
ScrText = Decoders.SecureDigital.Decoders.PrettifySCR(scr);
}
break;
if(extendedCsd != null)
ExtendedCsdText = Decoders.MMC.Decoders.PrettifyExtendedCSD(extendedCsd);
}
}
public string CidText { get; }
public string CsdText { get; }
public string OcrText { get; }
public string ExtendedCsdText { get; }
public string ScrText { get; }
break;
case DeviceType.SecureDigital:
{
//Text = "SecureDigital";
if(cid != null)
CidText = Decoders.SecureDigital.Decoders.PrettifyCID(cid);
if(csd != null)
CsdText = Decoders.SecureDigital.Decoders.PrettifyCSD(csd);
if(ocr != null)
OcrText = Decoders.SecureDigital.Decoders.PrettifyOCR(ocr);
if(scr != null)
ScrText = Decoders.SecureDigital.Decoders.PrettifySCR(scr);
}
break;
}
}
public string CidText { get; }
public string CsdText { get; }
public string OcrText { get; }
public string ExtendedCsdText { get; }
public string ScrText { get; }
}

View File

@@ -39,81 +39,80 @@ using Avalonia.Controls;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Tabs
namespace Aaru.Gui.ViewModels.Tabs;
public sealed class XboxInfoViewModel
{
public sealed class XboxInfoViewModel
readonly Window _view;
readonly byte[] _xboxSecuritySector;
public XboxInfoViewModel([CanBeNull] XgdInfo xgdInfo, [CanBeNull] byte[] dmi, [CanBeNull] byte[] securitySector,
SS.SecuritySector? decodedSecuritySector, Window view)
{
readonly Window _view;
readonly byte[] _xboxSecuritySector;
_xboxSecuritySector = securitySector;
_view = view;
SaveXboxSsCommand = ReactiveCommand.Create(ExecuteSaveXboxSsCommand);
public XboxInfoViewModel([CanBeNull] XgdInfo xgdInfo, [CanBeNull] byte[] dmi, [CanBeNull] byte[] securitySector,
SS.SecuritySector? decodedSecuritySector, Window view)
if(xgdInfo != null)
{
_xboxSecuritySector = securitySector;
_view = view;
SaveXboxSsCommand = ReactiveCommand.Create(ExecuteSaveXboxSsCommand);
if(xgdInfo != null)
{
XboxInformationVisible = true;
XboxL0VideoText = $"{xgdInfo.L0Video} sectors";
XboxL1VideoText = $"{xgdInfo.L1Video} sectors";
XboxMiddleZoneText = $"{xgdInfo.MiddleZone} sectors";
XboxGameSizeText = $"{xgdInfo.GameSize} sectors";
XboxTotalSizeText = $"{xgdInfo.TotalSize} sectors";
XboxRealBreakText = xgdInfo.LayerBreak.ToString();
}
if(dmi != null)
{
if(DMI.IsXbox(dmi))
XboxDmiText = DMI.PrettifyXbox(dmi);
else if(DMI.IsXbox360(dmi))
XboxDmiText = DMI.PrettifyXbox360(dmi);
}
if(decodedSecuritySector.HasValue)
XboxSsText = SS.Prettify(decodedSecuritySector);
SaveXboxSsVisible = securitySector != null;
XboxInformationVisible = true;
XboxL0VideoText = $"{xgdInfo.L0Video} sectors";
XboxL1VideoText = $"{xgdInfo.L1Video} sectors";
XboxMiddleZoneText = $"{xgdInfo.MiddleZone} sectors";
XboxGameSizeText = $"{xgdInfo.GameSize} sectors";
XboxTotalSizeText = $"{xgdInfo.TotalSize} sectors";
XboxRealBreakText = xgdInfo.LayerBreak.ToString();
}
public ReactiveCommand<Unit, Unit> SaveXboxSsCommand { get; }
public bool XboxInformationVisible { get; }
public bool SaveXboxSsVisible { get; }
public string XboxL0VideoText { get; }
public string XboxL1VideoText { get; }
public string XboxMiddleZoneText { get; }
public string XboxGameSizeText { get; }
public string XboxTotalSizeText { get; }
public string XboxRealBreakText { get; }
public string XboxDmiText { get; }
public string XboxSsText { get; }
async void SaveElement(byte[] data)
if(dmi != null)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
if(DMI.IsXbox(dmi))
XboxDmiText = DMI.PrettifyXbox(dmi);
else if(DMI.IsXbox360(dmi))
XboxDmiText = DMI.PrettifyXbox360(dmi);
}
public void ExecuteSaveXboxSsCommand() => SaveElement(_xboxSecuritySector);
if(decodedSecuritySector.HasValue)
XboxSsText = SS.Prettify(decodedSecuritySector);
SaveXboxSsVisible = securitySector != null;
}
public ReactiveCommand<Unit, Unit> SaveXboxSsCommand { get; }
public bool XboxInformationVisible { get; }
public bool SaveXboxSsVisible { get; }
public string XboxL0VideoText { get; }
public string XboxL1VideoText { get; }
public string XboxMiddleZoneText { get; }
public string XboxGameSizeText { get; }
public string XboxTotalSizeText { get; }
public string XboxRealBreakText { get; }
public string XboxDmiText { get; }
public string XboxSsText { get; }
async void SaveElement(byte[] data)
{
var dlgSaveBinary = new SaveFileDialog();
dlgSaveBinary.Filters.Add(new FileDialogFilter
{
Extensions = new List<string>(new[]
{
"*.bin"
}),
Name = "Binary"
});
string result = await dlgSaveBinary.ShowAsync(_view);
if(result is null)
return;
var saveFs = new FileStream(result, FileMode.Create);
saveFs.Write(data, 0, data.Length);
saveFs.Close();
}
public void ExecuteSaveXboxSsCommand() => SaveElement(_xboxSecuritySector);
}

View File

@@ -32,7 +32,6 @@
using ReactiveUI;
namespace Aaru.Gui.ViewModels
{
public class ViewModelBase : ReactiveObject {}
}
namespace Aaru.Gui.ViewModels;
public class ViewModelBase : ReactiveObject {}

View File

@@ -54,199 +54,198 @@ using DMI = Aaru.Decoders.Xbox.DMI;
using Inquiry = Aaru.Decoders.SCSI.Inquiry;
using Spare = Aaru.Decoders.DVD.Spare;
namespace Aaru.Gui.ViewModels.Windows
namespace Aaru.Gui.ViewModels.Windows;
public sealed class DecodeMediaTagsViewModel : ViewModelBase
{
public sealed class DecodeMediaTagsViewModel : ViewModelBase
const int HEX_COLUMNS = 32;
readonly MediaType _mediaType;
string _decodedText;
bool _decodedVisible;
string _hexViewText;
MediaTagModel _selectedTag;
public DecodeMediaTagsViewModel([NotNull] IMediaImage inputFormat)
{
const int HEX_COLUMNS = 32;
readonly MediaType _mediaType;
string _decodedText;
bool _decodedVisible;
string _hexViewText;
MediaTagModel _selectedTag;
TagsList = new ObservableCollection<MediaTagModel>();
public DecodeMediaTagsViewModel([NotNull] IMediaImage inputFormat)
_mediaType = inputFormat.Info.MediaType;
foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags)
{
TagsList = new ObservableCollection<MediaTagModel>();
ErrorNumber errno = inputFormat.ReadMediaTag(tag, out byte[] data);
_mediaType = inputFormat.Info.MediaType;
foreach(MediaTagType tag in inputFormat.Info.ReadableMediaTags)
{
ErrorNumber errno = inputFormat.ReadMediaTag(tag, out byte[] data);
if(errno == ErrorNumber.NoError)
TagsList.Add(new MediaTagModel
{
Tag = tag,
Data = data
});
}
}
public string Title { get; }
public ObservableCollection<MediaTagModel> TagsList { get; }
public MediaTagModel SelectedTag
{
get => _selectedTag;
set
{
this.RaiseAndSetIfChanged(ref _selectedTag, value);
if(value is null)
return;
// TODO: Decoders should be able to handle tags with/without length header
HexViewText = PrintHex.ByteArrayToHexArrayString(value.Data, HEX_COLUMNS);
DecodedVisible = true;
if(value.Decoded != null)
if(errno == ErrorNumber.NoError)
TagsList.Add(new MediaTagModel
{
DecodedText = value.Decoded;
return;
}
switch(value.Tag)
{
case MediaTagType.CD_TOC:
DecodedText = TOC.Prettify(value.Data);
break;
case MediaTagType.CD_SessionInfo:
DecodedText = Session.Prettify(value.Data);
break;
case MediaTagType.CD_FullTOC:
DecodedText = FullTOC.Prettify(value.Data);
break;
case MediaTagType.CD_PMA:
DecodedText = PMA.Prettify(value.Data);
break;
case MediaTagType.CD_ATIP:
DecodedText = ATIP.Prettify(value.Data);
break;
case MediaTagType.CD_TEXT:
DecodedText = CDTextOnLeadIn.Prettify(value.Data);
break;
case MediaTagType.CD_MCN:
DecodedText = Encoding.ASCII.GetString(value.Data);
break;
case MediaTagType.DVD_PFI:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.DVD_CMI:
DecodedText = CSS_CPRM.PrettifyLeadInCopyright(value.Data);
break;
case MediaTagType.DVDRAM_DDS:
DecodedText = DDS.Prettify(value.Data);
break;
case MediaTagType.DVDRAM_SpareArea:
DecodedText = Spare.Prettify(value.Data);
break;
case MediaTagType.DVDR_PFI:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.HDDVD_MediumStatus:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.BD_DI:
DecodedText = DI.Prettify(value.Data);
break;
case MediaTagType.BD_BCA:
DecodedText = BCA.Prettify(value.Data);
break;
case MediaTagType.BD_DDS:
DecodedText = Decoders.Bluray.DDS.Prettify(value.Data);
break;
case MediaTagType.BD_CartridgeStatus:
DecodedText = Cartridge.Prettify(value.Data);
break;
case MediaTagType.BD_SpareArea:
DecodedText = Decoders.Bluray.Spare.Prettify(value.Data);
break;
case MediaTagType.MMC_WriteProtection:
DecodedText = WriteProtect.PrettifyWriteProtectionStatus(value.Data);
break;
case MediaTagType.MMC_DiscInformation:
DecodedText = DiscInformation.Prettify(value.Data);
break;
case MediaTagType.SCSI_INQUIRY:
DecodedText = Inquiry.Prettify(value.Data);
break;
case MediaTagType.SCSI_MODEPAGE_2A:
DecodedText = Modes.PrettifyModePage_2A(value.Data);
break;
case MediaTagType.ATA_IDENTIFY:
case MediaTagType.ATAPI_IDENTIFY:
DecodedText = Identify.Prettify(value.Data);
break;
case MediaTagType.Xbox_SecuritySector:
DecodedText = SS.Prettify(value.Data);
break;
case MediaTagType.SCSI_MODESENSE_6:
DecodedText = Modes.PrettifyModeHeader6(value.Data, PeripheralDeviceTypes.DirectAccess);
break;
case MediaTagType.SCSI_MODESENSE_10:
DecodedText = Modes.PrettifyModeHeader10(value.Data, PeripheralDeviceTypes.DirectAccess);
break;
case MediaTagType.Xbox_DMI:
DecodedText = DMI.IsXbox360(value.Data) ? DMI.PrettifyXbox360(value.Data)
: DMI.PrettifyXbox(value.Data);
break;
default:
DecodedVisible = false;
break;
}
if(DecodedText != null)
value.Decoded = DecodedText;
}
}
public string HexViewText
{
get => _hexViewText;
set => this.RaiseAndSetIfChanged(ref _hexViewText, value);
}
public bool DecodedVisible
{
get => _decodedVisible;
set => this.RaiseAndSetIfChanged(ref _decodedVisible, value);
}
public string DecodedText
{
get => _decodedText;
set => this.RaiseAndSetIfChanged(ref _decodedText, value);
Tag = tag,
Data = data
});
}
}
public string Title { get; }
public ObservableCollection<MediaTagModel> TagsList { get; }
public MediaTagModel SelectedTag
{
get => _selectedTag;
set
{
this.RaiseAndSetIfChanged(ref _selectedTag, value);
if(value is null)
return;
// TODO: Decoders should be able to handle tags with/without length header
HexViewText = PrintHex.ByteArrayToHexArrayString(value.Data, HEX_COLUMNS);
DecodedVisible = true;
if(value.Decoded != null)
{
DecodedText = value.Decoded;
return;
}
switch(value.Tag)
{
case MediaTagType.CD_TOC:
DecodedText = TOC.Prettify(value.Data);
break;
case MediaTagType.CD_SessionInfo:
DecodedText = Session.Prettify(value.Data);
break;
case MediaTagType.CD_FullTOC:
DecodedText = FullTOC.Prettify(value.Data);
break;
case MediaTagType.CD_PMA:
DecodedText = PMA.Prettify(value.Data);
break;
case MediaTagType.CD_ATIP:
DecodedText = ATIP.Prettify(value.Data);
break;
case MediaTagType.CD_TEXT:
DecodedText = CDTextOnLeadIn.Prettify(value.Data);
break;
case MediaTagType.CD_MCN:
DecodedText = Encoding.ASCII.GetString(value.Data);
break;
case MediaTagType.DVD_PFI:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.DVD_CMI:
DecodedText = CSS_CPRM.PrettifyLeadInCopyright(value.Data);
break;
case MediaTagType.DVDRAM_DDS:
DecodedText = DDS.Prettify(value.Data);
break;
case MediaTagType.DVDRAM_SpareArea:
DecodedText = Spare.Prettify(value.Data);
break;
case MediaTagType.DVDR_PFI:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.HDDVD_MediumStatus:
DecodedText = PFI.Prettify(value.Data, _mediaType);
break;
case MediaTagType.BD_DI:
DecodedText = DI.Prettify(value.Data);
break;
case MediaTagType.BD_BCA:
DecodedText = BCA.Prettify(value.Data);
break;
case MediaTagType.BD_DDS:
DecodedText = Decoders.Bluray.DDS.Prettify(value.Data);
break;
case MediaTagType.BD_CartridgeStatus:
DecodedText = Cartridge.Prettify(value.Data);
break;
case MediaTagType.BD_SpareArea:
DecodedText = Decoders.Bluray.Spare.Prettify(value.Data);
break;
case MediaTagType.MMC_WriteProtection:
DecodedText = WriteProtect.PrettifyWriteProtectionStatus(value.Data);
break;
case MediaTagType.MMC_DiscInformation:
DecodedText = DiscInformation.Prettify(value.Data);
break;
case MediaTagType.SCSI_INQUIRY:
DecodedText = Inquiry.Prettify(value.Data);
break;
case MediaTagType.SCSI_MODEPAGE_2A:
DecodedText = Modes.PrettifyModePage_2A(value.Data);
break;
case MediaTagType.ATA_IDENTIFY:
case MediaTagType.ATAPI_IDENTIFY:
DecodedText = Identify.Prettify(value.Data);
break;
case MediaTagType.Xbox_SecuritySector:
DecodedText = SS.Prettify(value.Data);
break;
case MediaTagType.SCSI_MODESENSE_6:
DecodedText = Modes.PrettifyModeHeader6(value.Data, PeripheralDeviceTypes.DirectAccess);
break;
case MediaTagType.SCSI_MODESENSE_10:
DecodedText = Modes.PrettifyModeHeader10(value.Data, PeripheralDeviceTypes.DirectAccess);
break;
case MediaTagType.Xbox_DMI:
DecodedText = DMI.IsXbox360(value.Data) ? DMI.PrettifyXbox360(value.Data)
: DMI.PrettifyXbox(value.Data);
break;
default:
DecodedVisible = false;
break;
}
if(DecodedText != null)
value.Decoded = DecodedText;
}
}
public string HexViewText
{
get => _hexViewText;
set => this.RaiseAndSetIfChanged(ref _hexViewText, value);
}
public bool DecodedVisible
{
get => _decodedVisible;
set => this.RaiseAndSetIfChanged(ref _decodedVisible, value);
}
public string DecodedText
{
get => _decodedText;
set => this.RaiseAndSetIfChanged(ref _decodedText, value);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -44,384 +44,383 @@ using Avalonia.Threading;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Windows
namespace Aaru.Gui.ViewModels.Windows;
public sealed class ImageEntropyViewModel : ViewModelBase
{
public sealed class ImageEntropyViewModel : ViewModelBase
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _closeVisible;
bool _duplicatedSectorsChecked;
bool _duplicatedSectorsEnabled;
EntropyResults _entropy;
string _mediaEntropyText;
bool _mediaEntropyVisible;
string _mediaUniqueSectorsText;
bool _mediaUniqueSectorsVisible;
bool _optionsVisible;
bool _progress1Visible;
bool _progress2Indeterminate;
double _progress2Max;
string _progress2Text;
double _progress2Value;
bool _progress2Visible;
bool _progressIndeterminate;
double _progressMax;
string _progressText;
double _progressValue;
bool _progressVisible;
bool _resultsVisible;
bool _separatedTracksChecked;
bool _separatedTracksEnabled;
bool _separatedTracksVisible;
bool _startVisible;
bool _stopVisible;
EntropyResults[] _tracksEntropy;
bool _wholeDiscChecked;
bool _wholeDiscEnabled;
bool _wholeDiscVisible;
public ImageEntropyViewModel(IMediaImage inputFormat, Window view)
{
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _closeVisible;
bool _duplicatedSectorsChecked;
bool _duplicatedSectorsEnabled;
EntropyResults _entropy;
string _mediaEntropyText;
bool _mediaEntropyVisible;
string _mediaUniqueSectorsText;
bool _mediaUniqueSectorsVisible;
bool _optionsVisible;
bool _progress1Visible;
bool _progress2Indeterminate;
double _progress2Max;
string _progress2Text;
double _progress2Value;
bool _progress2Visible;
bool _progressIndeterminate;
double _progressMax;
string _progressText;
double _progressValue;
bool _progressVisible;
bool _resultsVisible;
bool _separatedTracksChecked;
bool _separatedTracksEnabled;
bool _separatedTracksVisible;
bool _startVisible;
bool _stopVisible;
EntropyResults[] _tracksEntropy;
bool _wholeDiscChecked;
bool _wholeDiscEnabled;
bool _wholeDiscVisible;
_inputFormat = inputFormat;
_view = view;
TrackEntropy = new ObservableCollection<TrackEntropyModel>();
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
OptionsVisible = true;
DuplicatedSectorsChecked = true;
SeparatedTracksChecked = true;
WholeDiscChecked = true;
StartVisible = true;
public ImageEntropyViewModel(IMediaImage inputFormat, Window view)
var inputOptical = inputFormat as IOpticalMediaImage;
if(inputOptical?.Tracks.Count > 0)
{
_inputFormat = inputFormat;
_view = view;
TrackEntropy = new ObservableCollection<TrackEntropyModel>();
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
OptionsVisible = true;
DuplicatedSectorsChecked = true;
SeparatedTracksChecked = true;
WholeDiscChecked = true;
StartVisible = true;
SeparatedTracksVisible = true;
WholeDiscVisible = true;
}
else
{
SeparatedTracksChecked = false;
WholeDiscChecked = true;
}
}
var inputOptical = inputFormat as IOpticalMediaImage;
public bool SeparatedTracksVisible
{
get => _separatedTracksVisible;
set => this.RaiseAndSetIfChanged(ref _separatedTracksVisible, value);
}
if(inputOptical?.Tracks.Count > 0)
{
SeparatedTracksVisible = true;
WholeDiscVisible = true;
}
else
{
SeparatedTracksChecked = false;
WholeDiscChecked = true;
}
public bool WholeDiscVisible
{
get => _wholeDiscVisible;
set => this.RaiseAndSetIfChanged(ref _wholeDiscVisible, value);
}
public bool SeparatedTracksChecked
{
get => _separatedTracksChecked;
set => this.RaiseAndSetIfChanged(ref _separatedTracksChecked, value);
}
public bool WholeDiscChecked
{
get => _wholeDiscChecked;
set => this.RaiseAndSetIfChanged(ref _wholeDiscChecked, value);
}
public bool DuplicatedSectorsEnabled
{
get => _duplicatedSectorsEnabled;
set => this.RaiseAndSetIfChanged(ref _duplicatedSectorsEnabled, value);
}
public bool SeparatedTracksEnabled
{
get => _separatedTracksEnabled;
set => this.RaiseAndSetIfChanged(ref _separatedTracksEnabled, value);
}
public bool WholeDiscEnabled
{
get => _wholeDiscEnabled;
set => this.RaiseAndSetIfChanged(ref _wholeDiscEnabled, value);
}
public bool CloseVisible
{
get => _closeVisible;
set => this.RaiseAndSetIfChanged(ref _closeVisible, value);
}
public bool StartVisible
{
get => _startVisible;
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
}
public bool StopVisible
{
get => _stopVisible;
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
}
public bool ProgressVisible
{
get => _progressVisible;
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
}
public bool DuplicatedSectorsChecked
{
get => _duplicatedSectorsChecked;
set => this.RaiseAndSetIfChanged(ref _duplicatedSectorsChecked, value);
}
public bool OptionsVisible
{
get => _optionsVisible;
set => this.RaiseAndSetIfChanged(ref _optionsVisible, value);
}
public bool ResultsVisible
{
get => _resultsVisible;
set => this.RaiseAndSetIfChanged(ref _resultsVisible, value);
}
public string MediaEntropyText
{
get => _mediaEntropyText;
set => this.RaiseAndSetIfChanged(ref _mediaEntropyText, value);
}
public bool MediaEntropyVisible
{
get => _mediaEntropyVisible;
set => this.RaiseAndSetIfChanged(ref _mediaEntropyVisible, value);
}
public string MediaUniqueSectorsText
{
get => _mediaUniqueSectorsText;
set => this.RaiseAndSetIfChanged(ref _mediaUniqueSectorsText, value);
}
public bool MediaUniqueSectorsVisible
{
get => _mediaUniqueSectorsVisible;
set => this.RaiseAndSetIfChanged(ref _mediaUniqueSectorsVisible, value);
}
public bool Progress1Visible
{
get => _progress1Visible;
set => this.RaiseAndSetIfChanged(ref _progress1Visible, value);
}
public bool Progress2Visible
{
get => _progress2Visible;
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
}
public string ProgressText
{
get => _progressText;
set => this.RaiseAndSetIfChanged(ref _progressText, value);
}
public bool ProgressIndeterminate
{
get => _progressIndeterminate;
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
}
public double ProgressMax
{
get => _progressMax;
set => this.RaiseAndSetIfChanged(ref _progressMax, value);
}
public double ProgressValue
{
get => _progressValue;
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
}
public string Progress2Text
{
get => _progress2Text;
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
}
public bool Progress2Indeterminate
{
get => _progress2Indeterminate;
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
}
public double Progress2Max
{
get => _progress2Max;
set => this.RaiseAndSetIfChanged(ref _progress2Max, value);
}
public double Progress2Value
{
get => _progress2Value;
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
}
[NotNull]
public string Title => "Calculating entropy";
public ObservableCollection<TrackEntropyModel> TrackEntropy { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ReactiveCommand<Unit, Unit> StopCommand { get; }
void ExecuteStartCommand()
{
var entropyCalculator = new Entropy(false, _inputFormat);
entropyCalculator.InitProgressEvent += InitProgress;
entropyCalculator.InitProgress2Event += InitProgress2;
entropyCalculator.UpdateProgressEvent += UpdateProgress;
entropyCalculator.UpdateProgress2Event += UpdateProgress2;
entropyCalculator.EndProgressEvent += EndProgress;
entropyCalculator.EndProgress2Event += EndProgress2;
DuplicatedSectorsEnabled = false;
SeparatedTracksEnabled = false;
WholeDiscEnabled = false;
CloseVisible = false;
StartVisible = false;
StopVisible = false;
ProgressVisible = true;
if(WholeDiscChecked &&
_inputFormat is IOpticalMediaImage opticalFormat &&
opticalFormat.Sessions?.Count > 1)
{
AaruConsole.ErrorWriteLine("Calculating disc entropy of multisession images is not yet implemented.");
WholeDiscChecked = false;
}
public bool SeparatedTracksVisible
var thread = new Thread(async () =>
{
get => _separatedTracksVisible;
set => this.RaiseAndSetIfChanged(ref _separatedTracksVisible, value);
}
public bool WholeDiscVisible
{
get => _wholeDiscVisible;
set => this.RaiseAndSetIfChanged(ref _wholeDiscVisible, value);
}
public bool SeparatedTracksChecked
{
get => _separatedTracksChecked;
set => this.RaiseAndSetIfChanged(ref _separatedTracksChecked, value);
}
public bool WholeDiscChecked
{
get => _wholeDiscChecked;
set => this.RaiseAndSetIfChanged(ref _wholeDiscChecked, value);
}
public bool DuplicatedSectorsEnabled
{
get => _duplicatedSectorsEnabled;
set => this.RaiseAndSetIfChanged(ref _duplicatedSectorsEnabled, value);
}
public bool SeparatedTracksEnabled
{
get => _separatedTracksEnabled;
set => this.RaiseAndSetIfChanged(ref _separatedTracksEnabled, value);
}
public bool WholeDiscEnabled
{
get => _wholeDiscEnabled;
set => this.RaiseAndSetIfChanged(ref _wholeDiscEnabled, value);
}
public bool CloseVisible
{
get => _closeVisible;
set => this.RaiseAndSetIfChanged(ref _closeVisible, value);
}
public bool StartVisible
{
get => _startVisible;
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
}
public bool StopVisible
{
get => _stopVisible;
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
}
public bool ProgressVisible
{
get => _progressVisible;
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
}
public bool DuplicatedSectorsChecked
{
get => _duplicatedSectorsChecked;
set => this.RaiseAndSetIfChanged(ref _duplicatedSectorsChecked, value);
}
public bool OptionsVisible
{
get => _optionsVisible;
set => this.RaiseAndSetIfChanged(ref _optionsVisible, value);
}
public bool ResultsVisible
{
get => _resultsVisible;
set => this.RaiseAndSetIfChanged(ref _resultsVisible, value);
}
public string MediaEntropyText
{
get => _mediaEntropyText;
set => this.RaiseAndSetIfChanged(ref _mediaEntropyText, value);
}
public bool MediaEntropyVisible
{
get => _mediaEntropyVisible;
set => this.RaiseAndSetIfChanged(ref _mediaEntropyVisible, value);
}
public string MediaUniqueSectorsText
{
get => _mediaUniqueSectorsText;
set => this.RaiseAndSetIfChanged(ref _mediaUniqueSectorsText, value);
}
public bool MediaUniqueSectorsVisible
{
get => _mediaUniqueSectorsVisible;
set => this.RaiseAndSetIfChanged(ref _mediaUniqueSectorsVisible, value);
}
public bool Progress1Visible
{
get => _progress1Visible;
set => this.RaiseAndSetIfChanged(ref _progress1Visible, value);
}
public bool Progress2Visible
{
get => _progress2Visible;
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
}
public string ProgressText
{
get => _progressText;
set => this.RaiseAndSetIfChanged(ref _progressText, value);
}
public bool ProgressIndeterminate
{
get => _progressIndeterminate;
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
}
public double ProgressMax
{
get => _progressMax;
set => this.RaiseAndSetIfChanged(ref _progressMax, value);
}
public double ProgressValue
{
get => _progressValue;
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
}
public string Progress2Text
{
get => _progress2Text;
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
}
public bool Progress2Indeterminate
{
get => _progress2Indeterminate;
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
}
public double Progress2Max
{
get => _progress2Max;
set => this.RaiseAndSetIfChanged(ref _progress2Max, value);
}
public double Progress2Value
{
get => _progress2Value;
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
}
[NotNull]
public string Title => "Calculating entropy";
public ObservableCollection<TrackEntropyModel> TrackEntropy { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ReactiveCommand<Unit, Unit> StopCommand { get; }
void ExecuteStartCommand()
{
var entropyCalculator = new Entropy(false, _inputFormat);
entropyCalculator.InitProgressEvent += InitProgress;
entropyCalculator.InitProgress2Event += InitProgress2;
entropyCalculator.UpdateProgressEvent += UpdateProgress;
entropyCalculator.UpdateProgress2Event += UpdateProgress2;
entropyCalculator.EndProgressEvent += EndProgress;
entropyCalculator.EndProgress2Event += EndProgress2;
DuplicatedSectorsEnabled = false;
SeparatedTracksEnabled = false;
WholeDiscEnabled = false;
CloseVisible = false;
StartVisible = false;
StopVisible = false;
ProgressVisible = true;
if(WholeDiscChecked &&
_inputFormat is IOpticalMediaImage opticalFormat &&
opticalFormat.Sessions?.Count > 1)
{
AaruConsole.ErrorWriteLine("Calculating disc entropy of multisession images is not yet implemented.");
WholeDiscChecked = false;
}
var thread = new Thread(async () =>
{
if(SeparatedTracksChecked)
{
_tracksEntropy = entropyCalculator.CalculateTracksEntropy(DuplicatedSectorsChecked);
foreach(EntropyResults trackEntropy in _tracksEntropy)
{
AaruConsole.WriteLine("Entropy for track {0} is {1:F4}.", trackEntropy.Track,
trackEntropy.Entropy);
if(trackEntropy.UniqueSectors != null)
AaruConsole.WriteLine("Track {0} has {1} unique sectors ({2:P3})", trackEntropy.Track,
trackEntropy.UniqueSectors,
(double)trackEntropy.UniqueSectors / trackEntropy.Sectors);
}
}
if(WholeDiscChecked != true)
return;
_entropy = entropyCalculator.CalculateMediaEntropy(DuplicatedSectorsChecked);
await Dispatcher.UIThread.InvokeAsync(Finish);
});
Statistics.AddCommand("entropy");
thread.Start();
}
void Finish()
{
OptionsVisible = false;
CloseVisible = true;
ProgressVisible = false;
ResultsVisible = true;
if(SeparatedTracksChecked)
{
_tracksEntropy = entropyCalculator.CalculateTracksEntropy(DuplicatedSectorsChecked);
foreach(EntropyResults trackEntropy in _tracksEntropy)
TrackEntropy.Add(new TrackEntropyModel
{
Track = trackEntropy.Track.ToString(),
Entropy = trackEntropy.Entropy.ToString(CultureInfo.CurrentUICulture),
UniqueSectors =
$"{trackEntropy.UniqueSectors} ({(trackEntropy.UniqueSectors ?? 0) / (double)trackEntropy.Sectors:P3})"
});
{
AaruConsole.WriteLine("Entropy for track {0} is {1:F4}.", trackEntropy.Track,
trackEntropy.Entropy);
if(trackEntropy.UniqueSectors != null)
AaruConsole.WriteLine("Track {0} has {1} unique sectors ({2:P3})", trackEntropy.Track,
trackEntropy.UniqueSectors,
(double)trackEntropy.UniqueSectors / trackEntropy.Sectors);
}
}
if(WholeDiscChecked != true)
return;
MediaEntropyText = $"Entropy for disk is {_entropy.Entropy:F4}.";
MediaEntropyVisible = true;
_entropy = entropyCalculator.CalculateMediaEntropy(DuplicatedSectorsChecked);
if(_entropy.UniqueSectors == null)
return;
await Dispatcher.UIThread.InvokeAsync(Finish);
});
MediaUniqueSectorsText =
$"Disk has {_entropy.UniqueSectors} unique sectors ({(double)_entropy.UniqueSectors / _entropy.Sectors:P3})";
Statistics.AddCommand("entropy");
MediaUniqueSectorsVisible = true;
thread.Start();
}
void Finish()
{
OptionsVisible = false;
CloseVisible = true;
ProgressVisible = false;
ResultsVisible = true;
if(SeparatedTracksChecked)
{
foreach(EntropyResults trackEntropy in _tracksEntropy)
TrackEntropy.Add(new TrackEntropyModel
{
Track = trackEntropy.Track.ToString(),
Entropy = trackEntropy.Entropy.ToString(CultureInfo.CurrentUICulture),
UniqueSectors =
$"{trackEntropy.UniqueSectors} ({(trackEntropy.UniqueSectors ?? 0) / (double)trackEntropy.Sectors:P3})"
});
}
void ExecuteCloseCommand() => _view.Close();
if(WholeDiscChecked != true)
return;
internal void ExecuteStopCommand() => throw new NotImplementedException();
MediaEntropyText = $"Entropy for disk is {_entropy.Entropy:F4}.";
MediaEntropyVisible = true;
void InitProgress() => Progress1Visible = true;
if(_entropy.UniqueSectors == null)
return;
void EndProgress() => Progress1Visible = false;
MediaUniqueSectorsText =
$"Disk has {_entropy.UniqueSectors} unique sectors ({(double)_entropy.UniqueSectors / _entropy.Sectors:P3})";
void InitProgress2() => Progress2Visible = true;
void EndProgress2() => Progress2Visible = false;
async void UpdateProgress(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
if(maximum == 0)
{
ProgressIndeterminate = true;
return;
}
if(ProgressIndeterminate)
ProgressIndeterminate = false;
ProgressMax = maximum;
ProgressValue = current;
});
async void UpdateProgress2(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;
if(maximum == 0)
{
Progress2Indeterminate = true;
return;
}
if(Progress2Indeterminate)
Progress2Indeterminate = false;
Progress2Max = maximum;
Progress2Value = current;
});
MediaUniqueSectorsVisible = true;
}
void ExecuteCloseCommand() => _view.Close();
internal void ExecuteStopCommand() => throw new NotImplementedException();
void InitProgress() => Progress1Visible = true;
void EndProgress() => Progress1Visible = false;
void InitProgress2() => Progress2Visible = true;
void EndProgress2() => Progress2Visible = false;
async void UpdateProgress(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
if(maximum == 0)
{
ProgressIndeterminate = true;
return;
}
if(ProgressIndeterminate)
ProgressIndeterminate = false;
ProgressMax = maximum;
ProgressValue = current;
});
async void UpdateProgress2(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;
if(maximum == 0)
{
Progress2Indeterminate = true;
return;
}
if(Progress2Indeterminate)
Progress2Indeterminate = false;
Progress2Max = maximum;
Progress2Value = current;
});
}

View File

@@ -45,305 +45,304 @@ using Avalonia.Threading;
using ReactiveUI;
using Schemas;
namespace Aaru.Gui.ViewModels.Windows
namespace Aaru.Gui.ViewModels.Windows;
public sealed class ImageSidecarViewModel : ViewModelBase
{
public sealed class ImageSidecarViewModel : ViewModelBase
readonly Encoding _encoding;
readonly Guid _filterId;
readonly string _imageSource;
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _closeVisible;
bool _destinationEnabled;
string _destinationText;
bool _progress1Visible;
bool _progress2Indeterminate;
double _progress2MaxValue;
string _progress2Text;
double _progress2Value;
bool _progress2Visible;
bool _progressIndeterminate;
double _progressMaxValue;
string _progressText;
double _progressValue;
bool _progressVisible;
Sidecar _sidecarClass;
bool _startVisible;
string _statusText;
bool _statusVisible;
bool _stopEnabled;
bool _stopVisible;
public ImageSidecarViewModel(IMediaImage inputFormat, string imageSource, Guid filterId, Encoding encoding,
Window view)
{
readonly Encoding _encoding;
readonly Guid _filterId;
readonly string _imageSource;
readonly IMediaImage _inputFormat;
readonly Window _view;
bool _closeVisible;
bool _destinationEnabled;
string _destinationText;
bool _progress1Visible;
bool _progress2Indeterminate;
double _progress2MaxValue;
string _progress2Text;
double _progress2Value;
bool _progress2Visible;
bool _progressIndeterminate;
double _progressMaxValue;
string _progressText;
double _progressValue;
bool _progressVisible;
Sidecar _sidecarClass;
bool _startVisible;
string _statusText;
bool _statusVisible;
bool _stopEnabled;
bool _stopVisible;
_view = view;
_inputFormat = inputFormat;
_imageSource = imageSource;
_filterId = filterId;
_encoding = encoding;
public ImageSidecarViewModel(IMediaImage inputFormat, string imageSource, Guid filterId, Encoding encoding,
Window view)
DestinationText = Path.Combine(Path.GetDirectoryName(imageSource) ?? "",
Path.GetFileNameWithoutExtension(imageSource) + ".cicm.xml");
DestinationEnabled = true;
StartVisible = true;
CloseVisible = true;
DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand);
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
}
public string Title { get; }
public ReactiveCommand<Unit, Unit> DestinationCommand { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ReactiveCommand<Unit, Unit> StopCommand { get; }
public bool ProgressIndeterminate
{
get => _progressIndeterminate;
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
}
public bool ProgressVisible
{
get => _progressVisible;
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
}
public bool Progress1Visible
{
get => _progress1Visible;
set => this.RaiseAndSetIfChanged(ref _progress1Visible, value);
}
public bool Progress2Visible
{
get => _progress2Visible;
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
}
public bool Progress2Indeterminate
{
get => _progress2Indeterminate;
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
}
public double ProgressMaxValue
{
get => _progressMaxValue;
set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value);
}
public double Progress2MaxValue
{
get => _progress2MaxValue;
set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value);
}
public string ProgressText
{
get => _progressText;
set => this.RaiseAndSetIfChanged(ref _progressText, value);
}
public double ProgressValue
{
get => _progressValue;
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
}
public double Progress2Value
{
get => _progress2Value;
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
}
public string Progress2Text
{
get => _progress2Text;
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
}
public string DestinationText
{
get => _destinationText;
set => this.RaiseAndSetIfChanged(ref _destinationText, value);
}
public bool DestinationEnabled
{
get => _destinationEnabled;
set => this.RaiseAndSetIfChanged(ref _destinationEnabled, value);
}
public string StatusText
{
get => _statusText;
set => this.RaiseAndSetIfChanged(ref _statusText, value);
}
public bool StatusVisible
{
get => _statusVisible;
set => this.RaiseAndSetIfChanged(ref _statusVisible, value);
}
public bool StartVisible
{
get => _startVisible;
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
}
public bool CloseVisible
{
get => _closeVisible;
set => this.RaiseAndSetIfChanged(ref _closeVisible, value);
}
public bool StopEnabled
{
get => _stopEnabled;
set => this.RaiseAndSetIfChanged(ref _stopEnabled, value);
}
public bool StopVisible
{
get => _stopVisible;
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
}
void ExecuteStartCommand() => new Thread(DoWork).Start();
async void DoWork()
{
// Prepare UI
await Dispatcher.UIThread.InvokeAsync(() =>
{
_view = view;
_inputFormat = inputFormat;
_imageSource = imageSource;
_filterId = filterId;
_encoding = encoding;
DestinationText = Path.Combine(Path.GetDirectoryName(imageSource) ?? "",
Path.GetFileNameWithoutExtension(imageSource) + ".cicm.xml");
DestinationEnabled = true;
StartVisible = true;
CloseVisible = true;
DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand);
StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
StopCommand = ReactiveCommand.Create(ExecuteStopCommand);
}
public string Title { get; }
public ReactiveCommand<Unit, Unit> DestinationCommand { get; }
public ReactiveCommand<Unit, Unit> StartCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ReactiveCommand<Unit, Unit> StopCommand { get; }
public bool ProgressIndeterminate
{
get => _progressIndeterminate;
set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value);
}
public bool ProgressVisible
{
get => _progressVisible;
set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
}
public bool Progress1Visible
{
get => _progress1Visible;
set => this.RaiseAndSetIfChanged(ref _progress1Visible, value);
}
public bool Progress2Visible
{
get => _progress2Visible;
set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
}
public bool Progress2Indeterminate
{
get => _progress2Indeterminate;
set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, value);
}
public double ProgressMaxValue
{
get => _progressMaxValue;
set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value);
}
public double Progress2MaxValue
{
get => _progress2MaxValue;
set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value);
}
public string ProgressText
{
get => _progressText;
set => this.RaiseAndSetIfChanged(ref _progressText, value);
}
public double ProgressValue
{
get => _progressValue;
set => this.RaiseAndSetIfChanged(ref _progressValue, value);
}
public double Progress2Value
{
get => _progress2Value;
set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
}
public string Progress2Text
{
get => _progress2Text;
set => this.RaiseAndSetIfChanged(ref _progress2Text, value);
}
public string DestinationText
{
get => _destinationText;
set => this.RaiseAndSetIfChanged(ref _destinationText, value);
}
public bool DestinationEnabled
{
get => _destinationEnabled;
set => this.RaiseAndSetIfChanged(ref _destinationEnabled, value);
}
public string StatusText
{
get => _statusText;
set => this.RaiseAndSetIfChanged(ref _statusText, value);
}
public bool StatusVisible
{
get => _statusVisible;
set => this.RaiseAndSetIfChanged(ref _statusVisible, value);
}
public bool StartVisible
{
get => _startVisible;
set => this.RaiseAndSetIfChanged(ref _startVisible, value);
}
public bool CloseVisible
{
get => _closeVisible;
set => this.RaiseAndSetIfChanged(ref _closeVisible, value);
}
public bool StopEnabled
{
get => _stopEnabled;
set => this.RaiseAndSetIfChanged(ref _stopEnabled, value);
}
public bool StopVisible
{
get => _stopVisible;
set => this.RaiseAndSetIfChanged(ref _stopVisible, value);
}
void ExecuteStartCommand() => new Thread(DoWork).Start();
async void DoWork()
{
// Prepare UI
await Dispatcher.UIThread.InvokeAsync(() =>
{
CloseVisible = false;
StartVisible = false;
StopVisible = true;
StopEnabled = true;
ProgressVisible = true;
DestinationEnabled = false;
StatusVisible = true;
});
_sidecarClass = new Sidecar(_inputFormat, _imageSource, _filterId, _encoding);
_sidecarClass.UpdateStatusEvent += UpdateStatus;
_sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress;
_sidecarClass.EndProgressEvent += EndProgress;
_sidecarClass.InitProgressEvent2 += InitProgress2;
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
CICMMetadataType sidecar = _sidecarClass.Create();
AaruConsole.WriteLine("Writing metadata sidecar");
var xmlFs = new FileStream(DestinationText, FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
await Dispatcher.UIThread.InvokeAsync(() =>
{
CloseVisible = true;
StopVisible = false;
ProgressVisible = false;
StatusVisible = false;
});
Statistics.AddCommand("create-sidecar");
}
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
CloseVisible = false;
StartVisible = false;
StopVisible = true;
StopEnabled = true;
ProgressVisible = true;
DestinationEnabled = false;
StatusVisible = true;
});
async void UpdateProgress2(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
_sidecarClass = new Sidecar(_inputFormat, _imageSource, _filterId, _encoding);
_sidecarClass.UpdateStatusEvent += UpdateStatus;
_sidecarClass.InitProgressEvent += InitProgress;
_sidecarClass.UpdateProgressEvent += UpdateProgress;
_sidecarClass.EndProgressEvent += EndProgress;
_sidecarClass.InitProgressEvent2 += InitProgress2;
_sidecarClass.UpdateProgressEvent2 += UpdateProgress2;
_sidecarClass.EndProgressEvent2 += EndProgress2;
CICMMetadataType sidecar = _sidecarClass.Create();
AaruConsole.WriteLine("Writing metadata sidecar");
var xmlFs = new FileStream(DestinationText, FileMode.Create);
var xmlSer = new XmlSerializer(typeof(CICMMetadataType));
xmlSer.Serialize(xmlFs, sidecar);
xmlFs.Close();
await Dispatcher.UIThread.InvokeAsync(() =>
{
CloseVisible = true;
StopVisible = false;
ProgressVisible = false;
StatusVisible = false;
});
Statistics.AddCommand("create-sidecar");
}
async void EndProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = false;
});
async void UpdateProgress2(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Text = text;
Progress2Indeterminate = false;
Progress2MaxValue = maximum;
Progress2Value = current;
});
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
});
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = false;
});
async void UpdateProgress(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
ProgressIndeterminate = false;
ProgressMaxValue = maximum;
ProgressValue = current;
});
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
StatusText = text;
});
void ExecuteCloseCommand() => _view.Close();
void ExecuteStopCommand()
{
ProgressText = "Aborting...";
StopEnabled = false;
_sidecarClass.Abort();
}
async void ExecuteDestinationCommand()
{
var dlgDestination = new SaveFileDialog
{
Title = "Choose destination file"
};
dlgDestination.Filters.Add(new FileDialogFilter
{
Name = "CICM XML metadata",
Extensions = new List<string>(new[]
{
Progress2Text = text;
Progress2Indeterminate = false;
Progress2MaxValue = maximum;
Progress2Value = current;
});
async void InitProgress2() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress2Visible = true;
"*.xml"
})
});
async void EndProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
string result = await dlgDestination.ShowAsync(_view);
if(result is null)
{
Progress1Visible = false;
});
DestinationText = "";
async void UpdateProgress(string text, long current, long maximum) =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
ProgressText = text;
ProgressIndeterminate = false;
ProgressMaxValue = maximum;
ProgressValue = current;
});
async void InitProgress() => await Dispatcher.UIThread.InvokeAsync(() =>
{
Progress1Visible = true;
});
async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() =>
{
StatusText = text;
});
void ExecuteCloseCommand() => _view.Close();
void ExecuteStopCommand()
{
ProgressText = "Aborting...";
StopEnabled = false;
_sidecarClass.Abort();
return;
}
async void ExecuteDestinationCommand()
{
var dlgDestination = new SaveFileDialog
{
Title = "Choose destination file"
};
if(string.IsNullOrEmpty(Path.GetExtension(result)))
result += ".xml";
dlgDestination.Filters.Add(new FileDialogFilter
{
Name = "CICM XML metadata",
Extensions = new List<string>(new[]
{
"*.xml"
})
});
string result = await dlgDestination.ShowAsync(_view);
if(result is null)
{
DestinationText = "";
return;
}
if(string.IsNullOrEmpty(Path.GetExtension(result)))
result += ".xml";
DestinationText = result;
}
DestinationText = result;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -46,250 +46,249 @@ using Avalonia.Threading;
using Microsoft.EntityFrameworkCore;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Windows
namespace Aaru.Gui.ViewModels.Windows;
public sealed class SplashWindowViewModel : ViewModelBase
{
public sealed class SplashWindowViewModel : ViewModelBase
readonly SplashWindow _view;
double _currentProgress;
double _maxProgress;
string _message;
public SplashWindowViewModel(SplashWindow view) => _view = view;
public string Message
{
readonly SplashWindow _view;
double _currentProgress;
double _maxProgress;
string _message;
get => _message;
set => this.RaiseAndSetIfChanged(ref _message, value);
}
public SplashWindowViewModel(SplashWindow view) => _view = view;
public double MaxProgress
{
get => _maxProgress;
set => this.RaiseAndSetIfChanged(ref _maxProgress, value);
}
public string Message
public double CurrentProgress
{
get => _currentProgress;
set => this.RaiseAndSetIfChanged(ref _currentProgress, value);
}
internal void OnOpened()
{
Message = "Welcome to Aaru!";
MaxProgress = 9;
CurrentProgress = 0;
Dispatcher.UIThread.Post(InitializeConsole);
}
void InitializeConsole()
{
CurrentProgress++;
Message = "Initializing console...";
Task.Run(() =>
{
get => _message;
set => this.RaiseAndSetIfChanged(ref _message, value);
}
ConsoleHandler.Init();
AaruConsole.WriteLine("Aaru started!");
public double MaxProgress
Dispatcher.UIThread.Post(LoadSettings);
});
}
void LoadSettings()
{
CurrentProgress++;
Message = "Loading settings...";
AaruConsole.WriteLine("Loading settings...");
Task.Run(() =>
{
get => _maxProgress;
set => this.RaiseAndSetIfChanged(ref _maxProgress, value);
}
// TODO: Detect there are no settings yet
Settings.Settings.LoadSettings();
public double CurrentProgress
Dispatcher.UIThread.Post(MigrateLocalDatabase);
});
}
void MigrateLocalDatabase()
{
CurrentProgress++;
Message = "Migrating local database...";
AaruConsole.WriteLine("Migrating local database...");
Task.Run(() =>
{
get => _currentProgress;
set => this.RaiseAndSetIfChanged(ref _currentProgress, value);
}
AaruContext ctx = null;
internal void OnOpened()
{
Message = "Welcome to Aaru!";
MaxProgress = 9;
CurrentProgress = 0;
Dispatcher.UIThread.Post(InitializeConsole);
}
void InitializeConsole()
{
CurrentProgress++;
Message = "Initializing console...";
Task.Run(() =>
try
{
ConsoleHandler.Init();
AaruConsole.WriteLine("Aaru started!");
Dispatcher.UIThread.Post(LoadSettings);
});
}
void LoadSettings()
{
CurrentProgress++;
Message = "Loading settings...";
AaruConsole.WriteLine("Loading settings...");
Task.Run(() =>
ctx = AaruContext.Create(Settings.Settings.LocalDbPath, false);
ctx.Database.Migrate();
}
catch(NotSupportedException)
{
// TODO: Detect there are no settings yet
Settings.Settings.LoadSettings();
try
{
ctx?.Database.CloseConnection();
ctx?.Dispose();
}
catch(Exception)
{
// Should not ever arrive here, but if it does, keep trying to replace it anyway
}
Dispatcher.UIThread.Post(MigrateLocalDatabase);
});
}
File.Delete(Settings.Settings.LocalDbPath);
ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
ctx.Database.EnsureCreated();
void MigrateLocalDatabase()
ctx.Database.
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database.
ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{migration}', '0.0.0')");
}
ctx.SaveChanges();
}
// Remove duplicates
foreach(var duplicate in ctx.SeenDevices.AsEnumerable()!.GroupBy(a => new
{
a.Manufacturer,
a.Model,
a.Revision,
a.Bus
}).Where(a => a.Count() > 1).Distinct().Select(a => a.Key))
ctx.RemoveRange(ctx.SeenDevices!.
Where(d => d.Manufacturer == duplicate.Manufacturer &&
d.Model == duplicate.Model && d.Revision == duplicate.Revision &&
d.Bus == duplicate.Bus).Skip(1));
// Remove nulls
ctx.RemoveRange(ctx.SeenDevices!.Where(d => d.Manufacturer == null && d.Model == null &&
d.Revision == null));
ctx.SaveChanges();
Dispatcher.UIThread.Post(UpdateMainDatabase);
});
}
void UpdateMainDatabase()
{
CurrentProgress++;
Message = "Updating main database...";
AaruConsole.WriteLine("Updating main database...");
Task.Run(() =>
{
CurrentProgress++;
Message = "Migrating local database...";
AaruConsole.WriteLine("Migrating local database...");
bool mainDbUpdate = false;
Task.Run(() =>
if(!File.Exists(Settings.Settings.MainDbPath))
{
AaruContext ctx = null;
mainDbUpdate = true;
// TODO: Update database
}
var mainContext = AaruContext.Create(Settings.Settings.MainDbPath, false);
if(mainContext.Database.GetPendingMigrations().Any())
{
AaruConsole.WriteLine("New database version, updating...");
try
{
ctx = AaruContext.Create(Settings.Settings.LocalDbPath, false);
ctx.Database.Migrate();
File.Delete(Settings.Settings.MainDbPath);
}
catch(NotSupportedException)
catch(Exception)
{
try
{
ctx?.Database.CloseConnection();
ctx?.Dispose();
}
catch(Exception)
{
// Should not ever arrive here, but if it does, keep trying to replace it anyway
}
AaruConsole.
ErrorWriteLine("Exception trying to remove old database version, cannot continue...");
File.Delete(Settings.Settings.LocalDbPath);
ctx = AaruContext.Create(Settings.Settings.LocalDbPath);
ctx.Database.EnsureCreated();
AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MainDbPath);
ctx.Database.
ExecuteSqlRaw("CREATE TABLE IF NOT EXISTS \"__EFMigrationsHistory\" (\"MigrationId\" TEXT PRIMARY KEY, \"ProductVersion\" TEXT)");
foreach(string migration in ctx.Database.GetPendingMigrations())
{
ctx.Database.
ExecuteSqlRaw($"INSERT INTO \"__EFMigrationsHistory\" (MigrationId, ProductVersion) VALUES ('{migration}', '0.0.0')");
}
ctx.SaveChanges();
return;
}
// Remove duplicates
foreach(var duplicate in ctx.SeenDevices.AsEnumerable()!.GroupBy(a => new
{
a.Manufacturer,
a.Model,
a.Revision,
a.Bus
}).Where(a => a.Count() > 1).Distinct().Select(a => a.Key))
ctx.RemoveRange(ctx.SeenDevices!.
Where(d => d.Manufacturer == duplicate.Manufacturer &&
d.Model == duplicate.Model && d.Revision == duplicate.Revision &&
d.Bus == duplicate.Bus).Skip(1));
// Remove nulls
ctx.RemoveRange(ctx.SeenDevices!.Where(d => d.Manufacturer == null && d.Model == null &&
d.Revision == null));
ctx.SaveChanges();
Dispatcher.UIThread.Post(UpdateMainDatabase);
});
}
void UpdateMainDatabase()
{
CurrentProgress++;
Message = "Updating main database...";
AaruConsole.WriteLine("Updating main database...");
Task.Run(() =>
{
bool mainDbUpdate = false;
if(!File.Exists(Settings.Settings.MainDbPath))
{
mainDbUpdate = true;
// TODO: Update database
}
var mainContext = AaruContext.Create(Settings.Settings.MainDbPath, false);
if(mainContext.Database.GetPendingMigrations().Any())
{
AaruConsole.WriteLine("New database version, updating...");
try
{
File.Delete(Settings.Settings.MainDbPath);
}
catch(Exception)
{
AaruConsole.
ErrorWriteLine("Exception trying to remove old database version, cannot continue...");
AaruConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MainDbPath);
return;
}
// TODO: Update database
}
Dispatcher.UIThread.Post(CheckGdprCompliance);
});
}
async void CheckGdprCompliance()
{
CurrentProgress++;
Message = "Checking GDPR compliance...";
AaruConsole.WriteLine("Checking GDPR compliance...");
if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL)
{
var settingsDialog = new SettingsDialog();
var settingsDialogViewModel = new SettingsViewModel(settingsDialog, true);
settingsDialog.DataContext = settingsDialogViewModel;
await settingsDialog.ShowDialog(_view);
// TODO: Update database
}
LoadStatistics();
}
void LoadStatistics()
{
CurrentProgress++;
Message = "Loading statistics...";
AaruConsole.WriteLine("Loading statistics...");
Task.Run(() =>
{
Statistics.LoadStats();
Dispatcher.UIThread.Post(RegisterEncodings);
});
}
void RegisterEncodings()
{
CurrentProgress++;
Message = "Registering encodings...";
AaruConsole.WriteLine("Registering encodings...");
Task.Run(() =>
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Dispatcher.UIThread.Post(SaveStatistics);
});
}
void SaveStatistics()
{
CurrentProgress++;
Message = "Saving statistics...";
AaruConsole.WriteLine("Saving statistics...");
Task.Run(() =>
{
Statistics.SaveStats();
Dispatcher.UIThread.Post(LoadMainWindow);
});
}
void LoadMainWindow()
{
CurrentProgress++;
Message = "Loading main window...";
AaruConsole.WriteLine("Loading main window...");
WorkFinished?.Invoke(this, EventArgs.Empty);
}
internal event EventHandler WorkFinished;
Dispatcher.UIThread.Post(CheckGdprCompliance);
});
}
async void CheckGdprCompliance()
{
CurrentProgress++;
Message = "Checking GDPR compliance...";
AaruConsole.WriteLine("Checking GDPR compliance...");
if(Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL)
{
var settingsDialog = new SettingsDialog();
var settingsDialogViewModel = new SettingsViewModel(settingsDialog, true);
settingsDialog.DataContext = settingsDialogViewModel;
await settingsDialog.ShowDialog(_view);
}
LoadStatistics();
}
void LoadStatistics()
{
CurrentProgress++;
Message = "Loading statistics...";
AaruConsole.WriteLine("Loading statistics...");
Task.Run(() =>
{
Statistics.LoadStats();
Dispatcher.UIThread.Post(RegisterEncodings);
});
}
void RegisterEncodings()
{
CurrentProgress++;
Message = "Registering encodings...";
AaruConsole.WriteLine("Registering encodings...");
Task.Run(() =>
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Dispatcher.UIThread.Post(SaveStatistics);
});
}
void SaveStatistics()
{
CurrentProgress++;
Message = "Saving statistics...";
AaruConsole.WriteLine("Saving statistics...");
Task.Run(() =>
{
Statistics.SaveStats();
Dispatcher.UIThread.Post(LoadMainWindow);
});
}
void LoadMainWindow()
{
CurrentProgress++;
Message = "Loading main window...";
AaruConsole.WriteLine("Loading main window...");
WorkFinished?.Invoke(this, EventArgs.Empty);
}
internal event EventHandler WorkFinished;
}

View File

@@ -36,72 +36,71 @@ using Aaru.Helpers;
using JetBrains.Annotations;
using ReactiveUI;
namespace Aaru.Gui.ViewModels.Windows
namespace Aaru.Gui.ViewModels.Windows;
public sealed class ViewSectorViewModel : ViewModelBase
{
public sealed class ViewSectorViewModel : ViewModelBase
const int HEX_COLUMNS = 32;
readonly IMediaImage _inputFormat;
bool _longSectorChecked;
bool _longSectorVisible;
string _printHexText;
double _sectorNumber;
string _title;
string _totalSectorsText;
public ViewSectorViewModel([NotNull] IMediaImage inputFormat)
{
const int HEX_COLUMNS = 32;
readonly IMediaImage _inputFormat;
bool _longSectorChecked;
bool _longSectorVisible;
string _printHexText;
double _sectorNumber;
string _title;
string _totalSectorsText;
_inputFormat = inputFormat;
public ViewSectorViewModel([NotNull] IMediaImage inputFormat)
ErrorNumber errno = inputFormat.ReadSectorLong(0, out _);
if(errno == ErrorNumber.NoError)
LongSectorChecked = true;
else
LongSectorVisible = false;
TotalSectorsText = $"of {inputFormat.Info.Sectors}";
SectorNumber = 0;
}
public string Title
{
get => _title;
set => this.RaiseAndSetIfChanged(ref _title, value);
}
public double SectorNumber
{
get => _sectorNumber;
set
{
_inputFormat = inputFormat;
this.RaiseAndSetIfChanged(ref _sectorNumber, value);
ErrorNumber errno = inputFormat.ReadSectorLong(0, out _);
byte[] sector;
ErrorNumber errno;
errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
: _inputFormat.ReadSector((ulong)SectorNumber, out sector);
if(errno == ErrorNumber.NoError)
LongSectorChecked = true;
else
LongSectorVisible = false;
TotalSectorsText = $"of {inputFormat.Info.Sectors}";
SectorNumber = 0;
}
public string Title
{
get => _title;
set => this.RaiseAndSetIfChanged(ref _title, value);
}
public double SectorNumber
{
get => _sectorNumber;
set
{
this.RaiseAndSetIfChanged(ref _sectorNumber, value);
byte[] sector;
ErrorNumber errno;
errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out sector)
: _inputFormat.ReadSector((ulong)SectorNumber, out sector);
if(errno == ErrorNumber.NoError)
PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS);
}
}
public string TotalSectorsText { get; }
public bool LongSectorChecked
{
get => _longSectorChecked;
set => this.RaiseAndSetIfChanged(ref _longSectorChecked, value);
}
public bool LongSectorVisible { get; }
public string PrintHexText
{
get => _printHexText;
set => this.RaiseAndSetIfChanged(ref _printHexText, value);
PrintHexText = PrintHex.ByteArrayToHexArrayString(sector, HEX_COLUMNS);
}
}
public string TotalSectorsText { get; }
public bool LongSectorChecked
{
get => _longSectorChecked;
set => this.RaiseAndSetIfChanged(ref _longSectorChecked, value);
}
public bool LongSectorVisible { get; }
public string PrintHexText
{
get => _printHexText;
set => this.RaiseAndSetIfChanged(ref _printHexText, value);
}
}