diff --git a/Aaru.Gui/Aaru.Gui.csproj b/Aaru.Gui/Aaru.Gui.csproj index 903e05def..0a746d70f 100644 --- a/Aaru.Gui/Aaru.Gui.csproj +++ b/Aaru.Gui/Aaru.Gui.csproj @@ -23,6 +23,7 @@ + @@ -32,7 +33,6 @@ - diff --git a/Aaru.Gui/App.xaml.cs b/Aaru.Gui/App.xaml.cs index 1f9424ba4..1c115e0ab 100644 --- a/Aaru.Gui/App.xaml.cs +++ b/Aaru.Gui/App.xaml.cs @@ -91,7 +91,7 @@ public sealed class App : Application }) return; - mainWindowViewModel.ExecuteAboutCommand(); + mainWindowViewModel.About(); } void OnQuitClicked(object sender, EventArgs args) @@ -105,7 +105,7 @@ public sealed class App : Application }) return; - mainWindowViewModel.ExecuteExitCommand(); + mainWindowViewModel.Exit(); } void OnPreferencesClicked(object sender, EventArgs args) @@ -119,6 +119,6 @@ public sealed class App : Application }) return; - mainWindowViewModel.ExecuteSettingsCommand(); + mainWindowViewModel.SettingsAsync(); } } \ No newline at end of file diff --git a/Aaru.Gui/Main.cs b/Aaru.Gui/Main.cs index fdc725e52..b5a4e6032 100644 --- a/Aaru.Gui/Main.cs +++ b/Aaru.Gui/Main.cs @@ -29,8 +29,6 @@ using System; using System.Text; using Avalonia; -using Avalonia.Dialogs; -using Avalonia.ReactiveUI; using Sentry; namespace Aaru.Gui; @@ -78,6 +76,5 @@ public static class Main } // Avalonia configuration, don't remove; also used by visual designer. - public static AppBuilder BuildAvaloniaApp() => - AppBuilder.Configure().UsePlatformDetect().UseReactiveUI().UseManagedSystemDialogs(); + public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure().UsePlatformDetect(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs index f51113346..5b35f3d29 100644 --- a/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/AboutViewModel.cs @@ -34,22 +34,24 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics; using System.Linq; -using System.Reactive; using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Gui.Models; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Dialogs; -public sealed class AboutViewModel : ViewModelBase +public sealed partial class AboutViewModel : ViewModelBase { readonly About _view; - string _versionText; + [ObservableProperty] + string _versionText; public AboutViewModel(About view) { @@ -59,13 +61,13 @@ public sealed class AboutViewModel : ViewModelBase (Attribute.GetCustomAttribute(typeof(App).Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute)?.InformationalVersion; - WebsiteCommand = ReactiveCommand.Create(ExecuteWebsiteCommand); - LicenseCommand = ReactiveCommand.Create(ExecuteLicenseCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + WebsiteCommand = new RelayCommand(OpenWebsite); + LicenseCommand = new AsyncRelayCommand(LicenseAsync); + CloseCommand = new RelayCommand(Close); Assemblies = []; - Task.Run(() => + _ = Task.Run(() => { foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName)) { @@ -125,18 +127,12 @@ public sealed class AboutViewModel : ViewModelBase [NotNull] public string Authors => UI.Text_Authors; - public ReactiveCommand WebsiteCommand { get; } - public ReactiveCommand LicenseCommand { get; } - public ReactiveCommand CloseCommand { get; } + public ICommand WebsiteCommand { get; } + public ICommand LicenseCommand { get; } + public ICommand CloseCommand { get; } public ObservableCollection Assemblies { get; } - public string VersionText - { - get => _versionText; - set => this.RaiseAndSetIfChanged(ref _versionText, value); - } - - static void ExecuteWebsiteCommand() + static void OpenWebsite() { var process = new Process { @@ -163,12 +159,13 @@ public sealed class AboutViewModel : ViewModelBase process.Start(); } - void ExecuteLicenseCommand() + Task LicenseAsync() { var dialog = new LicenseDialog(); dialog.DataContext = new LicenseViewModel(dialog); - dialog.ShowDialog(_view); + + return dialog.ShowDialog(_view); } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs index f41e89a76..868d42009 100644 --- a/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/ConsoleViewModel.cs @@ -34,17 +34,17 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Reactive; using System.Reflection; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes.Interop; using Aaru.Localization; using Aaru.Logging; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using Console = Aaru.Gui.Views.Dialogs.Console; using PlatformID = Aaru.CommonTypes.Interop.PlatformID; using Version = Aaru.CommonTypes.Interop.Version; @@ -59,15 +59,15 @@ public sealed class ConsoleViewModel : ViewModelBase public ConsoleViewModel(Console view) { _view = view; - SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand); - ClearCommand = ReactiveCommand.Create(ExecuteClearCommand); + SaveCommand = new AsyncRelayCommand(SaveAsync); + ClearCommand = new RelayCommand(Clear); } [NotNull] public string Title => UI.Title_Console; - public ReactiveCommand ClearCommand { get; } - public ReactiveCommand SaveCommand { get; } + public ICommand ClearCommand { get; } + public ICommand SaveCommand { get; } public ObservableCollection Entries => ConsoleHandler.Entries; [NotNull] @@ -90,11 +90,11 @@ public sealed class ConsoleViewModel : ViewModelBase set { ConsoleHandler.Debug = value; - this.RaiseAndSetIfChanged(ref _debugChecked, value); + SetProperty(ref _debugChecked, value); } } - async Task ExecuteSaveCommand() + async Task SaveAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -165,11 +165,11 @@ public sealed class ConsoleViewModel : ViewModelBase Icon.Error) .ShowWindowDialogAsync(_view); - AaruLogging.Exception(exception, UI - .Exception_0_trying_to_save_logfile_details_has_been_sent_to_console, + AaruLogging.Exception(exception, + UI.Exception_0_trying_to_save_logfile_details_has_been_sent_to_console, exception.Message); } } - static void ExecuteClearCommand() => ConsoleHandler.Entries.Clear(); + static void Clear() => ConsoleHandler.Entries.Clear(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs index df4402b34..736dab2ef 100644 --- a/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/EncodingsViewModel.cs @@ -32,14 +32,14 @@ using System.Collections.ObjectModel; using System.Linq; -using System.Reactive; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Gui.Models; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Dialogs; @@ -51,9 +51,9 @@ public sealed class EncodingsViewModel : ViewModelBase { _view = view; Encodings = []; - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + CloseCommand = new RelayCommand(Close); - Task.Run(() => + _ = Task.Run(() => { var encodings = Encoding.GetEncodings() .Select(info => new EncodingModel @@ -83,8 +83,8 @@ public sealed class EncodingsViewModel : ViewModelBase public string CodeLabel => UI.Title_Code_for_encoding; public string NameLabel => UI.Title_Name; - public ReactiveCommand CloseCommand { get; } + public ICommand CloseCommand { get; } public ObservableCollection Encodings { get; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs index 985ee81b3..ceac46e94 100644 --- a/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/LicenseViewModel.cs @@ -31,12 +31,12 @@ // ****************************************************************************/ using System.IO; -using System.Reactive; using System.Reflection; +using System.Windows.Input; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Dialogs; @@ -48,7 +48,7 @@ public sealed class LicenseViewModel : ViewModelBase public LicenseViewModel(LicenseDialog view) { _view = view; - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + CloseCommand = new RelayCommand(Close); // TODO: Localize using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Gui.LICENSE"); @@ -66,8 +66,8 @@ public sealed class LicenseViewModel : ViewModelBase [NotNull] public string CloseLabel => UI.ButtonLabel_Close; - public string LicenseText { get; } - public ReactiveCommand CloseCommand { get; } + public string LicenseText { get; } + public ICommand CloseCommand { get; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs index a73d10148..8908c1c9f 100644 --- a/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/PluginsViewModel.cs @@ -31,15 +31,15 @@ // ****************************************************************************/ using System.Collections.ObjectModel; -using System.Reactive; using System.Reflection; +using System.Windows.Input; using Aaru.CommonTypes; using Aaru.CommonTypes.Interfaces; using Aaru.Gui.Models; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Dialogs; @@ -58,7 +58,7 @@ public sealed class PluginsViewModel : ViewModelBase WritableImages = []; FloppyImages = []; WritableFloppyImages = []; - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + CloseCommand = new RelayCommand(Close); // TODO: Takes too much time foreach(IFilter filter in PluginRegister.Singleton.Filters.Values) @@ -201,7 +201,7 @@ public sealed class PluginsViewModel : ViewModelBase public string VersionLabel => UI.Title_Version; public string AuthorLabel => UI.Title_Author; - public ReactiveCommand CloseCommand { get; } + public ICommand CloseCommand { get; } public ObservableCollection Filters { get; } public ObservableCollection PartitionSchemes { get; } public ObservableCollection Filesystems { get; } @@ -211,5 +211,5 @@ public sealed class PluginsViewModel : ViewModelBase public ObservableCollection FloppyImages { get; } public ObservableCollection WritableFloppyImages { get; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs index c23820e95..cb5877b63 100644 --- a/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/SettingsViewModel.cs @@ -30,33 +30,49 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ -using System.Reactive; +using System.Windows.Input; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; using Aaru.Settings; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Dialogs; -public sealed class SettingsViewModel : ViewModelBase +public sealed partial 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; + [ObservableProperty] + bool _commandStatsChecked; + [ObservableProperty] + bool _deviceStatsChecked; + [ObservableProperty] + bool _filesystemStatsChecked; + [ObservableProperty] + bool _filterStatsChecked; + [ObservableProperty] + bool _gdprVisible; + [ObservableProperty] + bool _mediaImageStatsChecked; + [ObservableProperty] + bool _mediaScanStatsChecked; + [ObservableProperty] + bool _mediaStatsChecked; + [ObservableProperty] + bool _partitionStatsChecked; + [ObservableProperty] + bool _saveReportsGloballyChecked; + [ObservableProperty] + bool _saveStatsChecked; + [ObservableProperty] + bool _shareReportsChecked; + [ObservableProperty] + bool _shareStatsChecked; + [ObservableProperty] + int _tabControlSelectedIndex; + [ObservableProperty] + bool _verifyStatsChecked; public SettingsViewModel(SettingsDialog view, bool gdprChange) { @@ -82,8 +98,8 @@ public sealed class SettingsViewModel : ViewModelBase else SaveStatsChecked = false; - CancelCommand = ReactiveCommand.Create(ExecuteCancelCommand); - SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand); + CancelCommand = new RelayCommand(Cancel); + SaveCommand = new RelayCommand(Save); if(!_gdprVisible) _tabControlSelectedIndex = 1; } @@ -164,100 +180,10 @@ public sealed class SettingsViewModel : ViewModelBase [NotNull] public string VerifyStatsText => UI.Gather_statistics_about_media_image_verifications_Q; - public ReactiveCommand CancelCommand { get; } - public ReactiveCommand SaveCommand { get; } + public ICommand CancelCommand { get; } + public ICommand 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() + void Save() { Settings.Settings.Current.SaveReportsGlobally = SaveReportsGloballyChecked; Settings.Settings.Current.ShareReports = ShareReportsChecked; @@ -286,5 +212,5 @@ public sealed class SettingsViewModel : ViewModelBase _view.Close(); } - void ExecuteCancelCommand() => _view.Close(); + void Cancel() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs index 127420742..579ac4c7c 100644 --- a/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs +++ b/Aaru.Gui/ViewModels/Dialogs/StatisticsViewModel.cs @@ -32,14 +32,14 @@ using System.Collections.ObjectModel; using System.Linq; -using System.Reactive; +using System.Windows.Input; using Aaru.Database; using Aaru.Database.Models; using Aaru.Gui.Models; using Aaru.Gui.Views.Dialogs; using Aaru.Localization; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; using NameCountModel = Aaru.Gui.Models.NameCountModel; namespace Aaru.Gui.ViewModels.Dialogs; @@ -96,7 +96,7 @@ public sealed class StatisticsViewModel : ViewModelBase Filesystems = []; Devices = []; Medias = []; - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); + CloseCommand = new RelayCommand(Close); using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); if(ctx.Commands.Any()) @@ -481,235 +481,235 @@ public sealed class StatisticsViewModel : ViewModelBase public string FsInfoText { get => _fsinfoText; - set => this.RaiseAndSetIfChanged(ref _fsinfoText, value); + set => SetProperty(ref _fsinfoText, value); } public bool FsInfoVisible { get => _fsinfoVisible; - set => this.RaiseAndSetIfChanged(ref _fsinfoVisible, value); + set => SetProperty(ref _fsinfoVisible, value); } public string ChecksumText { get => _checksumText; - set => this.RaiseAndSetIfChanged(ref _checksumText, value); + set => SetProperty(ref _checksumText, value); } public bool ChecksumVisible { get => _checksumVisible; - set => this.RaiseAndSetIfChanged(ref _checksumVisible, value); + set => SetProperty(ref _checksumVisible, value); } public string CompareText { get => _compareText; - set => this.RaiseAndSetIfChanged(ref _compareText, value); + set => SetProperty(ref _compareText, value); } public bool CompareVisible { get => _compareVisible; - set => this.RaiseAndSetIfChanged(ref _compareVisible, value); + set => SetProperty(ref _compareVisible, value); } public string ConvertImageText { get => _convertImageText; - set => this.RaiseAndSetIfChanged(ref _convertImageText, value); + set => SetProperty(ref _convertImageText, value); } public bool ConvertImageVisible { get => _convertImageVisible; - set => this.RaiseAndSetIfChanged(ref _convertImageVisible, value); + set => SetProperty(ref _convertImageVisible, value); } public string CreateSidecarText { get => _createSidecarText; - set => this.RaiseAndSetIfChanged(ref _createSidecarText, value); + set => SetProperty(ref _createSidecarText, value); } public bool CreateSidecarVisible { get => _createSidecarVisible; - set => this.RaiseAndSetIfChanged(ref _createSidecarVisible, value); + set => SetProperty(ref _createSidecarVisible, value); } public string DecodeText { get => _decodeText; - set => this.RaiseAndSetIfChanged(ref _decodeText, value); + set => SetProperty(ref _decodeText, value); } public bool DecodeVisible { get => _decodeVisible; - set => this.RaiseAndSetIfChanged(ref _decodeVisible, value); + set => SetProperty(ref _decodeVisible, value); } public string DeviceInfoText { get => _deviceInfoText; - set => this.RaiseAndSetIfChanged(ref _deviceInfoText, value); + set => SetProperty(ref _deviceInfoText, value); } public bool DeviceInfoVisible { get => _deviceInfoVisible; - set => this.RaiseAndSetIfChanged(ref _deviceInfoVisible, value); + set => SetProperty(ref _deviceInfoVisible, value); } public string DeviceReportText { get => _deviceReportText; - set => this.RaiseAndSetIfChanged(ref _deviceReportText, value); + set => SetProperty(ref _deviceReportText, value); } public bool DeviceReportVisible { get => _deviceReportVisible; - set => this.RaiseAndSetIfChanged(ref _deviceReportVisible, value); + set => SetProperty(ref _deviceReportVisible, value); } public string DumpMediaText { get => _dumpMediaText; - set => this.RaiseAndSetIfChanged(ref _dumpMediaText, value); + set => SetProperty(ref _dumpMediaText, value); } public bool DumpMediaVisible { get => _dumpMediaVisible; - set => this.RaiseAndSetIfChanged(ref _dumpMediaVisible, value); + set => SetProperty(ref _dumpMediaVisible, value); } public string EntropyText { get => _entropyText; - set => this.RaiseAndSetIfChanged(ref _entropyText, value); + set => SetProperty(ref _entropyText, value); } public bool EntropyVisible { get => _entropyVisible; - set => this.RaiseAndSetIfChanged(ref _entropyVisible, value); + set => SetProperty(ref _entropyVisible, value); } public string FormatsCommandText { get => _formatsText; - set => this.RaiseAndSetIfChanged(ref _formatsText, value); + set => SetProperty(ref _formatsText, value); } public bool FormatsCommandVisible { get => _formatsCommandVisible; - set => this.RaiseAndSetIfChanged(ref _formatsCommandVisible, value); + set => SetProperty(ref _formatsCommandVisible, value); } public string ImageInfoText { get => _imageInfoText; - set => this.RaiseAndSetIfChanged(ref _imageInfoText, value); + set => SetProperty(ref _imageInfoText, value); } public bool ImageInfoVisible { get => _imageInfoVisible; - set => this.RaiseAndSetIfChanged(ref _imageInfoVisible, value); + set => SetProperty(ref _imageInfoVisible, value); } public string MediaInfoText { get => _mediaInfoText; - set => this.RaiseAndSetIfChanged(ref _mediaInfoText, value); + set => SetProperty(ref _mediaInfoText, value); } public bool MediaInfoVisible { get => _mediaInfoVisible; - set => this.RaiseAndSetIfChanged(ref _mediaInfoVisible, value); + set => SetProperty(ref _mediaInfoVisible, value); } public string MediaScanText { get => _mediaScanText; - set => this.RaiseAndSetIfChanged(ref _mediaScanText, value); + set => SetProperty(ref _mediaScanText, value); } public bool MediaScanVisible { get => _mediaScanVisible; - set => this.RaiseAndSetIfChanged(ref _mediaScanVisible, value); + set => SetProperty(ref _mediaScanVisible, value); } public string PrintHexText { get => _printHexText; - set => this.RaiseAndSetIfChanged(ref _printHexText, value); + set => SetProperty(ref _printHexText, value); } public bool PrintHexVisible { get => _printHexVisible; - set => this.RaiseAndSetIfChanged(ref _printHexVisible, value); + set => SetProperty(ref _printHexVisible, value); } public string VerifyText { get => _verifyText; - set => this.RaiseAndSetIfChanged(ref _verifyText, value); + set => SetProperty(ref _verifyText, value); } public bool VerifyVisible { get => _verifyVisible; - set => this.RaiseAndSetIfChanged(ref _verifyVisible, value); + set => SetProperty(ref _verifyVisible, value); } public bool CommandsVisible { get => _commandsVisible; - set => this.RaiseAndSetIfChanged(ref _commandsVisible, value); + set => SetProperty(ref _commandsVisible, value); } public bool FiltersVisible { get => _filtersVisible; - set => this.RaiseAndSetIfChanged(ref _filtersVisible, value); + set => SetProperty(ref _filtersVisible, value); } public bool PartitionsVisible { get => _partitionsVisible; - set => this.RaiseAndSetIfChanged(ref _partitionsVisible, value); + set => SetProperty(ref _partitionsVisible, value); } public bool FormatsVisible { get => _formatsVisible; - set => this.RaiseAndSetIfChanged(ref _formatsVisible, value); + set => SetProperty(ref _formatsVisible, value); } public bool FilesystemsVisible { get => _filesystemsVisible; - set => this.RaiseAndSetIfChanged(ref _filesystemsVisible, value); + set => SetProperty(ref _filesystemsVisible, value); } public bool DevicesVisible { get => _devicesVisible; - set => this.RaiseAndSetIfChanged(ref _devicesVisible, value); + set => SetProperty(ref _devicesVisible, value); } public bool MediasVisible { get => _mediasVisible; - set => this.RaiseAndSetIfChanged(ref _mediasVisible, value); + set => SetProperty(ref _mediasVisible, value); } [NotNull] @@ -772,7 +772,7 @@ public sealed class StatisticsViewModel : ViewModelBase [NotNull] public string CloseLabel => UI.ButtonLabel_Close; - public ReactiveCommand CloseCommand { get; } + public ICommand CloseCommand { get; } public ObservableCollection Filters { get; } public ObservableCollection Formats { get; } public ObservableCollection Partitions { get; } @@ -780,5 +780,5 @@ public sealed class StatisticsViewModel : ViewModelBase public ObservableCollection Devices { get; } public ObservableCollection Medias { get; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs index 6086c02db..3027c8634 100644 --- a/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/DeviceInfoViewModel.cs @@ -33,8 +33,8 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.SCSI.SSC; using Aaru.Devices; using Aaru.Gui.ViewModels.Tabs; @@ -42,110 +42,200 @@ using Aaru.Gui.Views.Tabs; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Humanizer; using Humanizer.Localisation; -using ReactiveUI; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; namespace Aaru.Gui.ViewModels.Panels; -public sealed class DeviceInfoViewModel : ViewModelBase +public sealed partial class DeviceInfoViewModel : ViewModelBase { readonly DeviceInfo _devInfo; readonly Window _view; - AtaInfo _ataInfo; - string _blockLimits; - string _blockSizeGranularity; - string _cid; - string _csd; - string _densities; - string _deviceType; - string _extendedCsd; - string _firewireGuid; - string _firewireManufacturer; - string _firewireModel; - string _firewireModelId; - string _firewireVendorId; - bool _firewireVisible; - bool _kreon; - bool _kreonChallengeResponse; - bool _kreonChallengeResponse360; - bool _kreonDecryptSs; - bool _kreonDecryptSs360; - bool _kreonErrorSkipping; - bool _kreonLock; - bool _kreonWxripperUnlock; - bool _kreonWxripperUnlock360; - bool _kreonXtremeUnlock; - bool _kreonXtremeUnlock360; - string _manufacturer; - string _maxBlockSize; - string _mediumDensity; - string _mediumTypes; - string _minBlockSize; - string _model; - string _ocr; - PcmciaInfo _pcmciaInfo; - bool _plextorBitSetting; - bool _plextorBitSettingDl; - string _plextorCdReadTime; - string _plextorCdWriteTime; - string _plextorDiscs; - string _plextorDvd; - bool _plextorDvdPlusWriteTest; - string _plextorDvdReadTime; - bool _plextorDvdTimesVisible; - string _plextorDvdWriteTime; - bool _plextorEepromVisible; - bool _plextorGigaRec; - bool _plextorHidesRecordables; - bool _plextorHidesSessions; - bool _plextorHiding; - bool _plextorPoweRec; - bool _plextorPoweRecEnabled; - string _plextorPoweRecLast; - bool _plextorPoweRecLastVisible; - string _plextorPoweRecMax; - bool _plextorPoweRecMaxVisible; - string _plextorPoweRecRecommended; - bool _plextorPoweRecRecommendedVisible; - string _plextorPoweRecSelected; - bool _plextorPoweRecSelectedVisible; - bool _plextorSecuRec; - bool _plextorSilentMode; - string _plextorSilentModeAccessTime; - string _plextorSilentModeCdReadSpeedLimit; - string _plextorSilentModeCdWriteSpeedLimit; - string _plextorSilentModeDvdReadSpeedLimit; - bool _plextorSilentModeDvdReadSpeedLimitVisible; - bool _plextorSilentModeEnabled; - bool _plextorSpeedEnabled; - bool _plextorSpeedRead; - bool _plextorVariRec; - bool _plextorVariRecDvd; - bool _plextorVisible; - bool _removable; - string _revision; - bool _saveUsbDescriptorsEnabled; - string _scr; - ScsiInfo _scsiInfo; - string _scsiType; - string _sdMm; - SdMmcInfo _sdMmcInfo; - string _secureDigital; - string _serial; - bool _ssc; - string _usbConnected; - string _usbManufacturer; - string _usbProduct; - string _usbProductId; - string _usbSerial; - string _usbVendorId; - bool _usbVisible; + [ObservableProperty] + AtaInfo _ataInfo; + [ObservableProperty] + string _blockLimits; + [ObservableProperty] + string _blockSizeGranularity; + [ObservableProperty] + string _cid; + [ObservableProperty] + string _csd; + [ObservableProperty] + string _densities; + [ObservableProperty] + string _deviceType; + [ObservableProperty] + string _extendedCsd; + [ObservableProperty] + string _firewireGuid; + [ObservableProperty] + string _firewireManufacturer; + [ObservableProperty] + string _firewireModel; + [ObservableProperty] + string _firewireModelId; + [ObservableProperty] + string _firewireVendorId; + [ObservableProperty] + bool _firewireVisible; + [ObservableProperty] + bool _kreon; + [ObservableProperty] + bool _kreonChallengeResponse; + [ObservableProperty] + bool _kreonChallengeResponse360; + [ObservableProperty] + bool _kreonDecryptSs; + [ObservableProperty] + bool _kreonDecryptSs360; + [ObservableProperty] + bool _kreonErrorSkipping; + [ObservableProperty] + bool _kreonLock; + [ObservableProperty] + bool _kreonWxripperUnlock; + [ObservableProperty] + bool _kreonWxripperUnlock360; + [ObservableProperty] + bool _kreonXtremeUnlock; + [ObservableProperty] + bool _kreonXtremeUnlock360; + [ObservableProperty] + string _manufacturer; + [ObservableProperty] + string _maxBlockSize; + [ObservableProperty] + string _mediumDensity; + [ObservableProperty] + string _mediumTypes; + [ObservableProperty] + string _minBlockSize; + [ObservableProperty] + string _model; + [ObservableProperty] + string _ocr; + [ObservableProperty] + PcmciaInfo _pcmciaInfo; + [ObservableProperty] + bool _plextorBitSetting; + [ObservableProperty] + bool _plextorBitSettingDl; + [ObservableProperty] + string _plextorCdReadTime; + [ObservableProperty] + string _plextorCdWriteTime; + [ObservableProperty] + string _plextorDiscs; + [ObservableProperty] + string _plextorDvd; + [ObservableProperty] + bool _plextorDvdPlusWriteTest; + [ObservableProperty] + string _plextorDvdReadTime; + [ObservableProperty] + bool _plextorDvdTimesVisible; + [ObservableProperty] + string _plextorDvdWriteTime; + [ObservableProperty] + bool _plextorEepromVisible; + [ObservableProperty] + bool _plextorGigaRec; + [ObservableProperty] + bool _plextorHidesRecordables; + [ObservableProperty] + bool _plextorHidesSessions; + [ObservableProperty] + bool _plextorHiding; + [ObservableProperty] + bool _plextorPoweRec; + [ObservableProperty] + bool _plextorPoweRecEnabled; + [ObservableProperty] + string _plextorPoweRecLast; + [ObservableProperty] + bool _plextorPoweRecLastVisible; + [ObservableProperty] + string _plextorPoweRecMax; + [ObservableProperty] + bool _plextorPoweRecMaxVisible; + [ObservableProperty] + string _plextorPoweRecRecommended; + [ObservableProperty] + bool _plextorPoweRecRecommendedVisible; + [ObservableProperty] + string _plextorPoweRecSelected; + [ObservableProperty] + bool _plextorPoweRecSelectedVisible; + [ObservableProperty] + bool _plextorSecuRec; + [ObservableProperty] + bool _plextorSilentMode; + [ObservableProperty] + string _plextorSilentModeAccessTime; + [ObservableProperty] + string _plextorSilentModeCdReadSpeedLimit; + [ObservableProperty] + string _plextorSilentModeCdWriteSpeedLimit; + [ObservableProperty] + string _plextorSilentModeDvdReadSpeedLimit; + [ObservableProperty] + bool _plextorSilentModeDvdReadSpeedLimitVisible; + [ObservableProperty] + bool _plextorSilentModeEnabled; + [ObservableProperty] + bool _plextorSpeedEnabled; + [ObservableProperty] + bool _plextorSpeedRead; + [ObservableProperty] + bool _plextorVariRec; + [ObservableProperty] + bool _plextorVariRecDvd; + [ObservableProperty] + bool _plextorVisible; + [ObservableProperty] + bool _removable; + [ObservableProperty] + string _revision; + [ObservableProperty] + bool _saveUsbDescriptorsEnabled; + [ObservableProperty] + string _scr; + [ObservableProperty] + ScsiInfo _scsiInfo; + [ObservableProperty] + string _scsiType; + [ObservableProperty] + string _sdMm; + [ObservableProperty] + SdMmcInfo _sdMmcInfo; + [ObservableProperty] + string _secureDigital; + [ObservableProperty] + string _serial; + [ObservableProperty] + bool _ssc; + [ObservableProperty] + string _usbConnected; + [ObservableProperty] + string _usbManufacturer; + [ObservableProperty] + string _usbProduct; + [ObservableProperty] + string _usbProductId; + [ObservableProperty] + string _usbSerial; + [ObservableProperty] + string _usbVendorId; + [ObservableProperty] + bool _usbVisible; public DeviceInfoViewModel(DeviceInfo devInfo, Window view) { - SaveUsbDescriptorsCommand = ReactiveCommand.Create(ExecuteSaveUsbDescriptorsCommand); + SaveUsbDescriptorsCommand = new AsyncRelayCommand(SaveUsbDescriptorsAsync); _view = view; _devInfo = devInfo; @@ -412,541 +502,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase }; } - public ReactiveCommand SaveUsbDescriptorsCommand { get; } - - public string DeviceType - { - get => _deviceType; - set => this.RaiseAndSetIfChanged(ref _deviceType, value); - } - - public string Manufacturer - { - get => _manufacturer; - set => this.RaiseAndSetIfChanged(ref _manufacturer, value); - } - - public string Model - { - get => _model; - set => this.RaiseAndSetIfChanged(ref _model, value); - } - - public string Revision - { - get => _revision; - set => this.RaiseAndSetIfChanged(ref _revision, value); - } - - public string Serial - { - get => _serial; - set => this.RaiseAndSetIfChanged(ref _serial, value); - } - - public string ScsiType - { - get => _scsiType; - set => this.RaiseAndSetIfChanged(ref _scsiType, value); - } - - public bool Removable - { - get => _removable; - set => this.RaiseAndSetIfChanged(ref _removable, value); - } - - public string UsbConnected - { - get => _usbConnected; - set => this.RaiseAndSetIfChanged(ref _usbConnected, value); - } - - public bool UsbVisible - { - get => _usbVisible; - set => this.RaiseAndSetIfChanged(ref _usbVisible, value); - } - - public string UsbVendorId - { - get => _usbVendorId; - set => this.RaiseAndSetIfChanged(ref _usbVendorId, value); - } - - public string UsbProductId - { - get => _usbProductId; - set => this.RaiseAndSetIfChanged(ref _usbProductId, value); - } - - public string UsbManufacturer - { - get => _usbManufacturer; - set => this.RaiseAndSetIfChanged(ref _usbManufacturer, value); - } - - public string UsbProduct - { - get => _usbProduct; - set => this.RaiseAndSetIfChanged(ref _usbProduct, value); - } - - public string UsbSerial - { - get => _usbSerial; - set => this.RaiseAndSetIfChanged(ref _usbSerial, value); - } - - public bool SaveUsbDescriptorsEnabled - { - get => _saveUsbDescriptorsEnabled; - set => this.RaiseAndSetIfChanged(ref _saveUsbDescriptorsEnabled, value); - } - - public bool FirewireVisible - { - get => _firewireVisible; - set => this.RaiseAndSetIfChanged(ref _firewireVisible, value); - } - - public string FirewireVendorId - { - get => _firewireVendorId; - set => this.RaiseAndSetIfChanged(ref _firewireVendorId, value); - } - - public string FirewireModelId - { - get => _firewireModelId; - set => this.RaiseAndSetIfChanged(ref _firewireModelId, value); - } - - public string FirewireManufacturer - { - get => _firewireManufacturer; - set => this.RaiseAndSetIfChanged(ref _firewireManufacturer, value); - } - - public string FirewireModel - { - get => _firewireModel; - set => this.RaiseAndSetIfChanged(ref _firewireModel, value); - } - - public string FirewireGuid - { - get => _firewireGuid; - set => this.RaiseAndSetIfChanged(ref _firewireGuid, value); - } - - public bool PlextorVisible - { - get => _plextorVisible; - set => this.RaiseAndSetIfChanged(ref _plextorVisible, value); - } - - public bool PlextorEepromVisible - { - get => _plextorEepromVisible; - set => this.RaiseAndSetIfChanged(ref _plextorEepromVisible, value); - } - - public string PlextorDiscs - { - get => _plextorDiscs; - set => this.RaiseAndSetIfChanged(ref _plextorDiscs, value); - } - - public string PlextorCdReadTime - { - get => _plextorCdReadTime; - set => this.RaiseAndSetIfChanged(ref _plextorCdReadTime, value); - } - - public string PlextorCdWriteTime - { - get => _plextorCdWriteTime; - set => this.RaiseAndSetIfChanged(ref _plextorCdWriteTime, value); - } - - public bool PlextorDvdTimesVisible - { - get => _plextorDvdTimesVisible; - set => this.RaiseAndSetIfChanged(ref _plextorDvdTimesVisible, value); - } - - public string PlextorDvdReadTime - { - get => _plextorDvdReadTime; - set => this.RaiseAndSetIfChanged(ref _plextorDvdReadTime, value); - } - - public string PlextorDvdWriteTime - { - get => _plextorDvdWriteTime; - set => this.RaiseAndSetIfChanged(ref _plextorDvdWriteTime, value); - } - - public bool PlextorPoweRec - { - get => _plextorPoweRec; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRec, value); - } - - public bool PlextorPoweRecEnabled - { - get => _plextorPoweRecEnabled; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecEnabled, value); - } - - public bool PlextorPoweRecRecommendedVisible - { - get => _plextorPoweRecRecommendedVisible; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecRecommendedVisible, value); - } - - public string PlextorPoweRecRecommended - { - get => _plextorPoweRecRecommended; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecRecommended, value); - } - - public bool PlextorPoweRecSelectedVisible - { - get => _plextorPoweRecSelectedVisible; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecSelectedVisible, value); - } - - public string PlextorPoweRecSelected - { - get => _plextorPoweRecSelected; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecSelected, value); - } - - public bool PlextorPoweRecMaxVisible - { - get => _plextorPoweRecMaxVisible; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecMaxVisible, value); - } - - public string PlextorPoweRecMax - { - get => _plextorPoweRecMax; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecMax, value); - } - - public bool PlextorPoweRecLastVisible - { - get => _plextorPoweRecLastVisible; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecLastVisible, value); - } - - public string PlextorPoweRecLast - { - get => _plextorPoweRecLast; - set => this.RaiseAndSetIfChanged(ref _plextorPoweRecLast, value); - } - - public bool PlextorSilentMode - { - get => _plextorSilentMode; - set => this.RaiseAndSetIfChanged(ref _plextorSilentMode, value); - } - - public bool PlextorSilentModeEnabled - { - get => _plextorSilentModeEnabled; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeEnabled, value); - } - - public string PlextorSilentModeAccessTime - { - get => _plextorSilentModeAccessTime; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeAccessTime, value); - } - - public string PlextorSilentModeCdReadSpeedLimit - { - get => _plextorSilentModeCdReadSpeedLimit; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeCdReadSpeedLimit, value); - } - - public string PlextorSilentModeCdWriteSpeedLimit - { - get => _plextorSilentModeCdWriteSpeedLimit; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeCdWriteSpeedLimit, value); - } - - public bool PlextorSilentModeDvdReadSpeedLimitVisible - { - get => _plextorSilentModeDvdReadSpeedLimitVisible; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeDvdReadSpeedLimitVisible, value); - } - - public string PlextorSilentModeDvdReadSpeedLimit - { - get => _plextorSilentModeDvdReadSpeedLimit; - set => this.RaiseAndSetIfChanged(ref _plextorSilentModeDvdReadSpeedLimit, value); - } - - public bool PlextorGigaRec - { - get => _plextorGigaRec; - set => this.RaiseAndSetIfChanged(ref _plextorGigaRec, value); - } - - public bool PlextorSecuRec - { - get => _plextorSecuRec; - set => this.RaiseAndSetIfChanged(ref _plextorSecuRec, value); - } - - public bool PlextorSpeedRead - { - get => _plextorSpeedRead; - set => this.RaiseAndSetIfChanged(ref _plextorSpeedRead, value); - } - - public bool PlextorSpeedEnabled - { - get => _plextorSpeedEnabled; - set => this.RaiseAndSetIfChanged(ref _plextorSpeedEnabled, value); - } - - public bool PlextorHiding - { - get => _plextorHiding; - set => this.RaiseAndSetIfChanged(ref _plextorHiding, value); - } - - public bool PlextorHidesRecordables - { - get => _plextorHidesRecordables; - set => this.RaiseAndSetIfChanged(ref _plextorHidesRecordables, value); - } - - public bool PlextorHidesSessions - { - get => _plextorHidesSessions; - set => this.RaiseAndSetIfChanged(ref _plextorHidesSessions, value); - } - - public bool PlextorVariRec - { - get => _plextorVariRec; - set => this.RaiseAndSetIfChanged(ref _plextorVariRec, value); - } - - public string PlextorDvd - { - get => _plextorDvd; - set => this.RaiseAndSetIfChanged(ref _plextorDvd, value); - } - - public bool PlextorVariRecDvd - { - get => _plextorVariRecDvd; - set => this.RaiseAndSetIfChanged(ref _plextorVariRecDvd, value); - } - - public bool PlextorBitSetting - { - get => _plextorBitSetting; - set => this.RaiseAndSetIfChanged(ref _plextorBitSetting, value); - } - - public bool PlextorBitSettingDl - { - get => _plextorBitSettingDl; - set => this.RaiseAndSetIfChanged(ref _plextorBitSettingDl, value); - } - - public bool PlextorDvdPlusWriteTest - { - get => _plextorDvdPlusWriteTest; - set => this.RaiseAndSetIfChanged(ref _plextorDvdPlusWriteTest, value); - } - - public bool Kreon - { - get => _kreon; - set => this.RaiseAndSetIfChanged(ref _kreon, value); - } - - public bool KreonChallengeResponse - { - get => _kreonChallengeResponse; - set => this.RaiseAndSetIfChanged(ref _kreonChallengeResponse, value); - } - - public bool KreonDecryptSs - { - get => _kreonDecryptSs; - set => this.RaiseAndSetIfChanged(ref _kreonDecryptSs, value); - } - - public bool KreonXtremeUnlock - { - get => _kreonXtremeUnlock; - set => this.RaiseAndSetIfChanged(ref _kreonXtremeUnlock, value); - } - - public bool KreonWxripperUnlock - { - get => _kreonWxripperUnlock; - set => this.RaiseAndSetIfChanged(ref _kreonWxripperUnlock, value); - } - - public bool KreonChallengeResponse360 - { - get => _kreonChallengeResponse360; - set => this.RaiseAndSetIfChanged(ref _kreonChallengeResponse360, value); - } - - public bool KreonDecryptSs360 - { - get => _kreonDecryptSs360; - set => this.RaiseAndSetIfChanged(ref _kreonDecryptSs360, value); - } - - public bool KreonXtremeUnlock360 - { - get => _kreonXtremeUnlock360; - set => this.RaiseAndSetIfChanged(ref _kreonXtremeUnlock360, value); - } - - public bool KreonWxripperUnlock360 - { - get => _kreonWxripperUnlock360; - set => this.RaiseAndSetIfChanged(ref _kreonWxripperUnlock360, value); - } - - public bool KreonLock - { - get => _kreonLock; - set => this.RaiseAndSetIfChanged(ref _kreonLock, value); - } - - public bool KreonErrorSkipping - { - get => _kreonErrorSkipping; - set => this.RaiseAndSetIfChanged(ref _kreonErrorSkipping, value); - } - - public bool Ssc - { - get => _ssc; - set => this.RaiseAndSetIfChanged(ref _ssc, value); - } - - public string BlockLimits - { - get => _blockLimits; - set => this.RaiseAndSetIfChanged(ref _blockLimits, value); - } - - public string MinBlockSize - { - get => _minBlockSize; - set => this.RaiseAndSetIfChanged(ref _minBlockSize, value); - } - - public string MaxBlockSize - { - get => _maxBlockSize; - set => this.RaiseAndSetIfChanged(ref _maxBlockSize, value); - } - - public string BlockSizeGranularity - { - get => _blockSizeGranularity; - set => this.RaiseAndSetIfChanged(ref _blockSizeGranularity, value); - } - - public string Densities - { - get => _densities; - set => this.RaiseAndSetIfChanged(ref _densities, value); - } - - public string MediumTypes - { - get => _mediumTypes; - set => this.RaiseAndSetIfChanged(ref _mediumTypes, value); - } - - public string MediumDensity - { - get => _mediumDensity; - set => this.RaiseAndSetIfChanged(ref _mediumDensity, value); - } - - public string SecureDigital - { - get => _secureDigital; - set => this.RaiseAndSetIfChanged(ref _secureDigital, value); - } - - public string SdMm - { - get => _sdMm; - set => this.RaiseAndSetIfChanged(ref _sdMm, value); - } - - public string Cid - { - get => _cid; - set => this.RaiseAndSetIfChanged(ref _cid, value); - } - - public string Csd - { - get => _csd; - set => this.RaiseAndSetIfChanged(ref _csd, value); - } - - public string Ocr - { - get => _ocr; - set => this.RaiseAndSetIfChanged(ref _ocr, value); - } - - public string ExtendedCsd - { - get => _extendedCsd; - set => this.RaiseAndSetIfChanged(ref _extendedCsd, value); - } - - public string Scr - { - get => _scr; - set => this.RaiseAndSetIfChanged(ref _scr, value); - } - - public PcmciaInfo PcmciaInfo - { - get => _pcmciaInfo; - set => this.RaiseAndSetIfChanged(ref _pcmciaInfo, value); - } - - public ScsiInfo ScsiInfo - { - get => _scsiInfo; - set => this.RaiseAndSetIfChanged(ref _scsiInfo, value); - } - - public AtaInfo AtaInfo - { - get => _ataInfo; - set => this.RaiseAndSetIfChanged(ref _ataInfo, value); - } - - public SdMmcInfo SdMmcInfo - { - get => _sdMmcInfo; - set => this.RaiseAndSetIfChanged(ref _sdMmcInfo, value); - } + public ICommand SaveUsbDescriptorsCommand { get; } public string DeviceInformationLabel => UI.Title_Device_information; public string GeneralLabel => UI.Title_General; @@ -1018,7 +574,7 @@ public sealed class DeviceInfoViewModel : ViewModelBase public string SCSILabel => UI.Title_SCSI; public string Sd_MMCLabel => UI.Title_SD_MMC; - async Task ExecuteSaveUsbDescriptorsCommand() + async Task SaveUsbDescriptorsAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs index 7dc525486..779a8b09f 100644 --- a/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/ImageInfoViewModel.cs @@ -33,8 +33,8 @@ using System; using System.Collections.ObjectModel; using System.Linq; -using System.Reactive; using System.Text; +using System.Windows.Input; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -53,9 +53,9 @@ using Aaru.Localization; using Avalonia.Controls; using Avalonia.Media.Imaging; using Avalonia.Platform; +using CommunityToolkit.Mvvm.Input; using Humanizer; using Humanizer.Bytes; -using ReactiveUI; using Sentry; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; using Session = Aaru.CommonTypes.Structs.Session; @@ -87,13 +87,13 @@ public sealed class ImageInfoViewModel : ViewModelBase Sessions = []; Tracks = []; DumpHardwareList = []; - EntropyCommand = ReactiveCommand.Create(ExecuteEntropyCommand); - VerifyCommand = ReactiveCommand.Create(ExecuteVerifyCommand); - ChecksumCommand = ReactiveCommand.Create(ExecuteChecksumCommand); - ConvertCommand = ReactiveCommand.Create(ExecuteConvertCommand); - CreateSidecarCommand = ReactiveCommand.Create(ExecuteCreateSidecarCommand); - ViewSectorsCommand = ReactiveCommand.Create(ExecuteViewSectorsCommand); - DecodeMediaTagCommand = ReactiveCommand.Create(ExecuteDecodeMediaTagCommand); + EntropyCommand = new RelayCommand(Entropy); + VerifyCommand = new RelayCommand(Verify); + ChecksumCommand = new RelayCommand(Checksum); + ConvertCommand = new RelayCommand(Convert); + CreateSidecarCommand = new RelayCommand(CreateSidecar); + ViewSectorsCommand = new RelayCommand(ViewSectors); + DecodeMediaTagCommand = new RelayCommand(DecodeMediaTag); var genericHddIcon = new Bitmap(AssetLoader.Open(new Uri("avares://Aaru.Gui/Assets/Icons/oxygen/32x32/drive-harddisk.png"))); @@ -780,13 +780,13 @@ public sealed class ImageInfoViewModel : ViewModelBase public ObservableCollection Sessions { get; } public ObservableCollection Tracks { get; } public ObservableCollection DumpHardwareList { get; } - public ReactiveCommand EntropyCommand { get; } - public ReactiveCommand VerifyCommand { get; } - public ReactiveCommand ChecksumCommand { get; } - public ReactiveCommand ConvertCommand { get; } - public ReactiveCommand CreateSidecarCommand { get; } - public ReactiveCommand ViewSectorsCommand { get; } - public ReactiveCommand DecodeMediaTagCommand { get; } + public ICommand EntropyCommand { get; } + public ICommand VerifyCommand { get; } + public ICommand ChecksumCommand { get; } + public ICommand ConvertCommand { get; } + public ICommand CreateSidecarCommand { get; } + public ICommand ViewSectorsCommand { get; } + public ICommand DecodeMediaTagCommand { get; } public bool DriveInformationVisible => DriveManufacturerText != null || DriveModelText != null || @@ -848,7 +848,7 @@ public sealed class ImageInfoViewModel : ViewModelBase public string ViewSectorsLabel => UI.ButtonLabel_View_sectors; public string DecodeMediaTagLabel => UI.ButtonLabel_Decode_media_tags; - void ExecuteEntropyCommand() + void Entropy() { if(_imageEntropy != null) { @@ -865,7 +865,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _imageEntropy.Show(); } - void ExecuteVerifyCommand() + void Verify() { if(_imageVerify != null) { @@ -882,7 +882,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _imageVerify.Show(); } - void ExecuteChecksumCommand() + void Checksum() { if(_imageChecksum != null) { @@ -899,7 +899,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _imageChecksum.Show(); } - void ExecuteConvertCommand() + void Convert() { if(_imageConvert != null) { @@ -916,7 +916,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _imageConvert.Show(); } - void ExecuteCreateSidecarCommand() + void CreateSidecar() { if(_imageSidecar != null) { @@ -936,7 +936,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _imageSidecar.Show(); } - void ExecuteViewSectorsCommand() + void ViewSectors() { if(_viewSector != null) { @@ -955,7 +955,7 @@ public sealed class ImageInfoViewModel : ViewModelBase _viewSector.Show(); } - void ExecuteDecodeMediaTagCommand() + void DecodeMediaTag() { if(_decodeMediaTags != null) { diff --git a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs index 381a03c0b..71c8d5de7 100644 --- a/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/MediaInfoViewModel.cs @@ -33,9 +33,9 @@ using System; using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Text; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Gui.ViewModels.Tabs; using Aaru.Gui.ViewModels.Windows; using Aaru.Gui.Views.Tabs; @@ -45,55 +45,78 @@ using Avalonia.Controls; using Avalonia.Media.Imaging; using Avalonia.Platform; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Humanizer.Bytes; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using ScsiInfo = Aaru.Core.Media.Info.ScsiInfo; namespace Aaru.Gui.ViewModels.Panels; -public sealed class MediaInfoViewModel : ViewModelBase +public sealed partial 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; + [ObservableProperty] + BlurayInfo _blurayInfo; + [ObservableProperty] + CompactDiscInfo _compactDiscInfo; + [ObservableProperty] + string _densitySupport; + [ObservableProperty] + DvdInfo _dvdInfo; + [ObservableProperty] + DvdWritableInfo _dvdWritableInfo; + [ObservableProperty] + string _generalVisible; + [ObservableProperty] + Bitmap _mediaLogo; + [ObservableProperty] + string _mediaSerial; + [ObservableProperty] + string _mediaSize; + [ObservableProperty] + string _mediaType; + [ObservableProperty] + string _mediumSupport; + [ObservableProperty] + bool _mmcVisible; + [ObservableProperty] + bool _saveDensitySupportVisible; + [ObservableProperty] + bool _saveGetConfigurationVisible; + [ObservableProperty] + bool _saveMediumSupportVisible; + [ObservableProperty] + bool _saveReadCapacity16Visible; + [ObservableProperty] + bool _saveReadCapacityVisible; + [ObservableProperty] + bool _saveReadMediaSerialVisible; + [ObservableProperty] + bool _saveRecognizedFormatLayersVisible; + [ObservableProperty] + bool _saveWriteProtectionStatusVisible; + [ObservableProperty] + bool _sscVisible; + [ObservableProperty] + XboxInfo _xboxInfo; public MediaInfoViewModel(ScsiInfo scsiInfo, string devicePath, Window view) { _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); + SaveReadMediaSerialCommand = new AsyncRelayCommand(SaveReadMediaSerial); + SaveReadCapacityCommand = new AsyncRelayCommand(SaveReadCapacity); + SaveReadCapacity16Command = new AsyncRelayCommand(SaveReadCapacity16); + SaveGetConfigurationCommand = new AsyncRelayCommand(SaveGetConfiguration); + SaveRecognizedFormatLayersCommand = new AsyncRelayCommand(SaveRecognizedFormatLayers); + SaveWriteProtectionStatusCommand = new AsyncRelayCommand(SaveWriteProtectionStatus); + SaveDensitySupportCommand = new AsyncRelayCommand(SaveDensitySupport); + SaveMediumSupportCommand = new AsyncRelayCommand(SaveMediumSupport); + DumpCommand = new AsyncRelayCommand(DumpAsync); + ScanCommand = new AsyncRelayCommand(ScanAsync); _devicePath = devicePath; _scsiInfo = scsiInfo; @@ -115,7 +138,7 @@ public sealed class MediaInfoViewModel : ViewModelBase { var sbSerial = new StringBuilder(); - for(var i = 4; i < scsiInfo.MediaSerialNumber.Length; i++) + for(int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++) sbSerial.Append($"{scsiInfo.MediaSerialNumber[i]:X2}"); MediaSerial = sbSerial.ToString(); @@ -221,148 +244,16 @@ public sealed class MediaInfoViewModel : ViewModelBase }; } - public ReactiveCommand SaveReadMediaSerialCommand { get; } - public ReactiveCommand SaveReadCapacityCommand { get; } - public ReactiveCommand SaveReadCapacity16Command { get; } - public ReactiveCommand SaveGetConfigurationCommand { get; } - public ReactiveCommand SaveRecognizedFormatLayersCommand { get; } - public ReactiveCommand SaveWriteProtectionStatusCommand { get; } - public ReactiveCommand SaveDensitySupportCommand { get; } - public ReactiveCommand SaveMediumSupportCommand { get; } - public ReactiveCommand DumpCommand { get; } - public ReactiveCommand 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); - } + public ICommand SaveReadMediaSerialCommand { get; } + public ICommand SaveReadCapacityCommand { get; } + public ICommand SaveReadCapacity16Command { get; } + public ICommand SaveGetConfigurationCommand { get; } + public ICommand SaveRecognizedFormatLayersCommand { get; } + public ICommand SaveWriteProtectionStatusCommand { get; } + public ICommand SaveDensitySupportCommand { get; } + public ICommand SaveMediumSupportCommand { get; } + public ICommand DumpCommand { get; } + public ICommand ScanCommand { get; } public string MediaInformationLabel => UI.Title_Media_information; public string GeneralLabel => UI.Title_General; @@ -388,7 +279,7 @@ public sealed class MediaInfoViewModel : ViewModelBase public string DumpLabel => UI.ButtonLabel_Dump_media_to_image; public string ScanLabel => UI.ButtonLabel_Scan_media_surface; - async Task SaveElement(byte[] data) + async Task SaveElementAsync(byte[] data) { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -406,23 +297,23 @@ public sealed class MediaInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveReadMediaSerialCommand() => await SaveElement(_scsiInfo.MediaSerialNumber); + Task SaveReadMediaSerial() => SaveElementAsync(_scsiInfo.MediaSerialNumber); - async Task ExecuteSaveReadCapacityCommand() => await SaveElement(_scsiInfo.ReadCapacity); + Task SaveReadCapacity() => SaveElementAsync(_scsiInfo.ReadCapacity); - async Task ExecuteSaveReadCapacity16Command() => await SaveElement(_scsiInfo.ReadCapacity16); + Task SaveReadCapacity16() => SaveElementAsync(_scsiInfo.ReadCapacity16); - async Task ExecuteSaveGetConfigurationCommand() => await SaveElement(_scsiInfo.MmcConfiguration); + Task SaveGetConfiguration() => SaveElementAsync(_scsiInfo.MmcConfiguration); - async Task ExecuteSaveRecognizedFormatLayersCommand() => await SaveElement(_scsiInfo.RecognizedFormatLayers); + Task SaveRecognizedFormatLayers() => SaveElementAsync(_scsiInfo.RecognizedFormatLayers); - async Task ExecuteSaveWriteProtectionStatusCommand() => await SaveElement(_scsiInfo.WriteProtectionStatus); + Task SaveWriteProtectionStatus() => SaveElementAsync(_scsiInfo.WriteProtectionStatus); - async Task ExecuteSaveDensitySupportCommand() => await SaveElement(_scsiInfo.DensitySupport); + Task SaveDensitySupport() => SaveElementAsync(_scsiInfo.DensitySupport); - async Task ExecuteSaveMediumSupportCommand() => await SaveElement(_scsiInfo.MediaTypeSupport); + Task SaveMediumSupport() => SaveElementAsync(_scsiInfo.MediaTypeSupport); - async Task ExecuteDumpCommand() + async Task DumpAsync() { switch(_scsiInfo.MediaType) { @@ -456,7 +347,7 @@ public sealed class MediaInfoViewModel : ViewModelBase mediaDumpWindow.Show(); } - async Task ExecuteScanCommand() + async Task ScanAsync() { switch(_scsiInfo.MediaType) { diff --git a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs index 3ce3cd737..dd000e626 100644 --- a/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs +++ b/Aaru.Gui/ViewModels/Panels/SubdirectoryViewModel.cs @@ -35,8 +35,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Interop; @@ -47,10 +47,10 @@ using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using Sentry; using FileAttributes = Aaru.CommonTypes.Structs.FileAttributes; @@ -65,7 +65,7 @@ public sealed class SubdirectoryViewModel { Entries = []; SelectedEntries = []; - ExtractFilesCommand = ReactiveCommand.Create(ExecuteExtractFilesCommand); + ExtractFilesCommand = new AsyncRelayCommand(ExtractFiles); _model = model; _view = view; @@ -73,13 +73,13 @@ public sealed class SubdirectoryViewModel if(errno != ErrorNumber.NoError) { - MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, - string.Format(UI.Error_0_trying_to_read_1_of_chosen_filesystem, - errno, - model.Path), - ButtonEnum.Ok, - Icon.Error) - .ShowWindowDialogAsync(view); + _ = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, + string.Format(UI.Error_0_trying_to_read_1_of_chosen_filesystem, + errno, + model.Path), + ButtonEnum.Ok, + Icon.Error) + .ShowWindowDialogAsync(view); return; } @@ -121,7 +121,7 @@ public sealed class SubdirectoryViewModel public ObservableCollection Entries { get; } public List SelectedEntries { get; } - public ReactiveCommand ExtractFilesCommand { get; } + public ICommand ExtractFilesCommand { get; } public string ExtractFilesLabel => UI.ButtonLabel_Extract_to; public string NameLabel => UI.Title_Name; @@ -138,7 +138,7 @@ public sealed class SubdirectoryViewModel public string LinksLabel => UI.Title_Links; public string ModeLabel => UI.Title_Mode; - async Task ExecuteExtractFilesCommand() + async Task ExtractFiles() { if(SelectedEntries.Count == 0) return; diff --git a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs index 10309170d..58ed9cd0b 100644 --- a/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/AtaInfoViewModel.cs @@ -32,14 +32,14 @@ using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.ATA; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Tabs; @@ -52,8 +52,8 @@ public sealed class AtaInfoViewModel : ViewModelBase public AtaInfoViewModel([CanBeNull] byte[] ataIdentify, byte[] atapiIdentify, AtaErrorRegistersChs? ataMcptError, Window view) { - SaveAtaBinaryCommand = ReactiveCommand.Create(ExecuteSaveAtaBinaryCommand); - SaveAtaTextCommand = ReactiveCommand.Create(ExecuteSaveAtaTextCommand); + SaveAtaBinaryCommand = new AsyncRelayCommand(SaveAtaBinaryAsync); + SaveAtaTextCommand = new AsyncRelayCommand(SaveAtaTextAsync); _ata = ataIdentify; _atapi = atapiIdentify; @@ -82,7 +82,8 @@ public sealed class AtaInfoViewModel : ViewModelBase AtaMcptWriteProtectionChecked = (ataMcptError.Value.DeviceHead & 0x08) == 0x08; - var specificData = (ushort)(ataMcptError.Value.CylinderHigh * 0x100 + ataMcptError.Value.CylinderLow); + ushort specificData = + (ushort)(ataMcptError.Value.CylinderHigh * 0x100 + ataMcptError.Value.CylinderLow); AtaMcptSpecificDataText = string.Format(Localization.Core.Card_specific_data_0, specificData); } @@ -96,14 +97,14 @@ public sealed class AtaInfoViewModel : ViewModelBase } } - 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 SaveAtaBinaryCommand { get; } - public ReactiveCommand SaveAtaTextCommand { get; } + 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 ICommand SaveAtaBinaryCommand { get; } + public ICommand SaveAtaTextCommand { get; } public string AtaOrAtapiText { get; } @@ -112,7 +113,7 @@ public sealed class AtaInfoViewModel : ViewModelBase public string SaveAtaBinaryLabel => UI.ButtonLabel_Save_binary_to_file; public string SaveAtaTextLabel => UI.ButtonLabel_Save_text_to_file; - async Task ExecuteSaveAtaBinaryCommand() + async Task SaveAtaBinaryAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -133,7 +134,7 @@ public sealed class AtaInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveAtaTextCommand() + async Task SaveAtaTextAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs index 25237d041..9bdf0d579 100644 --- a/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/BlurayInfoViewModel.cs @@ -32,15 +32,15 @@ using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.Bluray; using Aaru.Decoders.SCSI.MMC; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Tabs; @@ -73,17 +73,17 @@ public sealed class BlurayInfoViewModel _trackResources = blurayTrackResources; _rawDfl = blurayRawDfl; _pac = blurayPac; - SaveBlurayDiscInformationCommand = ReactiveCommand.Create(ExecuteSaveBlurayDiscInformationCommand); - SaveBlurayBurstCuttingAreaCommand = ReactiveCommand.Create(ExecuteSaveBlurayBurstCuttingAreaCommand); - SaveBlurayDdsCommand = ReactiveCommand.Create(ExecuteSaveBlurayDdsCommand); - SaveBlurayCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveBlurayCartridgeStatusCommand); + SaveBlurayDiscInformationCommand = new AsyncRelayCommand(SaveBlurayDiscInformationAsync); + SaveBlurayBurstCuttingAreaCommand = new AsyncRelayCommand(SaveBlurayBurstCuttingAreaAsync); + SaveBlurayDdsCommand = new AsyncRelayCommand(SaveBlurayDdsAsync); + SaveBlurayCartridgeStatusCommand = new AsyncRelayCommand(SaveBlurayCartridgeStatusAsync); - SaveBluraySpareAreaInformationCommand = ReactiveCommand.Create(ExecuteSaveBluraySpareAreaInformationCommand); + SaveBluraySpareAreaInformationCommand = new AsyncRelayCommand(SaveBluraySpareAreaInformationAsync); - SaveBlurayPowResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayPowResourcesCommand); - SaveBlurayTrackResourcesCommand = ReactiveCommand.Create(ExecuteSaveBlurayTrackResourcesCommand); - SaveBlurayRawDflCommand = ReactiveCommand.Create(ExecuteSaveBlurayRawDflCommand); - SaveBlurayPacCommand = ReactiveCommand.Create(ExecuteSaveBlurayPacCommand); + SaveBlurayPowResourcesCommand = new AsyncRelayCommand(SaveBlurayPowResourcesAsync); + SaveBlurayTrackResourcesCommand = new AsyncRelayCommand(SaveBlurayTrackResourcesAsync); + SaveBlurayRawDflCommand = new AsyncRelayCommand(SaveBlurayRawDflAsync); + SaveBlurayPacCommand = new AsyncRelayCommand(SaveBlurayPacAsync); if(blurayDiscInformation != null) { @@ -131,31 +131,31 @@ public sealed class BlurayInfoViewModel 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 SaveBlurayDiscInformationCommand { get; } - public ReactiveCommand SaveBlurayBurstCuttingAreaCommand { get; } - public ReactiveCommand SaveBlurayDdsCommand { get; } - public ReactiveCommand SaveBlurayCartridgeStatusCommand { get; } - public ReactiveCommand SaveBluraySpareAreaInformationCommand { get; } - public ReactiveCommand SaveBlurayPowResourcesCommand { get; } - public ReactiveCommand SaveBlurayTrackResourcesCommand { get; } - public ReactiveCommand SaveBlurayRawDflCommand { get; } - public ReactiveCommand 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; } + 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 ICommand SaveBlurayDiscInformationCommand { get; } + public ICommand SaveBlurayBurstCuttingAreaCommand { get; } + public ICommand SaveBlurayDdsCommand { get; } + public ICommand SaveBlurayCartridgeStatusCommand { get; } + public ICommand SaveBluraySpareAreaInformationCommand { get; } + public ICommand SaveBlurayPowResourcesCommand { get; } + public ICommand SaveBlurayTrackResourcesCommand { get; } + public ICommand SaveBlurayRawDflCommand { get; } + public ICommand 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; } public string DiscInformationLabel => UI.Disc_information; public string BurstCuttingAreaLabel => UI.Burst_Cutting_Area; @@ -174,7 +174,7 @@ public sealed class BlurayInfoViewModel public string SaveBlurayRawDflLabel => UI.ButtonLabel_Save_raw_DFL; public string SaveBlurayPacLabel => UI.ButtonLabel_Save_PAC; - async Task SaveElement(byte[] data) + async Task SaveElementAsync(byte[] data) { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -192,21 +192,21 @@ public sealed class BlurayInfoViewModel saveFs.Close(); } - async Task ExecuteSaveBlurayDiscInformationCommand() => await SaveElement(_discInformation); + Task SaveBlurayDiscInformationAsync() => SaveElementAsync(_discInformation); - async Task ExecuteSaveBlurayBurstCuttingAreaCommand() => await SaveElement(_burstCuttingArea); + Task SaveBlurayBurstCuttingAreaAsync() => SaveElementAsync(_burstCuttingArea); - async Task ExecuteSaveBlurayDdsCommand() => await SaveElement(_dds); + Task SaveBlurayDdsAsync() => SaveElementAsync(_dds); - async Task ExecuteSaveBlurayCartridgeStatusCommand() => await SaveElement(_cartridgeStatus); + Task SaveBlurayCartridgeStatusAsync() => SaveElementAsync(_cartridgeStatus); - async Task ExecuteSaveBluraySpareAreaInformationCommand() => await SaveElement(_spareAreaInformation); + Task SaveBluraySpareAreaInformationAsync() => SaveElementAsync(_spareAreaInformation); - async Task ExecuteSaveBlurayPowResourcesCommand() => await SaveElement(_powResources); + Task SaveBlurayPowResourcesAsync() => SaveElementAsync(_powResources); - async Task ExecuteSaveBlurayTrackResourcesCommand() => await SaveElement(_trackResources); + Task SaveBlurayTrackResourcesAsync() => SaveElementAsync(_trackResources); - async Task ExecuteSaveBlurayRawDflCommand() => await SaveElement(_rawDfl); + Task SaveBlurayRawDflAsync() => SaveElementAsync(_rawDfl); - async Task ExecuteSaveBlurayPacCommand() => await SaveElement(_pac); + Task SaveBlurayPacAsync() => SaveElementAsync(_pac); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs index 0978ad829..843b64fbc 100644 --- a/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/CompactDiscInfoViewModel.cs @@ -33,15 +33,15 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.CD; using Aaru.Decoders.SCSI.MMC; using Aaru.Gui.Models; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; -using ReactiveUI; +using CommunityToolkit.Mvvm.Input; namespace Aaru.Gui.ViewModels.Tabs; @@ -72,13 +72,13 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase _cdTextLeadInData = cdTextLeadIn; _view = view; IsrcList = []; - 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); + SaveCdInformationCommand = new AsyncRelayCommand(SaveCdInformationAsync); + SaveCdTocCommand = new AsyncRelayCommand(SaveCdTocAsync); + SaveCdFullTocCommand = new AsyncRelayCommand(SaveCdFullTocAsync); + SaveCdSessionCommand = new AsyncRelayCommand(SaveCdSessionAsync); + SaveCdTextCommand = new AsyncRelayCommand(SaveCdTextAsync); + SaveCdAtipCommand = new AsyncRelayCommand(SaveCdAtipAsync); + SaveCdPmaCommand = new AsyncRelayCommand(SaveCdPmaAsync); if(decodedCompactDiscInformation.HasValue) CdInformationText = DiscInformation.Prettify000b(decodedCompactDiscInformation); @@ -120,13 +120,13 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase public bool MiscellaneousVisible { get; } public string McnText { get; } public bool CdPmaVisible { get; } - public ReactiveCommand SaveCdInformationCommand { get; } - public ReactiveCommand SaveCdTocCommand { get; } - public ReactiveCommand SaveCdFullTocCommand { get; } - public ReactiveCommand SaveCdSessionCommand { get; } - public ReactiveCommand SaveCdTextCommand { get; } - public ReactiveCommand SaveCdAtipCommand { get; } - public ReactiveCommand SaveCdPmaCommand { get; } + public ICommand SaveCdInformationCommand { get; } + public ICommand SaveCdTocCommand { get; } + public ICommand SaveCdFullTocCommand { get; } + public ICommand SaveCdSessionCommand { get; } + public ICommand SaveCdTextCommand { get; } + public ICommand SaveCdAtipCommand { get; } + public ICommand SaveCdPmaCommand { get; } public ObservableCollection IsrcList { get; } public string CdInformationLabel => UI.Title_Information; @@ -148,7 +148,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase public string ISRCLabel => UI.Title_ISRC; public string SaveCdPmaLabel => UI.ButtonLabel_Save_READ_PMA_response; - async Task ExecuteSaveCdInformationCommand() + async Task SaveCdInformationAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -166,7 +166,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdTocCommand() + async Task SaveCdTocAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -184,7 +184,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdFullTocCommand() + async Task SaveCdFullTocAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -202,7 +202,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdSessionCommand() + async Task SaveCdSessionAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -220,7 +220,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdTextCommand() + async Task SaveCdTextAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -238,7 +238,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdAtipCommand() + async Task SaveCdAtipAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -256,7 +256,7 @@ public sealed class CompactDiscInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveCdPmaCommand() + async Task SaveCdPmaAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs index 01b990c9d..e0db117f5 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdInfoViewModel.cs @@ -32,14 +32,14 @@ using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.DVD; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Tabs; @@ -64,12 +64,12 @@ public sealed class DvdInfoViewModel _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); + SaveDvdPfiCommand = new AsyncRelayCommand(SaveDvdPfiAsync); + SaveDvdDmiCommand = new AsyncRelayCommand(SaveDvdDmiAsync); + SaveDvdCmiCommand = new AsyncRelayCommand(SaveDvdCmiAsync); + SaveHdDvdCmiCommand = new AsyncRelayCommand(SaveHdDvdCmiAsync); + SaveDvdBcaCommand = new AsyncRelayCommand(SaveDvdBcaAsync); + SaveDvdAacsCommand = new AsyncRelayCommand(SaveDvdAacsAsync); /* TODO: Pass back switch(mediaType) @@ -102,20 +102,20 @@ public sealed class DvdInfoViewModel SaveDvdAacsVisible = aacs != null; } - public ReactiveCommand SaveDvdPfiCommand { get; } - public ReactiveCommand SaveDvdDmiCommand { get; } - public ReactiveCommand SaveDvdCmiCommand { get; } - public ReactiveCommand SaveHdDvdCmiCommand { get; } - public ReactiveCommand SaveDvdBcaCommand { get; } - public ReactiveCommand 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; } + public ICommand SaveDvdPfiCommand { get; } + public ICommand SaveDvdDmiCommand { get; } + public ICommand SaveDvdCmiCommand { get; } + public ICommand SaveHdDvdCmiCommand { get; } + public ICommand SaveDvdBcaCommand { get; } + public ICommand 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; } public string SaveDvdPfiLabel => UI.ButtonLabel_Save_Physical_Format_Information; public string SaveDvdDmiLabel => UI.ButtonLabel_Save_Disc_Manufacturer_Information; @@ -124,7 +124,7 @@ public sealed class DvdInfoViewModel public string SaveDvdBcaLabel => UI.ButtonLabel_Save_Burst_Cutting_Area; public string SaveDvdAacsLabel => UI.ButtonLabel_Save_AACS_Information; - async Task SaveElement(byte[] data) + async Task SaveElementAsync(byte[] data) { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -142,15 +142,15 @@ public sealed class DvdInfoViewModel saveFs.Close(); } - async Task ExecuteSaveDvdPfiCommand() => await SaveElement(_dvdPfi); + Task SaveDvdPfiAsync() => SaveElementAsync(_dvdPfi); - async Task ExecuteSaveDvdDmiCommand() => await SaveElement(_dvdDmi); + Task SaveDvdDmiAsync() => SaveElementAsync(_dvdDmi); - async Task ExecuteSaveDvdCmiCommand() => await SaveElement(_dvdCmi); + Task SaveDvdCmiAsync() => SaveElementAsync(_dvdCmi); - async Task ExecuteSaveHdDvdCmiCommand() => await SaveElement(_hddvdCopyrightInformation); + Task SaveHdDvdCmiAsync() => SaveElementAsync(_hddvdCopyrightInformation); - async Task ExecuteSaveDvdBcaCommand() => await SaveElement(_dvdBca); + Task SaveDvdBcaAsync() => SaveElementAsync(_dvdBca); - async Task ExecuteSaveDvdAacsCommand() => await SaveElement(_dvdAacs); + Task SaveDvdAacsAsync() => SaveElementAsync(_dvdAacs); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs index dfd6ff005..cc5d7619b 100644 --- a/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/DvdWritableInfoViewModel.cs @@ -32,13 +32,13 @@ using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.DVD; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; -using ReactiveUI; +using CommunityToolkit.Mvvm.Input; namespace Aaru.Gui.ViewModels.Tabs; @@ -69,27 +69,26 @@ public sealed class DvdWritableInfoViewModel byte[] adip, byte[] dcb, Window view) { _view = view; - SaveDvdRamDdsCommand = ReactiveCommand.Create(ExecuteSaveDvdRamDdsCommand); - SaveDvdRamCartridgeStatusCommand = ReactiveCommand.Create(ExecuteSaveDvdRamCartridgeStatusCommand); + SaveDvdRamDdsCommand = new AsyncRelayCommand(SaveDvdRamDdsAsync); + SaveDvdRamCartridgeStatusCommand = new AsyncRelayCommand(SaveDvdRamCartridgeStatusAsync); - SaveDvdRamSpareAreaInformationCommand = ReactiveCommand.Create(ExecuteSaveDvdRamSpareAreaInformationCommand); + SaveDvdRamSpareAreaInformationCommand = new AsyncRelayCommand(SaveDvdRamSpareAreaInformationAsync); - 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); + SaveLastBorderOutRmdCommand = new AsyncRelayCommand(SaveLastBorderOutRmdAsync); + SaveDvdPreRecordedInfoCommand = new AsyncRelayCommand(SaveDvdPreRecordedInfoAsync); + SaveDvdrMediaIdentifierCommand = new AsyncRelayCommand(SaveDvdrMediaIdentifierAsync); + SaveDvdrPhysicalInformationCommand = new AsyncRelayCommand(SaveDvdrPhysicalInformationAsync); + SaveHddvdrMediumStatusCommand = new AsyncRelayCommand(SaveHddvdrMediumStatusAsync); + SaveHddvdrLastRmdCommand = new AsyncRelayCommand(SaveHddvdrLastRmdAsync); + SaveDvdrLayerCapacityCommand = new AsyncRelayCommand(SaveDvdrLayerCapacityAsync); + SaveDvdrDlMiddleZoneStartCommand = new AsyncRelayCommand(SaveDvdrDlMiddleZoneStartAsync); + SaveDvdrDlJumpIntervalSizeCommand = new AsyncRelayCommand(SaveDvdrDlJumpIntervalSizeAsync); - SaveDvdrDlManualLayerJumpStartLbaCommand = - ReactiveCommand.Create(ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand); + SaveDvdrDlManualLayerJumpStartLbaCommand = new AsyncRelayCommand(SaveDvdrDlManualLayerJumpStartLbaAsync); - SaveDvdrDlRemapAnchorPointCommand = ReactiveCommand.Create(ExecuteSaveDvdrDlRemapAnchorPointCommand); - SaveDvdPlusAdipCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusAdipCommand); - SaveDvdPlusDcbCommand = ReactiveCommand.Create(ExecuteSaveDvdPlusDcbCommand); + SaveDvdrDlRemapAnchorPointCommand = new AsyncRelayCommand(SaveDvdrDlRemapAnchorPointAsync); + SaveDvdPlusAdipCommand = new AsyncRelayCommand(SaveDvdPlusAdipAsync); + SaveDvdPlusDcbCommand = new AsyncRelayCommand(SaveDvdPlusDcbAsync); _dvdRamDds = dds; _dvdRamCartridgeStatus = cartridgeStatus; @@ -194,41 +193,41 @@ public sealed class DvdWritableInfoViewModel 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 SaveDvdRamDdsCommand { get; } - public ReactiveCommand SaveDvdRamCartridgeStatusCommand { get; } - public ReactiveCommand SaveDvdRamSpareAreaInformationCommand { get; } - public ReactiveCommand SaveLastBorderOutRmdCommand { get; } - public ReactiveCommand SaveDvdPreRecordedInfoCommand { get; } - public ReactiveCommand SaveDvdrMediaIdentifierCommand { get; } - public ReactiveCommand SaveDvdrPhysicalInformationCommand { get; } - public ReactiveCommand SaveHddvdrMediumStatusCommand { get; } - public ReactiveCommand SaveHddvdrLastRmdCommand { get; } - public ReactiveCommand SaveDvdrLayerCapacityCommand { get; } - public ReactiveCommand SaveDvdrDlMiddleZoneStartCommand { get; } - public ReactiveCommand SaveDvdrDlJumpIntervalSizeCommand { get; } - public ReactiveCommand SaveDvdrDlManualLayerJumpStartLbaCommand { get; } - public ReactiveCommand SaveDvdrDlRemapAnchorPointCommand { get; } - public ReactiveCommand SaveDvdPlusAdipCommand { get; } - public ReactiveCommand SaveDvdPlusDcbCommand { get; } + 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 ICommand SaveDvdRamDdsCommand { get; } + public ICommand SaveDvdRamCartridgeStatusCommand { get; } + public ICommand SaveDvdRamSpareAreaInformationCommand { get; } + public ICommand SaveLastBorderOutRmdCommand { get; } + public ICommand SaveDvdPreRecordedInfoCommand { get; } + public ICommand SaveDvdrMediaIdentifierCommand { get; } + public ICommand SaveDvdrPhysicalInformationCommand { get; } + public ICommand SaveHddvdrMediumStatusCommand { get; } + public ICommand SaveHddvdrLastRmdCommand { get; } + public ICommand SaveDvdrLayerCapacityCommand { get; } + public ICommand SaveDvdrDlMiddleZoneStartCommand { get; } + public ICommand SaveDvdrDlJumpIntervalSizeCommand { get; } + public ICommand SaveDvdrDlManualLayerJumpStartLbaCommand { get; } + public ICommand SaveDvdrDlRemapAnchorPointCommand { get; } + public ICommand SaveDvdPlusAdipCommand { get; } + public ICommand SaveDvdPlusDcbCommand { get; } public string DvdRamDdsLabel => UI.Disc_Definition_Structure; public string DvdRamCartridgeStatusLabel => UI.Cartridge_Status; @@ -250,7 +249,7 @@ public sealed class DvdWritableInfoViewModel public string SaveDvdPlusAdipLabel => UI.ButtonLabel_Save_ADIP; public string SaveDvdPlusDcbLabel => UI.ButtonLabel_Save_Disc_Control_Blocks; - async Task SaveElement(byte[] data) + async Task SaveElementAsync(byte[] data) { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -268,35 +267,35 @@ public sealed class DvdWritableInfoViewModel saveFs.Close(); } - async Task ExecuteSaveDvdRamDdsCommand() => await SaveElement(_dvdRamDds); + Task SaveDvdRamDdsAsync() => SaveElementAsync(_dvdRamDds); - async Task ExecuteSaveDvdRamCartridgeStatusCommand() => await SaveElement(_dvdRamCartridgeStatus); + Task SaveDvdRamCartridgeStatusAsync() => SaveElementAsync(_dvdRamCartridgeStatus); - async Task ExecuteSaveDvdRamSpareAreaInformationCommand() => await SaveElement(_dvdRamSpareArea); + Task SaveDvdRamSpareAreaInformationAsync() => SaveElementAsync(_dvdRamSpareArea); - async Task ExecuteSaveLastBorderOutRmdCommand() => await SaveElement(_dvdLastBorderOutRmd); + Task SaveLastBorderOutRmdAsync() => SaveElementAsync(_dvdLastBorderOutRmd); - async Task ExecuteSaveDvdPreRecordedInfoCommand() => await SaveElement(_dvdPreRecordedInfo); + Task SaveDvdPreRecordedInfoAsync() => SaveElementAsync(_dvdPreRecordedInfo); - async Task ExecuteSaveDvdrMediaIdentifierCommand() => await SaveElement(_dvdrMediaIdentifier); + Task SaveDvdrMediaIdentifierAsync() => SaveElementAsync(_dvdrMediaIdentifier); - async Task ExecuteSaveDvdrPhysicalInformationCommand() => await SaveElement(_dvdrPhysicalInformation); + Task SaveDvdrPhysicalInformationAsync() => SaveElementAsync(_dvdrPhysicalInformation); - async Task ExecuteSaveHddvdrMediumStatusCommand() => await SaveElement(_hddvdrMediumStatus); + Task SaveHddvdrMediumStatusAsync() => SaveElementAsync(_hddvdrMediumStatus); - async Task ExecuteSaveHddvdrLastRmdCommand() => await SaveElement(_hddvdrLastRmd); + Task SaveHddvdrLastRmdAsync() => SaveElementAsync(_hddvdrLastRmd); - async Task ExecuteSaveDvdrLayerCapacityCommand() => await SaveElement(_dvdrLayerCapacity); + Task SaveDvdrLayerCapacityAsync() => SaveElementAsync(_dvdrLayerCapacity); - async Task ExecuteSaveDvdrDlMiddleZoneStartCommand() => await SaveElement(_dvdrDlMiddleZoneStart); + Task SaveDvdrDlMiddleZoneStartAsync() => SaveElementAsync(_dvdrDlMiddleZoneStart); - async Task ExecuteSaveDvdrDlJumpIntervalSizeCommand() => await SaveElement(_dvdrDlJumpIntervalSize); + Task SaveDvdrDlJumpIntervalSizeAsync() => SaveElementAsync(_dvdrDlJumpIntervalSize); - async Task ExecuteSaveDvdrDlManualLayerJumpStartLbaCommand() => await SaveElement(_dvdrDlManualLayerJumpStartLba); + Task SaveDvdrDlManualLayerJumpStartLbaAsync() => SaveElementAsync(_dvdrDlManualLayerJumpStartLba); - async Task ExecuteSaveDvdrDlRemapAnchorPointCommand() => await SaveElement(_dvdrDlRemapAnchorPoint); + Task SaveDvdrDlRemapAnchorPointAsync() => SaveElementAsync(_dvdrDlRemapAnchorPoint); - async Task ExecuteSaveDvdPlusAdipCommand() => await SaveElement(_dvdPlusAdip); + Task SaveDvdPlusAdipAsync() => SaveElementAsync(_dvdPlusAdip); - async Task ExecuteSaveDvdPlusDcbCommand() => await SaveElement(_dvdPlusDcb); + Task SaveDvdPlusDcbAsync() => SaveElementAsync(_dvdPlusDcb); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs index 5e85d7a5e..99d3fb524 100644 --- a/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/PcmciaInfoViewModel.cs @@ -33,27 +33,29 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Decoders.PCMCIA; using Aaru.Gui.Models; using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; using Tuple = Aaru.Decoders.PCMCIA.Tuple; namespace Aaru.Gui.ViewModels.Tabs; -public class PcmciaInfoViewModel : ViewModelBase +public sealed partial class PcmciaInfoViewModel : ViewModelBase { const string MODULE_NAME = "PCMCIA Information ViewModel"; readonly byte[] _cis; readonly Window _view; - string _pcmciaCisText; - PcmciaCisModel _selectedCis; + [ObservableProperty] + string _pcmciaCisText; + PcmciaCisModel _selectedCis; internal PcmciaInfoViewModel([CanBeNull] byte[] pcmciaCis, Window view) { @@ -61,7 +63,7 @@ public class PcmciaInfoViewModel : ViewModelBase _cis = pcmciaCis; CisList = []; - SavePcmciaCisCommand = ReactiveCommand.Create(ExecuteSavePcmciaCisCommand); + SavePcmciaCisCommand = new AsyncRelayCommand(SavePcmciaCisAsync); _view = view; @@ -156,12 +158,6 @@ public class PcmciaInfoViewModel : ViewModelBase public ObservableCollection CisList { get; } - public string PcmciaCisText - { - get => _pcmciaCisText; - set => this.RaiseAndSetIfChanged(ref _pcmciaCisText, value); - } - public PcmciaCisModel SelectedCis { get => _selectedCis; @@ -170,13 +166,13 @@ public class PcmciaInfoViewModel : ViewModelBase if(_selectedCis == value) return; PcmciaCisText = value?.Description; - this.RaiseAndSetIfChanged(ref _selectedCis, value); + SetProperty(ref _selectedCis, value); } } - public ReactiveCommand SavePcmciaCisCommand { get; } + public ICommand SavePcmciaCisCommand { get; } - async Task ExecuteSavePcmciaCisCommand() + async Task SavePcmciaCisAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs index 7891add8a..132c9f559 100644 --- a/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/ScsiInfoViewModel.cs @@ -34,8 +34,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes.Structs.Devices.SCSI; using Aaru.Decoders.SCSI; using Aaru.Decoders.SCSI.MMC; @@ -45,24 +45,28 @@ using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Inquiry = Aaru.CommonTypes.Structs.Devices.SCSI.Inquiry; namespace Aaru.Gui.ViewModels.Tabs; -public sealed class ScsiInfoViewModel : ViewModelBase +public sealed partial class ScsiInfoViewModel : ViewModelBase { const string MODULE_NAME = "SCSI Information ViewModel"; readonly byte[] _configuration; readonly byte[] _scsiModeSense10; readonly byte[] _scsiModeSense6; readonly Window _view; - string _evpdPageText; - string _mmcFeatureText; - string _scsiModeSensePageText; - object _selectedEvpdPage; - object _selectedMmcFeature; - object _selectedModeSensePage; + [ObservableProperty] + string _evpdPageText; + [ObservableProperty] + string _mmcFeatureText; + [ObservableProperty] + string _modeSensePageText; + object _selectedEvpdPage; + object _selectedMmcFeature; + object _selectedModeSensePage; public ScsiInfoViewModel(byte[] scsiInquiryData, Inquiry? scsiInquiry, Dictionary scsiEvpdPages, Modes.DecodedMode? scsiMode, PeripheralDeviceTypes scsiType, byte[] scsiModeSense6, @@ -76,12 +80,12 @@ public sealed class ScsiInfoViewModel : ViewModelBase ModeSensePages = []; EvpdPages = []; MmcFeatures = []; - SaveInquiryBinaryCommand = ReactiveCommand.Create(ExecuteSaveInquiryBinaryCommand); - SaveInquiryTextCommand = ReactiveCommand.Create(ExecuteSaveInquiryTextCommand); - SaveModeSense6Command = ReactiveCommand.Create(ExecuteSaveModeSense6Command); - SaveModeSense10Command = ReactiveCommand.Create(ExecuteSaveModeSense10Command); - SaveEvpdPageCommand = ReactiveCommand.Create(ExecuteSaveEvpdPageCommand); - SaveMmcFeaturesCommand = ReactiveCommand.Create(ExecuteSaveMmcFeaturesCommand); + SaveInquiryBinaryCommand = new AsyncRelayCommand(SaveInquiryBinaryAsync); + SaveInquiryTextCommand = new AsyncRelayCommand(SaveInquiryTextAsync); + SaveModeSense6Command = new AsyncRelayCommand(SaveModeSense6Async); + SaveModeSense10Command = new AsyncRelayCommand(SaveModeSense10Async); + SaveEvpdPageCommand = new AsyncRelayCommand(SaveEvpdPageAsync); + SaveMmcFeaturesCommand = new AsyncRelayCommand(SaveMmcFeaturesAsync); if(InquiryData == null || !scsiInquiry.HasValue) return; @@ -606,9 +610,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase evpdPageTitle = string.Format(UI.Page_0_h, page.Key); evpdDecodedPage = UI.Undecoded; - AaruLogging.Debug(MODULE_NAME, - Localization.Core.Found_undecoded_SCSI_VPD_page_0, - page.Key); + AaruLogging.Debug(MODULE_NAME, Localization.Core.Found_undecoded_SCSI_VPD_page_0, page.Key); break; } @@ -629,9 +631,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase AaruLogging.Debug(MODULE_NAME, Localization.Core.GET_CONFIGURATION_length_is_0, ftr.DataLength); - AaruLogging.Debug(MODULE_NAME, - Localization.Core.GET_CONFIGURATION_current_profile_is_0, - ftr.CurrentProfile); + AaruLogging.Debug(MODULE_NAME, Localization.Core.GET_CONFIGURATION_current_profile_is_0, ftr.CurrentProfile); if(ftr.Descriptors != null) { @@ -711,10 +711,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase } } else - { - AaruLogging.Debug(MODULE_NAME, - Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors); - } + AaruLogging.Debug(MODULE_NAME, Localization.Core.GET_CONFIGURATION_returned_no_feature_descriptors); } public byte[] InquiryData { get; } @@ -722,12 +719,12 @@ public sealed class ScsiInfoViewModel : ViewModelBase public ObservableCollection ModeSensePages { get; } public ObservableCollection EvpdPages { get; } public ObservableCollection MmcFeatures { get; } - public ReactiveCommand SaveInquiryBinaryCommand { get; } - public ReactiveCommand SaveInquiryTextCommand { get; } - public ReactiveCommand SaveModeSense6Command { get; } - public ReactiveCommand SaveModeSense10Command { get; } - public ReactiveCommand SaveEvpdPageCommand { get; } - public ReactiveCommand SaveMmcFeaturesCommand { get; } + public ICommand SaveInquiryBinaryCommand { get; } + public ICommand SaveInquiryTextCommand { get; } + public ICommand SaveModeSense6Command { get; } + public ICommand SaveModeSense10Command { get; } + public ICommand SaveEvpdPageCommand { get; } + public ICommand SaveMmcFeaturesCommand { get; } public object SelectedModeSensePage { @@ -738,16 +735,10 @@ public sealed class ScsiInfoViewModel : ViewModelBase if(value is ScsiPageModel pageModel) ModeSensePageText = pageModel.Description; - this.RaiseAndSetIfChanged(ref _selectedModeSensePage, value); + SetProperty(ref _selectedModeSensePage, value); } } - public string ModeSensePageText - { - get => _scsiModeSensePageText; - set => this.RaiseAndSetIfChanged(ref _scsiModeSensePageText, value); - } - public object SelectedEvpdPage { get => _selectedEvpdPage; @@ -757,16 +748,10 @@ public sealed class ScsiInfoViewModel : ViewModelBase if(value is ScsiPageModel pageModel) EvpdPageText = pageModel.Description; - this.RaiseAndSetIfChanged(ref _selectedEvpdPage, value); + SetProperty(ref _selectedEvpdPage, value); } } - public string EvpdPageText - { - get => _evpdPageText; - set => this.RaiseAndSetIfChanged(ref _evpdPageText, value); - } - public object SelectedMmcFeature { get => _selectedMmcFeature; @@ -776,16 +761,10 @@ public sealed class ScsiInfoViewModel : ViewModelBase if(value is ScsiPageModel pageModel) MmcFeatureText = pageModel.Description; - this.RaiseAndSetIfChanged(ref _selectedMmcFeature, value); + SetProperty(ref _selectedMmcFeature, value); } } - public string MmcFeatureText - { - get => _mmcFeatureText; - set => this.RaiseAndSetIfChanged(ref _mmcFeatureText, value); - } - public string InquiryLabel => UI.Title_INQUIRY; public string ScsiInquiryLabel => UI.Title_SCSI_INQUIRY; public string SaveInquiryBinaryLabel => UI.ButtonLabel_Save_binary_to_file; @@ -800,7 +779,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase public string FeatureLabel => UI.Title_Feature; public string SaveMmcFeaturesLabel => UI.ButtonLabel_Save_MMC_GET_CONFIGURATION_response_to_file; - async Task ExecuteSaveInquiryBinaryCommand() + async Task SaveInquiryBinaryAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -818,7 +797,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveInquiryTextCommand() + async Task SaveInquiryTextAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -836,7 +815,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveModeSense6Command() + async Task SaveModeSense6Async() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -854,7 +833,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveModeSense10Command() + async Task SaveModeSense10Async() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -872,7 +851,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveEvpdPageCommand() + async Task SaveEvpdPageAsync() { if(SelectedEvpdPage is not ScsiPageModel pageModel) return; @@ -892,7 +871,7 @@ public sealed class ScsiInfoViewModel : ViewModelBase saveFs.Close(); } - async Task ExecuteSaveMmcFeaturesCommand() + async Task SaveMmcFeaturesAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs index 59f1731e3..e68390031 100644 --- a/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs +++ b/Aaru.Gui/ViewModels/Tabs/XboxInfoViewModel.cs @@ -32,15 +32,15 @@ using System.Collections.Generic; using System.IO; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.Core.Media.Info; using Aaru.Decoders.Xbox; using Aaru.Localization; using Avalonia.Controls; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Tabs; @@ -54,7 +54,7 @@ public sealed class XboxInfoViewModel { _xboxSecuritySector = securitySector; _view = view; - SaveXboxSsCommand = ReactiveCommand.Create(ExecuteSaveXboxSsCommand); + SaveXboxSsCommand = new AsyncRelayCommand(SaveXboxSsAsync); if(xgdInfo != null) { @@ -79,17 +79,17 @@ public sealed class XboxInfoViewModel SaveXboxSsVisible = securitySector != null; } - public ReactiveCommand 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; } + public ICommand 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; } public string XboxL0VideoLabel => Localization.Core.Video_layer_zero_size; public string XboxL1VideoLabel => Localization.Core.Video_layer_one_size; @@ -101,7 +101,7 @@ public sealed class XboxInfoViewModel public string XboxSsLabel => UI.Title_Security_Sector; public string SaveXboxSsLabel => UI.ButtonLabel_Save_Xbox_Security_Sector; - async Task SaveElement(byte[] data) + async Task SaveElementAsync(byte[] data) { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { @@ -119,5 +119,5 @@ public sealed class XboxInfoViewModel saveFs.Close(); } - public async Task ExecuteSaveXboxSsCommand() => await SaveElement(_xboxSecuritySector); + Task SaveXboxSsAsync() => SaveElementAsync(_xboxSecuritySector); } \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/ViewModelBase.cs b/Aaru.Gui/ViewModels/ViewModelBase.cs index 0641d7f67..11c9b2e5e 100644 --- a/Aaru.Gui/ViewModels/ViewModelBase.cs +++ b/Aaru.Gui/ViewModels/ViewModelBase.cs @@ -30,8 +30,8 @@ // Copyright © 2011-2025 Natalia Portillo // ****************************************************************************/ -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; namespace Aaru.Gui.ViewModels; -public class ViewModelBase : ReactiveObject; \ No newline at end of file +public class ViewModelBase : ObservableObject; \ No newline at end of file diff --git a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs index 4cad80475..85df1102b 100644 --- a/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/DecodeMediaTagsViewModel.cs @@ -46,8 +46,8 @@ using Aaru.Decoders.Xbox; using Aaru.Gui.Models; using Aaru.Helpers; using Aaru.Localization; +using CommunityToolkit.Mvvm.ComponentModel; using JetBrains.Annotations; -using ReactiveUI; using BCA = Aaru.Decoders.Bluray.BCA; using Cartridge = Aaru.Decoders.DVD.Cartridge; using DDS = Aaru.Decoders.DVD.DDS; @@ -57,14 +57,17 @@ using Spare = Aaru.Decoders.DVD.Spare; namespace Aaru.Gui.ViewModels.Windows; -public sealed class DecodeMediaTagsViewModel : ViewModelBase +public sealed partial class DecodeMediaTagsViewModel : ViewModelBase { const int HEX_COLUMNS = 32; readonly MediaType _mediaType; - string _decodedText; - bool _decodedVisible; - string _hexViewText; - MediaTagModel _selectedTag; + [ObservableProperty] + string _decodedText; + [ObservableProperty] + bool _decodedVisible; + [ObservableProperty] + string _hexViewText; + MediaTagModel _selectedTag; public DecodeMediaTagsViewModel([NotNull] IMediaImage inputFormat) { @@ -95,7 +98,7 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase get => _selectedTag; set { - this.RaiseAndSetIfChanged(ref _selectedTag, value); + SetProperty(ref _selectedTag, value); if(value is null) return; @@ -233,24 +236,6 @@ public sealed class DecodeMediaTagsViewModel : ViewModelBase } } - 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); - } - public string TagLabel => UI.Title_Tag; public string HexViewLabel => UI.Title_HexView; public string DecodedLabel => UI.Title_Decoded; diff --git a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs index bafeaa3f8..b0758ce03 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageChecksumViewModel.cs @@ -33,8 +33,8 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; -using System.Reactive; using System.Threading; +using System.Windows.Input; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; @@ -44,54 +44,91 @@ using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Threading; -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Sentry; namespace Aaru.Gui.ViewModels.Windows; -public sealed class ImageChecksumViewModel : ViewModelBase +public sealed partial class ImageChecksumViewModel : ViewModelBase { // How many sectors to read at once const uint SECTORS_TO_READ = 256; const string MODULE_NAME = "Image Checksum ViewModel"; readonly IMediaImage _inputFormat; readonly Window _view; - bool _adler32Checked; - bool _cancel; - bool _checksumMediaChecked; - bool _checksumTracksChecked; - bool _checksumTracksVisible; - bool _closeCommandEnabled; - bool _closeCommandVisible; - bool _crc16Checked; - bool _crc32Checked; - bool _crc64Checked; - bool _fletcher16Checked; - bool _fletcher32Checked; - bool _md5Checked; - bool _mediaChecksumsVisible; - bool _optionsEnabled; - bool _progress1Visible; - double _progress2Max; - string _progress2Text; - double _progress2Value; - bool _progress2Visible; - double _progressMax; - string _progressText; - double _progressValue; - bool _progressVisible; - bool _resultsVisible; - bool _sha1Checked; - bool _sha256Checked; - bool _sha384Checked; - bool _sha512Checked; - bool _spamsumChecked; - bool _startCommandEnabled; - bool _startCommandVisible; - bool _stopCommandEnabled; - bool _stopCommandVisible; - string _title; - bool _trackChecksumsVisible; + [ObservableProperty] + bool _adler32Checked; + [ObservableProperty] + bool _cancel; + [ObservableProperty] + bool _checksumMediaChecked; + [ObservableProperty] + bool _checksumTracksChecked; + [ObservableProperty] + bool _checksumTracksVisible; + [ObservableProperty] + bool _closeCommandEnabled; + [ObservableProperty] + bool _closeCommandVisible; + [ObservableProperty] + bool _crc16Checked; + [ObservableProperty] + bool _crc32Checked; + [ObservableProperty] + bool _crc64Checked; + [ObservableProperty] + bool _fletcher16Checked; + [ObservableProperty] + bool _fletcher32Checked; + [ObservableProperty] + bool _md5Checked; + [ObservableProperty] + bool _mediaChecksumsVisible; + [ObservableProperty] + bool _optionsEnabled; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + double _progress2Max; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + double _progressMax; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + bool _resultsVisible; + [ObservableProperty] + bool _sha1Checked; + [ObservableProperty] + bool _sha256Checked; + [ObservableProperty] + bool _sha384Checked; + [ObservableProperty] + bool _sha512Checked; + [ObservableProperty] + bool _spamsumChecked; + [ObservableProperty] + bool _startCommandEnabled; + [ObservableProperty] + bool _startCommandVisible; + [ObservableProperty] + bool _stopCommandEnabled; + [ObservableProperty] + bool _stopCommandVisible; + [ObservableProperty] + string _title; + [ObservableProperty] + bool _trackChecksumsVisible; public ImageChecksumViewModel(IMediaImage inputFormat, Window view) { @@ -110,9 +147,9 @@ public sealed class ImageChecksumViewModel : ViewModelBase SpamsumChecked = true; TrackChecksums = []; MediaChecksums = []; - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); StopCommandVisible = false; StartCommandVisible = true; CloseCommandVisible = true; @@ -154,223 +191,13 @@ public sealed class ImageChecksumViewModel : ViewModelBase public string CloseLabel => UI.ButtonLabel_Close; public string StopLabel => UI.ButtonLabel_Stop; - public string Title - { - get => _title; - set => this.RaiseAndSetIfChanged(ref _title, value); - } - - public bool OptionsEnabled - { - get => _optionsEnabled; - set => this.RaiseAndSetIfChanged(ref _optionsEnabled, value); - } - - public bool ChecksumMediaChecked - { - get => _checksumMediaChecked; - set => this.RaiseAndSetIfChanged(ref _checksumMediaChecked, value); - } - - public bool ChecksumTracksChecked - { - get => _checksumTracksChecked; - set => this.RaiseAndSetIfChanged(ref _checksumTracksChecked, value); - } - - public bool Adler32Checked - { - get => _adler32Checked; - set => this.RaiseAndSetIfChanged(ref _adler32Checked, value); - } - - public bool Crc16Checked - { - get => _crc16Checked; - set => this.RaiseAndSetIfChanged(ref _crc16Checked, value); - } - - public bool Crc32Checked - { - get => _crc32Checked; - set => this.RaiseAndSetIfChanged(ref _crc32Checked, value); - } - - public bool Crc64Checked - { - get => _crc64Checked; - set => this.RaiseAndSetIfChanged(ref _crc64Checked, value); - } - - public bool Fletcher16Checked - { - get => _fletcher16Checked; - set => this.RaiseAndSetIfChanged(ref _fletcher16Checked, value); - } - - public bool Fletcher32Checked - { - get => _fletcher32Checked; - set => this.RaiseAndSetIfChanged(ref _fletcher32Checked, value); - } - - public bool Md5Checked - { - get => _md5Checked; - set => this.RaiseAndSetIfChanged(ref _md5Checked, value); - } - - public bool Sha1Checked - { - get => _sha1Checked; - set => this.RaiseAndSetIfChanged(ref _sha1Checked, value); - } - - public bool Sha256Checked - { - get => _sha256Checked; - set => this.RaiseAndSetIfChanged(ref _sha256Checked, value); - } - - public bool Sha384Checked - { - get => _sha384Checked; - set => this.RaiseAndSetIfChanged(ref _sha384Checked, value); - } - - public bool Sha512Checked - { - get => _sha512Checked; - set => this.RaiseAndSetIfChanged(ref _sha512Checked, value); - } - - public bool SpamsumChecked - { - get => _spamsumChecked; - set => this.RaiseAndSetIfChanged(ref _spamsumChecked, value); - } - - public bool ResultsVisible - { - get => _resultsVisible; - set => this.RaiseAndSetIfChanged(ref _resultsVisible, value); - } - - public bool TrackChecksumsVisible - { - get => _trackChecksumsVisible; - set => this.RaiseAndSetIfChanged(ref _trackChecksumsVisible, value); - } - - public bool MediaChecksumsVisible - { - get => _mediaChecksumsVisible; - set => this.RaiseAndSetIfChanged(ref _mediaChecksumsVisible, value); - } - - public bool ProgressVisible - { - get => _progressVisible; - set => this.RaiseAndSetIfChanged(ref _progressVisible, value); - } - - public bool Progress1Visible - { - get => _progress1Visible; - set => this.RaiseAndSetIfChanged(ref _progress1Visible, value); - } - - public string ProgressText - { - get => _progressText; - set => this.RaiseAndSetIfChanged(ref _progressText, value); - } - - public double ProgressMax - { - get => _progressMax; - set => this.RaiseAndSetIfChanged(ref _progressMax, value); - } - - public double ProgressValue - { - get => _progressValue; - set => this.RaiseAndSetIfChanged(ref _progressValue, value); - } - - public bool Progress2Visible - { - get => _progress2Visible; - set => this.RaiseAndSetIfChanged(ref _progress2Visible, value); - } - - public string Progress2Text - { - get => _progress2Text; - set => this.RaiseAndSetIfChanged(ref _progress2Text, value); - } - - public double Progress2Max - { - get => _progress2Max; - set => this.RaiseAndSetIfChanged(ref _progress2Max, value); - } - - public double Progress2Value - { - get => _progress2Value; - set => this.RaiseAndSetIfChanged(ref _progress2Value, value); - } - - public bool StartCommandEnabled - { - get => _startCommandEnabled; - set => this.RaiseAndSetIfChanged(ref _startCommandEnabled, value); - } - - public bool StartCommandVisible - { - get => _startCommandVisible; - set => this.RaiseAndSetIfChanged(ref _startCommandVisible, value); - } - - public bool CloseCommandEnabled - { - get => _closeCommandEnabled; - set => this.RaiseAndSetIfChanged(ref _closeCommandEnabled, value); - } - - public bool CloseCommandVisible - { - get => _closeCommandVisible; - set => this.RaiseAndSetIfChanged(ref _closeCommandVisible, value); - } - - public bool StopCommandEnabled - { - get => _stopCommandEnabled; - set => this.RaiseAndSetIfChanged(ref _stopCommandEnabled, value); - } - - public bool StopCommandVisible - { - get => _stopCommandVisible; - set => this.RaiseAndSetIfChanged(ref _stopCommandVisible, value); - } - - public bool ChecksumTracksVisible - { - get => _checksumTracksVisible; - set => this.RaiseAndSetIfChanged(ref _stopCommandVisible, value); - } - public ObservableCollection TrackChecksums { get; } public ObservableCollection MediaChecksums { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } - void ExecuteStartCommand() + void Start() { OptionsEnabled = false; CloseCommandVisible = false; @@ -386,9 +213,9 @@ public sealed class ImageChecksumViewModel : ViewModelBase }.Start(); } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() + internal void Stop() { _cancel = true; StopCommandEnabled = false; diff --git a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs index c0ac40f15..a46e84c05 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageConvertViewModel.cs @@ -36,11 +36,11 @@ using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Reactive; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Enums; @@ -55,9 +55,10 @@ using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; using Avalonia.Threading; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using Sentry; using ImageInfo = Aaru.CommonTypes.Structs.ImageInfo; using Track = Aaru.CommonTypes.Structs.Track; @@ -66,70 +67,130 @@ using Version = Aaru.CommonTypes.Interop.Version; namespace Aaru.Gui.ViewModels.Windows; [SuppressMessage("ReSharper", "AsyncVoidLambda")] -public sealed class ImageConvertViewModel : ViewModelBase +public sealed partial class ImageConvertViewModel : ViewModelBase { readonly IMediaImage _inputFormat; readonly Window _view; - Metadata _aaruMetadata; - bool _aaruMetadataFromImageVisible; - bool _cancel; - bool _closeVisible; - string _commentsText; - bool _commentsVisible; - string _creatorText; - bool _creatorVisible; - bool _destinationEnabled; - string _destinationText; - bool _destinationVisible; - string _driveFirmwareRevisionText; - bool _driveFirmwareRevisionVisible; - string _driveManufacturerText; - bool _driveManufacturerVisible; - string _driveModelText; - bool _driveModelVisible; - string _driveSerialNumberText; - bool _driveSerialNumberVisible; - List _dumpHardware; - bool _forceChecked; - bool _formatReadOnly; - double _lastMediaSequenceValue; - bool _lastMediaSequenceVisible; - string _mediaBarcodeText; - bool _mediaBarcodeVisible; - string _mediaManufacturerText; - bool _mediaManufacturerVisible; - string _mediaModelText; - bool _mediaModelVisible; - string _mediaPartNumberText; - bool _mediaPartNumberVisible; - double _mediaSequenceValue; - bool _mediaSequenceVisible; - string _mediaSerialNumberText; - bool _mediaSerialNumberVisible; - string _mediaTitleText; - bool _mediaTitleVisible; - string _metadataJsonText; - bool _optionsVisible; - bool _progress1Visible; - bool _progress2Indeterminate; - double _progress2MaxValue; - string _progress2Text; - double _progress2Value; - bool _progress2Visible; - bool _progressIndeterminate; - double _progressMaxValue; - string _progressText; - double _progressValue; - bool _progressVisible; - bool _resumeFileFromImageVisible; - string _resumeFileText; - double _sectorsValue; - ImagePluginModel _selectedPlugin; - string _sourceText; - bool _startVisible; - bool _stopEnabled; - bool _stopVisible; - string _title; + [ObservableProperty] + Metadata _aaruMetadata; + [ObservableProperty] + bool _aaruMetadataFromImageVisible; + [ObservableProperty] + bool _cancel; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + string _commentsText; + [ObservableProperty] + bool _commentsVisible; + [ObservableProperty] + string _creatorText; + [ObservableProperty] + bool _creatorVisible; + [ObservableProperty] + bool _destinationEnabled; + [ObservableProperty] + string _destinationText; + [ObservableProperty] + bool _destinationVisible; + [ObservableProperty] + string _driveFirmwareRevisionText; + [ObservableProperty] + bool _driveFirmwareRevisionVisible; + [ObservableProperty] + string _driveManufacturerText; + [ObservableProperty] + bool _driveManufacturerVisible; + [ObservableProperty] + string _driveModelText; + [ObservableProperty] + bool _driveModelVisible; + [ObservableProperty] + string _driveSerialNumberText; + [ObservableProperty] + bool _driveSerialNumberVisible; + [ObservableProperty] + List _dumpHardware; + [ObservableProperty] + bool _forceChecked; + [ObservableProperty] + bool _formatReadOnly; + [ObservableProperty] + double _lastMediaSequenceValue; + [ObservableProperty] + bool _lastMediaSequenceVisible; + [ObservableProperty] + string _mediaBarcodeText; + [ObservableProperty] + bool _mediaBarcodeVisible; + [ObservableProperty] + string _mediaManufacturerText; + [ObservableProperty] + bool _mediaManufacturerVisible; + [ObservableProperty] + string _mediaModelText; + [ObservableProperty] + bool _mediaModelVisible; + [ObservableProperty] + string _mediaPartNumberText; + [ObservableProperty] + bool _mediaPartNumberVisible; + [ObservableProperty] + double _mediaSequenceValue; + [ObservableProperty] + bool _mediaSequenceVisible; + [ObservableProperty] + string _mediaSerialNumberText; + [ObservableProperty] + bool _mediaSerialNumberVisible; + [ObservableProperty] + string _mediaTitleText; + [ObservableProperty] + bool _mediaTitleVisible; + [ObservableProperty] + string _metadataJsonText; + [ObservableProperty] + bool _optionsVisible; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + bool _progress2Indeterminate; + [ObservableProperty] + double _progress2MaxValue; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMaxValue; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + bool _resumeFileFromImageVisible; + [ObservableProperty] + string _resumeFileText; + [ObservableProperty] + double _sectorsValue; + [ObservableProperty] + ImagePluginModel _selectedPlugin; + [ObservableProperty] + string _sourceText; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + bool _stopEnabled; + [ObservableProperty] + bool _stopVisible; + [ObservableProperty] + string _title; public ImageConvertViewModel([JetBrains.Annotations.NotNull] IMediaImage inputFormat, string imageSource, Window view) @@ -137,28 +198,28 @@ public sealed class ImageConvertViewModel : ViewModelBase _view = view; _inputFormat = inputFormat; _cancel = false; - DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand); - CreatorCommand = ReactiveCommand.Create(ExecuteCreatorCommand); - MediaTitleCommand = ReactiveCommand.Create(ExecuteMediaTitleCommand); - MediaManufacturerCommand = ReactiveCommand.Create(ExecuteMediaManufacturerCommand); - MediaModelCommand = ReactiveCommand.Create(ExecuteMediaModelCommand); - MediaSerialNumberCommand = ReactiveCommand.Create(ExecuteMediaSerialNumberCommand); - MediaBarcodeCommand = ReactiveCommand.Create(ExecuteMediaBarcodeCommand); - MediaPartNumberCommand = ReactiveCommand.Create(ExecuteMediaPartNumberCommand); - MediaSequenceCommand = ReactiveCommand.Create(ExecuteMediaSequenceCommand); - LastMediaSequenceCommand = ReactiveCommand.Create(ExecuteLastMediaSequenceCommand); - DriveManufacturerCommand = ReactiveCommand.Create(ExecuteDriveManufacturerCommand); - DriveModelCommand = ReactiveCommand.Create(ExecuteDriveModelCommand); - DriveSerialNumberCommand = ReactiveCommand.Create(ExecuteDriveSerialNumberCommand); - DriveFirmwareRevisionCommand = ReactiveCommand.Create(ExecuteDriveFirmwareRevisionCommand); - CommentsCommand = ReactiveCommand.Create(ExecuteCommentsCommand); - AaruMetadataFromImageCommand = ReactiveCommand.Create(ExecuteAaruMetadataFromImageCommand); - AaruMetadataCommand = ReactiveCommand.Create(ExecuteAaruMetadataCommand); - ResumeFileFromImageCommand = ReactiveCommand.Create(ExecuteResumeFileFromImageCommand); - ResumeFileCommand = ReactiveCommand.Create(ExecuteResumeFileCommand); - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + DestinationCommand = new AsyncRelayCommand(DestinationAsync); + CreatorCommand = new RelayCommand(Creator); + MediaTitleCommand = new RelayCommand(MediaTitle); + MediaManufacturerCommand = new RelayCommand(MediaManufacturer); + MediaModelCommand = new RelayCommand(MediaModel); + MediaSerialNumberCommand = new RelayCommand(MediaSerialNumber); + MediaBarcodeCommand = new RelayCommand(MediaBarcode); + MediaPartNumberCommand = new RelayCommand(MediaPartNumber); + MediaSequenceCommand = new RelayCommand(MediaSequence); + LastMediaSequenceCommand = new RelayCommand(LastMediaSequence); + DriveManufacturerCommand = new RelayCommand(DriveManufacturer); + DriveModelCommand = new RelayCommand(DriveModel); + DriveSerialNumberCommand = new RelayCommand(DriveSerialNumber); + DriveFirmwareRevisionCommand = new RelayCommand(DriveFirmwareRevision); + CommentsCommand = new RelayCommand(Comments); + AaruMetadataFromImageCommand = new RelayCommand(AaruMetadataFromImage); + AaruMetadataCommand = new AsyncRelayCommand(AaruMetadataAsync); + ResumeFileFromImageCommand = new RelayCommand(ResumeFileFromImage); + ResumeFileCommand = new AsyncRelayCommand(ResumeFileAsync); + StartCommand = new AsyncRelayCommand(StartAsync); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); SourceText = imageSource; CreatorVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.Creator); MediaTitleVisible = !string.IsNullOrWhiteSpace(inputFormat.Info.MediaTitle); @@ -200,401 +261,58 @@ public sealed class ImageConvertViewModel : ViewModelBase ResumeFileText = _dumpHardware == null ? "" : UI._From_image_; } - public string SourceImageLabel => UI.Source_image; - public string OutputFormatLabel => UI.Output_format; - public string ChooseLabel => UI.ButtonLabel_Choose; - public string SectorsLabel => UI.How_many_sectors_to_convert_at_once; - public string ForceLabel => UI.Continue_conversion_even_if_data_lost; - public string CreatorLabel => UI.Who_person_created_the_image; - public string GetFromSourceImageLabel => UI.ButtonLabel_Get_from_source_image; - public string MetadataLabel => UI.Title_Metadata; - public string MediaLabel => UI.Title_Media; - public string TitleLabel => UI.Title_Title; - public string ManufacturerLabel => UI.Title_Manufacturer; - public string ModelLabel => UI.Title_Model; - public string SerialNumberLabel => UI.Title_Serial_number; - public string BarcodeLabel => UI.Title_Barcode; - public string PartNumberLabel => UI.Title_Part_number; - public string NumberInSequenceLabel => UI.Title_Number_in_sequence; - public string LastMediaOfTheSequenceLabel => UI.Title_Last_media_of_the_sequence; - public string DriveLabel => UI.Title_Drive; - public string FirmwareRevisionLabel => UI.Title_Firmware_revision; - public string CommentsLabel => UI.Title_Comments; - public string AaruMetadataLabel => UI.Title_Existing_Aaru_Metadata_sidecar; - public string FromImageLabel => UI.Title_From_image; - public string ResumeFileLabel => UI.Title_Existing_resume_file; - public string StartLabel => UI.ButtonLabel_Start; - public string CloseLabel => UI.ButtonLabel_Close; - public string StopLabel => UI.ButtonLabel_Stop; - - public string Title - { - get => _title; - set => this.RaiseAndSetIfChanged(ref _title, value); - } - - public string SourceText - { - get => _sourceText; - set => this.RaiseAndSetIfChanged(ref _sourceText, value); - } - + public string SourceImageLabel => UI.Source_image; + public string OutputFormatLabel => UI.Output_format; + public string ChooseLabel => UI.ButtonLabel_Choose; + public string SectorsLabel => UI.How_many_sectors_to_convert_at_once; + public string ForceLabel => UI.Continue_conversion_even_if_data_lost; + public string CreatorLabel => UI.Who_person_created_the_image; + public string GetFromSourceImageLabel => UI.ButtonLabel_Get_from_source_image; + public string MetadataLabel => UI.Title_Metadata; + public string MediaLabel => UI.Title_Media; + public string TitleLabel => UI.Title_Title; + public string ManufacturerLabel => UI.Title_Manufacturer; + public string ModelLabel => UI.Title_Model; + public string SerialNumberLabel => UI.Title_Serial_number; + public string BarcodeLabel => UI.Title_Barcode; + public string PartNumberLabel => UI.Title_Part_number; + public string NumberInSequenceLabel => UI.Title_Number_in_sequence; + public string LastMediaOfTheSequenceLabel => UI.Title_Last_media_of_the_sequence; + public string DriveLabel => UI.Title_Drive; + public string FirmwareRevisionLabel => UI.Title_Firmware_revision; + public string CommentsLabel => UI.Title_Comments; + public string AaruMetadataLabel => UI.Title_Existing_Aaru_Metadata_sidecar; + public string FromImageLabel => UI.Title_From_image; + public string ResumeFileLabel => UI.Title_Existing_resume_file; + public string StartLabel => UI.ButtonLabel_Start; + public string CloseLabel => UI.ButtonLabel_Close; + public string StopLabel => UI.ButtonLabel_Stop; public ObservableCollection PluginsList { get; } - public ImagePluginModel SelectedPlugin - { - get => _selectedPlugin; - set => this.RaiseAndSetIfChanged(ref _selectedPlugin, value); - } + public ICommand DestinationCommand { get; } + public ICommand CreatorCommand { get; } + public ICommand MediaTitleCommand { get; } + public ICommand MediaManufacturerCommand { get; } + public ICommand MediaModelCommand { get; } + public ICommand MediaSerialNumberCommand { get; } + public ICommand MediaBarcodeCommand { get; } + public ICommand MediaPartNumberCommand { get; } + public ICommand MediaSequenceCommand { get; } + public ICommand LastMediaSequenceCommand { get; } + public ICommand DriveManufacturerCommand { get; } + public ICommand DriveModelCommand { get; } + public ICommand DriveSerialNumberCommand { get; } + public ICommand DriveFirmwareRevisionCommand { get; } + public ICommand CommentsCommand { get; } + public ICommand AaruMetadataFromImageCommand { get; } + public ICommand AaruMetadataCommand { get; } + public ICommand ResumeFileFromImageCommand { get; } + public ICommand ResumeFileCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } - public string DestinationText - { - get => _destinationText; - set => this.RaiseAndSetIfChanged(ref _destinationText, value); - } - - public bool OptionsVisible - { - get => _optionsVisible; - set => this.RaiseAndSetIfChanged(ref _optionsVisible, value); - } - - public double SectorsValue - { - get => _sectorsValue; - set => this.RaiseAndSetIfChanged(ref _sectorsValue, value); - } - - public bool ForceChecked - { - get => _forceChecked; - set => this.RaiseAndSetIfChanged(ref _forceChecked, value); - } - - public string CreatorText - { - get => _creatorText; - set => this.RaiseAndSetIfChanged(ref _creatorText, value); - } - - public string MediaTitleText - { - get => _mediaTitleText; - set => this.RaiseAndSetIfChanged(ref _mediaTitleText, value); - } - - public string MediaManufacturerText - { - get => _mediaManufacturerText; - set => this.RaiseAndSetIfChanged(ref _mediaManufacturerText, value); - } - - public string MediaModelText - { - get => _mediaModelText; - set => this.RaiseAndSetIfChanged(ref _mediaModelText, value); - } - - public string MediaSerialNumberText - { - get => _mediaSerialNumberText; - set => this.RaiseAndSetIfChanged(ref _mediaSerialNumberText, value); - } - - public string MediaBarcodeText - { - get => _mediaBarcodeText; - set => this.RaiseAndSetIfChanged(ref _mediaBarcodeText, value); - } - - public string MediaPartNumberText - { - get => _mediaPartNumberText; - set => this.RaiseAndSetIfChanged(ref _mediaPartNumberText, value); - } - - public double MediaSequenceValue - { - get => _mediaSequenceValue; - set => this.RaiseAndSetIfChanged(ref _mediaSequenceValue, value); - } - - public double LastMediaSequenceValue - { - get => _lastMediaSequenceValue; - set => this.RaiseAndSetIfChanged(ref _lastMediaSequenceValue, value); - } - - public string DriveManufacturerText - { - get => _driveManufacturerText; - set => this.RaiseAndSetIfChanged(ref _driveManufacturerText, value); - } - - public string DriveModelText - { - get => _driveModelText; - set => this.RaiseAndSetIfChanged(ref _driveModelText, value); - } - - public string DriveSerialNumberText - { - get => _driveSerialNumberText; - set => this.RaiseAndSetIfChanged(ref _driveSerialNumberText, value); - } - - public string DriveFirmwareRevisionText - { - get => _driveFirmwareRevisionText; - set => this.RaiseAndSetIfChanged(ref _driveFirmwareRevisionText, value); - } - - public string CommentsText - { - get => _commentsText; - set => this.RaiseAndSetIfChanged(ref _commentsText, value); - } - - public string MetadataJsonText - { - get => _metadataJsonText; - set => this.RaiseAndSetIfChanged(ref _metadataJsonText, value); - } - - public string ResumeFileText - { - get => _resumeFileText; - set => this.RaiseAndSetIfChanged(ref _resumeFileText, value); - } - - public bool ProgressVisible - { - get => _progressVisible; - set => this.RaiseAndSetIfChanged(ref _progressVisible, value); - } - - public bool Progress1Visible - { - get => _progress1Visible; - set => this.RaiseAndSetIfChanged(ref _progress1Visible, 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 ProgressMaxValue - { - get => _progressMaxValue; - set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value); - } - - public bool ProgressIndeterminate - { - get => _progressIndeterminate; - set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value); - } - - public bool Progress2Visible - { - get => _progress2Visible; - set => this.RaiseAndSetIfChanged(ref _progress2Visible, value); - } - - public string Progress2Text - { - get => _progress2Text; - set => this.RaiseAndSetIfChanged(ref _progress2Text, value); - } - - public double Progress2Value - { - get => _progress2Value; - set => this.RaiseAndSetIfChanged(ref _progress2Value, value); - } - - public double Progress2MaxValue - { - get => _progress2MaxValue; - set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value); - } - - public bool Progress2Indeterminate - { - get => _progress2Indeterminate; - set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, 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 StopVisible - { - get => _stopVisible; - set => this.RaiseAndSetIfChanged(ref _stopVisible, value); - } - - public bool StopEnabled - { - get => _stopEnabled; - set => this.RaiseAndSetIfChanged(ref _stopEnabled, value); - } - - public bool CreatorVisible - { - get => _creatorVisible; - set => this.RaiseAndSetIfChanged(ref _creatorVisible, value); - } - - public bool MediaTitleVisible - { - get => _mediaTitleVisible; - set => this.RaiseAndSetIfChanged(ref _mediaTitleVisible, value); - } - - public bool CommentsVisible - { - get => _commentsVisible; - set => this.RaiseAndSetIfChanged(ref _commentsVisible, value); - } - - public bool MediaManufacturerVisible - { - get => _mediaManufacturerVisible; - set => this.RaiseAndSetIfChanged(ref _mediaManufacturerVisible, value); - } - - public bool MediaModelVisible - { - get => _mediaModelVisible; - set => this.RaiseAndSetIfChanged(ref _mediaModelVisible, value); - } - - public bool MediaSerialNumberVisible - { - get => _mediaSerialNumberVisible; - set => this.RaiseAndSetIfChanged(ref _mediaSerialNumberVisible, value); - } - - public bool MediaBarcodeVisible - { - get => _mediaBarcodeVisible; - set => this.RaiseAndSetIfChanged(ref _mediaBarcodeVisible, value); - } - - public bool MediaPartNumberVisible - { - get => _mediaPartNumberVisible; - set => this.RaiseAndSetIfChanged(ref _mediaPartNumberVisible, value); - } - - public bool MediaSequenceVisible - { - get => _mediaSequenceVisible; - set => this.RaiseAndSetIfChanged(ref _mediaSequenceVisible, value); - } - - public bool LastMediaSequenceVisible - { - get => _lastMediaSequenceVisible; - set => this.RaiseAndSetIfChanged(ref _lastMediaSequenceVisible, value); - } - - public bool DriveManufacturerVisible - { - get => _driveManufacturerVisible; - set => this.RaiseAndSetIfChanged(ref _driveManufacturerVisible, value); - } - - public bool DriveModelVisible - { - get => _driveModelVisible; - set => this.RaiseAndSetIfChanged(ref _driveModelVisible, value); - } - - public bool DriveSerialNumberVisible - { - get => _driveSerialNumberVisible; - set => this.RaiseAndSetIfChanged(ref _driveSerialNumberVisible, value); - } - - public bool DriveFirmwareRevisionVisible - { - get => _driveFirmwareRevisionVisible; - set => this.RaiseAndSetIfChanged(ref _driveFirmwareRevisionVisible, value); - } - - public bool AaruMetadataFromImageVisible - { - get => _aaruMetadataFromImageVisible; - set => this.RaiseAndSetIfChanged(ref _aaruMetadataFromImageVisible, value); - } - - public bool ResumeFileFromImageVisible - { - get => _resumeFileFromImageVisible; - set => this.RaiseAndSetIfChanged(ref _resumeFileFromImageVisible, value); - } - - public bool DestinationEnabled - { - get => _destinationEnabled; - set => this.RaiseAndSetIfChanged(ref _destinationEnabled, value); - } - - public ReactiveCommand DestinationCommand { get; } - public ReactiveCommand CreatorCommand { get; } - public ReactiveCommand MediaTitleCommand { get; } - public ReactiveCommand MediaManufacturerCommand { get; } - public ReactiveCommand MediaModelCommand { get; } - public ReactiveCommand MediaSerialNumberCommand { get; } - public ReactiveCommand MediaBarcodeCommand { get; } - public ReactiveCommand MediaPartNumberCommand { get; } - public ReactiveCommand MediaSequenceCommand { get; } - public ReactiveCommand LastMediaSequenceCommand { get; } - public ReactiveCommand DriveManufacturerCommand { get; } - public ReactiveCommand DriveModelCommand { get; } - public ReactiveCommand DriveSerialNumberCommand { get; } - public ReactiveCommand DriveFirmwareRevisionCommand { get; } - public ReactiveCommand CommentsCommand { get; } - public ReactiveCommand AaruMetadataFromImageCommand { get; } - public ReactiveCommand AaruMetadataCommand { get; } - public ReactiveCommand ResumeFileFromImageCommand { get; } - public ReactiveCommand ResumeFileCommand { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } - - public bool FormatReadOnly - { - get => _formatReadOnly; - set => this.RaiseAndSetIfChanged(ref _formatReadOnly, value); - } - - public bool DestinationVisible - { - get => _destinationVisible; - set => this.RaiseAndSetIfChanged(ref _destinationVisible, value); - } - - async Task ExecuteStartCommand() + async Task StartAsync() { if(SelectedPlugin is null) { @@ -1894,9 +1612,9 @@ public sealed class ImageConvertViewModel : ViewModelBase Statistics.AddCommand("convert-image"); } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() + internal void Stop() { _cancel = true; StopEnabled = false; @@ -2036,7 +1754,7 @@ public sealed class ImageConvertViewModel : ViewModelBase grpOptions.Content = stkImageOptions; } */ - async Task ExecuteDestinationCommand() + async Task DestinationAsync() { if(SelectedPlugin is null) return; @@ -2065,41 +1783,41 @@ public sealed class ImageConvertViewModel : ViewModelBase DestinationText += SelectedPlugin.Plugin.KnownExtensions.First(); } - void ExecuteCreatorCommand() => CreatorText = _inputFormat.Info.Creator; + void Creator() => CreatorText = _inputFormat.Info.Creator; - void ExecuteMediaTitleCommand() => MediaTitleText = _inputFormat.Info.MediaTitle; + void MediaTitle() => MediaTitleText = _inputFormat.Info.MediaTitle; - void ExecuteCommentsCommand() => CommentsText = _inputFormat.Info.Comments; + void Comments() => CommentsText = _inputFormat.Info.Comments; - void ExecuteMediaManufacturerCommand() => MediaManufacturerText = _inputFormat.Info.MediaManufacturer; + void MediaManufacturer() => MediaManufacturerText = _inputFormat.Info.MediaManufacturer; - void ExecuteMediaModelCommand() => MediaModelText = _inputFormat.Info.MediaModel; + void MediaModel() => MediaModelText = _inputFormat.Info.MediaModel; - void ExecuteMediaSerialNumberCommand() => MediaSerialNumberText = _inputFormat.Info.MediaSerialNumber; + void MediaSerialNumber() => MediaSerialNumberText = _inputFormat.Info.MediaSerialNumber; - void ExecuteMediaBarcodeCommand() => MediaBarcodeText = _inputFormat.Info.MediaBarcode; + void MediaBarcode() => MediaBarcodeText = _inputFormat.Info.MediaBarcode; - void ExecuteMediaPartNumberCommand() => MediaPartNumberText = _inputFormat.Info.MediaPartNumber; + void MediaPartNumber() => MediaPartNumberText = _inputFormat.Info.MediaPartNumber; - void ExecuteMediaSequenceCommand() => MediaSequenceValue = _inputFormat.Info.MediaSequence; + void MediaSequence() => MediaSequenceValue = _inputFormat.Info.MediaSequence; - void ExecuteLastMediaSequenceCommand() => LastMediaSequenceValue = _inputFormat.Info.LastMediaSequence; + void LastMediaSequence() => LastMediaSequenceValue = _inputFormat.Info.LastMediaSequence; - void ExecuteDriveManufacturerCommand() => DriveManufacturerText = _inputFormat.Info.DriveManufacturer; + void DriveManufacturer() => DriveManufacturerText = _inputFormat.Info.DriveManufacturer; - void ExecuteDriveModelCommand() => DriveModelText = _inputFormat.Info.DriveModel; + void DriveModel() => DriveModelText = _inputFormat.Info.DriveModel; - void ExecuteDriveSerialNumberCommand() => DriveSerialNumberText = _inputFormat.Info.DriveSerialNumber; + void DriveSerialNumber() => DriveSerialNumberText = _inputFormat.Info.DriveSerialNumber; - void ExecuteDriveFirmwareRevisionCommand() => DriveFirmwareRevisionText = _inputFormat.Info.DriveFirmwareRevision; + void DriveFirmwareRevision() => DriveFirmwareRevisionText = _inputFormat.Info.DriveFirmwareRevision; - void ExecuteAaruMetadataFromImageCommand() + void AaruMetadataFromImage() { MetadataJsonText = UI._From_image_; _aaruMetadata = _inputFormat.AaruMetadata; } - async Task ExecuteAaruMetadataCommand() + async Task AaruMetadataAsync() { _aaruMetadata = null; MetadataJsonText = ""; @@ -2138,13 +1856,13 @@ public sealed class ImageConvertViewModel : ViewModelBase } } - void ExecuteResumeFileFromImageCommand() + void ResumeFileFromImage() { ResumeFileText = UI._From_image_; _dumpHardware = _inputFormat.DumpHardware; } - async Task ExecuteResumeFileCommand() + async Task ResumeFileAsync() { _dumpHardware = null; ResumeFileText = ""; diff --git a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs index cdd983a5a..4d712318b 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageEntropyViewModel.cs @@ -34,8 +34,8 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; -using System.Reactive; using System.Threading; +using System.Windows.Input; using Aaru.CommonTypes.Interfaces; using Aaru.Core; using Aaru.Gui.Models; @@ -43,53 +43,84 @@ using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Threading; -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; namespace Aaru.Gui.ViewModels.Windows; -public sealed class ImageEntropyViewModel : ViewModelBase +public sealed partial 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; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + bool _duplicatedSectorsChecked; + [ObservableProperty] + bool _duplicatedSectorsEnabled; + [ObservableProperty] + EntropyResults _entropy; + [ObservableProperty] + string _mediaEntropyText; + [ObservableProperty] + bool _mediaEntropyVisible; + [ObservableProperty] + string _mediaUniqueSectorsText; + [ObservableProperty] + bool _mediaUniqueSectorsVisible; + [ObservableProperty] + bool _optionsVisible; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + bool _progress2Indeterminate; + [ObservableProperty] + double _progress2Max; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMax; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + bool _resultsVisible; + [ObservableProperty] + bool _separatedTracksChecked; + [ObservableProperty] + bool _separatedTracksEnabled; + [ObservableProperty] + bool _separatedTracksVisible; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + bool _stopVisible; + [ObservableProperty] + EntropyResults[] _tracksEntropy; + [ObservableProperty] + bool _wholeDiscChecked; + [ObservableProperty] + bool _wholeDiscEnabled; + [ObservableProperty] + bool _wholeDiscVisible; public ImageEntropyViewModel(IMediaImage inputFormat, Window view) { _inputFormat = inputFormat; _view = view; TrackEntropy = []; - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); OptionsVisible = true; DuplicatedSectorsChecked = true; SeparatedTracksChecked = true; @@ -121,183 +152,15 @@ public sealed class ImageEntropyViewModel : ViewModelBase public string CloseLabel => UI.ButtonLabel_Close; public string StopLabel => UI.ButtonLabel_Stop; - public bool SeparatedTracksVisible - { - 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); - } - [JetBrains.Annotations.NotNull] public string Title => UI.Title_Calculating_entropy; public ObservableCollection TrackEntropy { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } - void ExecuteStartCommand() + void Start() { var entropyCalculator = new Entropy(false, _inputFormat); entropyCalculator.InitProgressEvent += InitProgress; @@ -388,9 +251,9 @@ public sealed class ImageEntropyViewModel : ViewModelBase MediaUniqueSectorsVisible = true; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() => throw new NotImplementedException(); + internal void Stop() => throw new NotImplementedException(); void InitProgress() => Progress1Visible = true; diff --git a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs index 951d61603..6f91856f9 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageSidecarViewModel.cs @@ -34,11 +34,11 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Reactive; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes.AaruMetadata; using Aaru.CommonTypes.Interfaces; using Aaru.Core; @@ -47,37 +47,58 @@ using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; using Avalonia.Threading; -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; namespace Aaru.Gui.ViewModels.Windows; -public sealed class ImageSidecarViewModel : ViewModelBase +public sealed partial 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; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + bool _destinationEnabled; + [ObservableProperty] + string _destinationText; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + bool _progress2Indeterminate; + [ObservableProperty] + double _progress2MaxValue; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMaxValue; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + Sidecar _sidecarClass; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + string _statusText; + [ObservableProperty] + bool _statusVisible; + [ObservableProperty] + bool _stopEnabled; + [ObservableProperty] + bool _stopVisible; public ImageSidecarViewModel(IMediaImage inputFormat, string imageSource, Guid filterId, Encoding encoding, Window view) @@ -94,10 +115,10 @@ public sealed class ImageSidecarViewModel : ViewModelBase DestinationEnabled = true; StartVisible = true; CloseVisible = true; - DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand); - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + DestinationCommand = new AsyncRelayCommand(DestinationAsync); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); } public string DestinationFileLabel => UI.Title_Destination_file; @@ -106,127 +127,13 @@ public sealed class ImageSidecarViewModel : ViewModelBase public string CloseLabel => UI.ButtonLabel_Close; public string StopLabel => UI.ButtonLabel_Stop; - public string Title { get; } - public ReactiveCommand DestinationCommand { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } + public string Title { get; } + public ICommand DestinationCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand 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(); + void Start() => new Thread(DoWork).Start(); [SuppressMessage("ReSharper", "AsyncVoidMethod")] async void DoWork() @@ -313,16 +220,16 @@ public sealed class ImageSidecarViewModel : ViewModelBase [SuppressMessage("ReSharper", "AsyncVoidMethod")] async void UpdateStatus(string text) => await Dispatcher.UIThread.InvokeAsync(() => { StatusText = text; }); - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - void ExecuteStopCommand() + void Stop() { ProgressText = Localization.Core.Aborting; StopEnabled = false; _sidecarClass.Abort(); } - async Task ExecuteDestinationCommand() + async Task DestinationAsync() { IStorageFile result = await _view.StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions { diff --git a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs index d99860ade..ff0785bd8 100644 --- a/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ImageVerifyViewModel.cs @@ -35,8 +35,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; -using System.Reactive; using System.Threading; +using System.Windows.Input; using Aaru.CommonTypes.Interfaces; using Aaru.CommonTypes.Structs; using Aaru.Core; @@ -45,61 +45,99 @@ using Aaru.Localization; using Aaru.Logging; using Avalonia.Controls; using Avalonia.Threading; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Humanizer; using Humanizer.Localisation; -using ReactiveUI; using Sentry; namespace Aaru.Gui.ViewModels.Windows; -public sealed class ImageVerifyViewModel : ViewModelBase +public sealed partial class ImageVerifyViewModel : ViewModelBase { readonly IMediaImage _inputFormat; readonly Window _view; - bool _cancel; - bool _closeVisible; - string _imageResultText; - bool _imageResultVisible; - bool _optionsVisible; - bool _progress2Indeterminate; - double _progress2MaxValue; - string _progress2Text; - double _progress2Value; - bool _progress2Visible; - bool _progressIndeterminate; - double _progressMaxValue; - string _progressText; - double _progressValue; - bool _progressVisible; - bool _resultsVisible; - string _sectorErrorsText; - bool _sectorErrorsVisible; - string _sectorsErrorsAllText; - bool _sectorsErrorsAllVisible; - bool _sectorSummaryVisible; - string _sectorsUnknownAllText; - bool _sectorsUnknownAllVisible; - string _sectorsUnknownsText; - bool _sectorsUnknownsVisible; - bool _startVisible; - bool _stopEnabled; - bool _stopVisible; - string _totalSectorErrorsText; - string _totalSectorErrorsUnknownsText; - string _totalSectorsText; - string _totalSectorUnknownsText; - bool _verifyImageChecked; - bool _verifyImageEnabled; - bool _verifySectorsChecked; - bool _verifySectorsEnabled; - bool _verifySectorsVisible; + [ObservableProperty] + bool _cancel; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + string _imageResultText; + [ObservableProperty] + bool _imageResultVisible; + [ObservableProperty] + bool _optionsVisible; + [ObservableProperty] + bool _progress2Indeterminate; + [ObservableProperty] + double _progress2MaxValue; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMaxValue; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + bool _resultsVisible; + [ObservableProperty] + string _sectorErrorsText; + [ObservableProperty] + bool _sectorErrorsVisible; + [ObservableProperty] + string _sectorsErrorsAllText; + [ObservableProperty] + bool _sectorsErrorsAllVisible; + [ObservableProperty] + bool _sectorSummaryVisible; + [ObservableProperty] + string _sectorsUnknownAllText; + [ObservableProperty] + bool _sectorsUnknownAllVisible; + [ObservableProperty] + string _sectorsUnknownsText; + [ObservableProperty] + bool _sectorsUnknownsVisible; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + bool _stopEnabled; + [ObservableProperty] + bool _stopVisible; + [ObservableProperty] + string _totalSectorErrorsText; + [ObservableProperty] + string _totalSectorErrorsUnknownsText; + [ObservableProperty] + string _totalSectorsText; + [ObservableProperty] + string _totalSectorUnknownsText; + [ObservableProperty] + bool _verifyImageChecked; + [ObservableProperty] + bool _verifyImageEnabled; + [ObservableProperty] + bool _verifySectorsChecked; + [ObservableProperty] + bool _verifySectorsEnabled; + [ObservableProperty] + bool _verifySectorsVisible; public ImageVerifyViewModel(IMediaImage inputFormat, Window view) { _view = view; - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); _inputFormat = inputFormat; _cancel = false; ErrorList = []; @@ -120,227 +158,12 @@ public sealed class ImageVerifyViewModel : ViewModelBase public ObservableCollection ErrorList { get; } public ObservableCollection UnknownList { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } - public bool VerifyImageEnabled - { - get => _verifyImageEnabled; - set => this.RaiseAndSetIfChanged(ref _verifyImageEnabled, value); - } - public bool VerifySectorsEnabled - { - get => _verifySectorsEnabled; - set => this.RaiseAndSetIfChanged(ref _verifySectorsEnabled, value); - } - - public bool VerifySectorsVisible - { - get => _verifySectorsVisible; - set => this.RaiseAndSetIfChanged(ref _verifySectorsVisible, value); - } - - public double ProgressMaxValue - { - get => _progressMaxValue; - set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value); - } - - public bool VerifyImageChecked - { - get => _verifyImageChecked; - set => this.RaiseAndSetIfChanged(ref _verifyImageChecked, value); - } - - public bool ProgressIndeterminate - { - get => _progressIndeterminate; - set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value); - } - - public bool ImageResultVisible - { - get => _imageResultVisible; - set => this.RaiseAndSetIfChanged(ref _imageResultVisible, value); - } - - public string ImageResultText - { - get => _imageResultText; - set => this.RaiseAndSetIfChanged(ref _imageResultText, value); - } - - public bool VerifySectorsChecked - { - get => _verifySectorsChecked; - set => this.RaiseAndSetIfChanged(ref _verifySectorsChecked, 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 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 bool SectorsErrorsAllVisible - { - get => _sectorsErrorsAllVisible; - set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllVisible, value); - } - - public string SectorsErrorsAllText - { - get => _sectorsErrorsAllText; - set => this.RaiseAndSetIfChanged(ref _sectorsErrorsAllText, value); - } - - public bool SectorsUnknownAllVisible - { - get => _sectorsUnknownAllVisible; - set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllVisible, value); - } - - public string SectorsUnknownAllText - { - get => _sectorsUnknownAllText; - set => this.RaiseAndSetIfChanged(ref _sectorsUnknownAllText, value); - } - - public string SectorErrorsText - { - get => _sectorErrorsText; - set => this.RaiseAndSetIfChanged(ref _sectorErrorsText, value); - } - - public bool SectorErrorsVisible - { - get => _sectorErrorsVisible; - set => this.RaiseAndSetIfChanged(ref _sectorErrorsVisible, value); - } - - public bool SectorsUnknownsVisible - { - get => _sectorsUnknownsVisible; - set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsVisible, value); - } - - public string SectorsUnknownsText - { - get => _sectorsUnknownsText; - set => this.RaiseAndSetIfChanged(ref _sectorsUnknownsText, value); - } - - public bool SectorSummaryVisible - { - get => _sectorSummaryVisible; - set => this.RaiseAndSetIfChanged(ref _sectorSummaryVisible, value); - } - - public string TotalSectorsText - { - get => _totalSectorsText; - set => this.RaiseAndSetIfChanged(ref _totalSectorsText, value); - } - - public string TotalSectorErrorsText - { - get => _totalSectorErrorsText; - set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsText, value); - } - - public string TotalSectorUnknownsText - { - get => _totalSectorUnknownsText; - set => this.RaiseAndSetIfChanged(ref _totalSectorUnknownsText, value); - } - - public string TotalSectorErrorsUnknownsText - { - get => _totalSectorErrorsUnknownsText; - set => this.RaiseAndSetIfChanged(ref _totalSectorErrorsUnknownsText, value); - } - - public bool OptionsVisible - { - get => _optionsVisible; - set => this.RaiseAndSetIfChanged(ref _optionsVisible, value); - } - - public bool ResultsVisible - { - get => _resultsVisible; - set => this.RaiseAndSetIfChanged(ref _resultsVisible, value); - } - - public bool ProgressVisible - { - get => _progressVisible; - set => this.RaiseAndSetIfChanged(ref _progressVisible, 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 CloseVisible - { - get => _closeVisible; - set => this.RaiseAndSetIfChanged(ref _closeVisible, value); - } - - public bool StopEnabled - { - get => _stopEnabled; - set => this.RaiseAndSetIfChanged(ref _stopEnabled, value); - } - - void ExecuteStartCommand() + void Start() { VerifyImageEnabled = false; VerifySectorsEnabled = false; @@ -687,9 +510,9 @@ public sealed class ImageVerifyViewModel : ViewModelBase }); } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() + internal void Stop() { _cancel = true; StopEnabled = false; diff --git a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs index d4724fea4..42dbd4d82 100644 --- a/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MainWindowViewModel.cs @@ -35,8 +35,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; -using System.Reactive; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes; using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; @@ -60,10 +60,10 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Media.Imaging; using Avalonia.Platform; using Avalonia.Platform.Storage; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using Spectre.Console; using Console = Aaru.Gui.Views.Dialogs.Console; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; @@ -94,22 +94,22 @@ public sealed class MainWindowViewModel : ViewModelBase public MainWindowViewModel(MainWindow view) { - AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand); - EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand); - PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand); - StatisticsCommand = ReactiveCommand.Create(ExecuteStatisticsCommand); - ExitCommand = ReactiveCommand.Create(ExecuteExitCommand); - SettingsCommand = ReactiveCommand.Create(ExecuteSettingsCommand); - ConsoleCommand = ReactiveCommand.Create(ExecuteConsoleCommand); - OpenCommand = ReactiveCommand.Create(ExecuteOpenCommand); - CalculateEntropyCommand = ReactiveCommand.Create(ExecuteCalculateEntropyCommand); - VerifyImageCommand = ReactiveCommand.Create(ExecuteVerifyImageCommand); - ChecksumImageCommand = ReactiveCommand.Create(ExecuteChecksumImageCommand); - ConvertImageCommand = ReactiveCommand.Create(ExecuteConvertImageCommand); - CreateSidecarCommand = ReactiveCommand.Create(ExecuteCreateSidecarCommand); - ViewImageSectorsCommand = ReactiveCommand.Create(ExecuteViewImageSectorsCommand); - DecodeImageMediaTagsCommand = ReactiveCommand.Create(ExecuteDecodeImageMediaTagsCommand); - RefreshDevicesCommand = ReactiveCommand.Create(ExecuteRefreshDevicesCommand); + AboutCommand = new RelayCommand(About); + EncodingsCommand = new RelayCommand(Encodings); + PluginsCommand = new RelayCommand(Plugins); + StatisticsCommand = new RelayCommand(Statistics); + ExitCommand = new RelayCommand(Exit); + SettingsCommand = new AsyncRelayCommand(SettingsAsync); + ConsoleCommand = new RelayCommand(Console); + OpenCommand = new AsyncRelayCommand(OpenAsync); + CalculateEntropyCommand = new RelayCommand(CalculateEntropy); + VerifyImageCommand = new RelayCommand(VerifyImage); + ChecksumImageCommand = new RelayCommand(ChecksumImage); + ConvertImageCommand = new RelayCommand(ConvertImage); + CreateSidecarCommand = new RelayCommand(CreateSidecar); + ViewImageSectorsCommand = new RelayCommand(ViewImageSectors); + DecodeImageMediaTagsCommand = new RelayCommand(DecodeImageMediaTags); + RefreshDevicesCommand = new RelayCommand(RefreshDevices); _view = view; TreeRoot = []; ContentPanel = Greeting; @@ -190,7 +190,7 @@ public sealed class MainWindowViewModel : ViewModelBase public bool DevicesSupported { get => _devicesSupported; - set => this.RaiseAndSetIfChanged(ref _devicesSupported, value); + set => SetProperty(ref _devicesSupported, value); } public bool NativeMenuSupported @@ -208,27 +208,27 @@ public sealed class MainWindowViewModel : ViewModelBase public string Greeting => UI.Welcome_to_Aaru; public ObservableCollection TreeRoot { get; } - public ReactiveCommand AboutCommand { get; } - public ReactiveCommand ConsoleCommand { get; } - public ReactiveCommand EncodingsCommand { get; } - public ReactiveCommand PluginsCommand { get; } - public ReactiveCommand StatisticsCommand { get; } - public ReactiveCommand ExitCommand { get; } - public ReactiveCommand SettingsCommand { get; } - public ReactiveCommand OpenCommand { get; } - public ReactiveCommand CalculateEntropyCommand { get; } - public ReactiveCommand VerifyImageCommand { get; } - public ReactiveCommand ChecksumImageCommand { get; } - public ReactiveCommand ConvertImageCommand { get; } - public ReactiveCommand CreateSidecarCommand { get; } - public ReactiveCommand ViewImageSectorsCommand { get; } - public ReactiveCommand DecodeImageMediaTagsCommand { get; } - public ReactiveCommand RefreshDevicesCommand { get; } + public ICommand AboutCommand { get; } + public ICommand ConsoleCommand { get; } + public ICommand EncodingsCommand { get; } + public ICommand PluginsCommand { get; } + public ICommand StatisticsCommand { get; } + public ICommand ExitCommand { get; } + public ICommand SettingsCommand { get; } + public ICommand OpenCommand { get; } + public ICommand CalculateEntropyCommand { get; } + public ICommand VerifyImageCommand { get; } + public ICommand ChecksumImageCommand { get; } + public ICommand ConvertImageCommand { get; } + public ICommand CreateSidecarCommand { get; } + public ICommand ViewImageSectorsCommand { get; } + public ICommand DecodeImageMediaTagsCommand { get; } + public ICommand RefreshDevicesCommand { get; } public object ContentPanel { get => _contentPanel; - set => this.RaiseAndSetIfChanged(ref _contentPanel, value); + set => SetProperty(ref _contentPanel, value); } public object TreeViewSelectedItem @@ -238,7 +238,7 @@ public sealed class MainWindowViewModel : ViewModelBase { if(value == _treeViewSelectedItem) return; - this.RaiseAndSetIfChanged(ref _treeViewSelectedItem, value); + SetProperty(ref _treeViewSelectedItem, value); ContentPanel = null; @@ -285,11 +285,11 @@ public sealed class MainWindowViewModel : ViewModelBase return; case Devices.Remote.Device remoteDev: - Statistics.AddRemote(remoteDev.RemoteApplication, - remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, - remoteDev.RemoteOperatingSystemVersion, - remoteDev.RemoteArchitecture); + Core.Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, + remoteDev.RemoteOperatingSystemVersion, + remoteDev.RemoteArchitecture); break; } @@ -378,7 +378,7 @@ public sealed class MainWindowViewModel : ViewModelBase } } - void ExecuteCalculateEntropyCommand() + void CalculateEntropy() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -390,7 +390,7 @@ public sealed class MainWindowViewModel : ViewModelBase imageEntropyWindow.Show(); } - void ExecuteVerifyImageCommand() + void VerifyImage() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -402,7 +402,7 @@ public sealed class MainWindowViewModel : ViewModelBase imageVerifyWindow.Show(); } - void ExecuteChecksumImageCommand() + void ChecksumImage() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -414,7 +414,7 @@ public sealed class MainWindowViewModel : ViewModelBase imageChecksumWindow.Show(); } - void ExecuteConvertImageCommand() + void ConvertImage() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -428,7 +428,7 @@ public sealed class MainWindowViewModel : ViewModelBase imageConvertWindow.Show(); } - void ExecuteCreateSidecarCommand() + void CreateSidecar() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -445,7 +445,7 @@ public sealed class MainWindowViewModel : ViewModelBase imageSidecarWindow.Show(); } - void ExecuteViewImageSectorsCommand() + void ViewImageSectors() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -455,7 +455,7 @@ public sealed class MainWindowViewModel : ViewModelBase }.Show(); } - void ExecuteDecodeImageMediaTagsCommand() + void DecodeImageMediaTags() { if(TreeViewSelectedItem is not ImageModel imageModel) return; @@ -465,28 +465,28 @@ public sealed class MainWindowViewModel : ViewModelBase }.Show(); } - internal void ExecuteAboutCommand() + internal void About() { var dialog = new About(); dialog.DataContext = new AboutViewModel(dialog); dialog.ShowDialog(_view); } - void ExecuteEncodingsCommand() + void Encodings() { var dialog = new Encodings(); dialog.DataContext = new EncodingsViewModel(dialog); dialog.ShowDialog(_view); } - void ExecutePluginsCommand() + void Plugins() { var dialog = new PluginsDialog(); dialog.DataContext = new PluginsViewModel(dialog); dialog.ShowDialog(_view); } - void ExecuteStatisticsCommand() + void Statistics() { using var ctx = AaruContext.Create(Settings.Settings.LocalDbPath); @@ -509,17 +509,17 @@ public sealed class MainWindowViewModel : ViewModelBase dialog.ShowDialog(_view); } - internal async Task ExecuteSettingsCommand() + internal async Task SettingsAsync() { var dialog = new SettingsDialog(); dialog.DataContext = new SettingsViewModel(dialog, false); await dialog.ShowDialog(_view); } - internal void ExecuteExitCommand() => + internal void Exit() => (Application.Current?.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown(); - void ExecuteConsoleCommand() + void Console() { if(_console is null) { @@ -530,7 +530,7 @@ public sealed class MainWindowViewModel : ViewModelBase _console.Show(); } - async Task ExecuteOpenCommand() + async Task OpenAsync() { // TODO: Extensions IReadOnlyList result = await _view.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions @@ -698,10 +698,10 @@ public sealed class MainWindowViewModel : ViewModelBase Plugin = rofs }); - Statistics.AddCommand("ls"); + Core.Statistics.AddCommand("ls"); } - Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type); + Core.Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type); partitionModel.FileSystems.Add(filesystemModel); } } @@ -776,18 +776,18 @@ public sealed class MainWindowViewModel : ViewModelBase Plugin = rofs }); - Statistics.AddCommand("ls"); + Core.Statistics.AddCommand("ls"); } - Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type); + Core.Statistics.AddFilesystem(rofs?.Metadata.Type ?? fsMetadata.Type); imageModel.PartitionSchemesOrFileSystems.Add(filesystemModel); } } } - Statistics.AddMediaFormat(imageFormat.Format); - Statistics.AddMedia(imageFormat.Info.MediaType, false); - Statistics.AddFilter(inputFilter.Name); + Core.Statistics.AddMediaFormat(imageFormat.Format); + Core.Statistics.AddMedia(imageFormat.Info.MediaType, false); + Core.Statistics.AddFilter(inputFilter.Name); _imagesRoot.Images.Add(imageModel); } @@ -814,13 +814,11 @@ public sealed class MainWindowViewModel : ViewModelBase AaruLogging.Exception(ex, UI.Error_reading_file_0, ex.Message); } - Statistics.AddCommand("image-info"); + Core.Statistics.AddCommand("image-info"); } internal void LoadComplete() => RefreshDevices(); - void ExecuteRefreshDevicesCommand() => RefreshDevices(); - void RefreshDevices() { if(!DevicesSupported) return; @@ -855,11 +853,11 @@ public sealed class MainWindowViewModel : ViewModelBase { if(dev is Devices.Remote.Device remoteDev) { - Statistics.AddRemote(remoteDev.RemoteApplication, - remoteDev.RemoteVersion, - remoteDev.RemoteOperatingSystem, - remoteDev.RemoteOperatingSystemVersion, - remoteDev.RemoteArchitecture); + Core.Statistics.AddRemote(remoteDev.RemoteApplication, + remoteDev.RemoteVersion, + remoteDev.RemoteOperatingSystem, + remoteDev.RemoteOperatingSystemVersion, + remoteDev.RemoteArchitecture); } deviceModel.Icon = dev.Type switch diff --git a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs index 53ef48e7e..8dc491e22 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaDumpViewModel.cs @@ -36,11 +36,11 @@ using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; -using System.Reactive; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using System.Windows.Input; using System.Xml.Serialization; using Aaru.CommonTypes; using Aaru.CommonTypes.AaruMetadata; @@ -58,11 +58,11 @@ using Aaru.Logging; using Avalonia.Controls; using Avalonia.Platform.Storage; using Avalonia.Threading; -using DynamicData; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using JetBrains.Annotations; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; using Sentry; using DeviceInfo = Aaru.Core.Devices.Info.DeviceInfo; using Dump = Aaru.Core.Devices.Dumping.Dump; @@ -71,50 +71,86 @@ using MediaType = Aaru.CommonTypes.MediaType; namespace Aaru.Gui.ViewModels.Windows; -public sealed class MediaDumpViewModel : ViewModelBase +public sealed partial class MediaDumpViewModel : ViewModelBase { - readonly string _devicePath; - readonly Window _view; - bool _closeVisible; - string _destination; - bool _destinationEnabled; - Device _dev; - Dump _dumper; - string _encodingEnabled; - bool _encodingVisible; - bool _existingMetadata; - bool _force; - string _formatReadOnly; - string _log; - bool _optionsVisible; - string _outputPrefix; - bool _persistent; - bool _progress1Visible; - bool _progress2Indeterminate; - double _progress2MaxValue; - string _progress2Text; - double _progress2Value; - bool _progress2Visible; - bool _progressIndeterminate; - double _progressMaxValue; - string _progressText; - double _progressValue; - bool _progressVisible; - Resume _resume; - double _retries; - EncodingModel _selectedEncoding; + readonly string _devicePath; + readonly Window _view; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + string _destination; + [ObservableProperty] + bool _destinationEnabled; + [ObservableProperty] + Device _dev; + [ObservableProperty] + Dump _dumper; + [ObservableProperty] + string _encodingEnabled; + [ObservableProperty] + bool _encodingVisible; + bool _existingMetadata; + [ObservableProperty] + bool _force; + [ObservableProperty] + string _formatReadOnly; + [ObservableProperty] + string _log; + [ObservableProperty] + bool _optionsVisible; + [ObservableProperty] + string _outputPrefix; + [ObservableProperty] + bool _persistent; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + bool _progress2Indeterminate; + [ObservableProperty] + double _progress2MaxValue; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + double _progress2Value; + [ObservableProperty] + bool _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMaxValue; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + Resume _resume; + [ObservableProperty] + double _retries; + [ObservableProperty] + EncodingModel _selectedEncoding; ImagePluginModel _selectedPlugin; - Metadata _sidecar; - double _skipped; - bool _startVisible; - bool _stopEnabled; - bool _stopOnError; - bool _stopVisible; - bool _track1Pregap; - bool _track1PregapVisible; - bool _trim; - bool _useResume; - bool _useSidecar; + [ObservableProperty] + Metadata _sidecar; + [ObservableProperty] + double _skipped; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + bool _stopEnabled; + [ObservableProperty] + bool _stopOnError; + [ObservableProperty] + bool _stopVisible; + [ObservableProperty] + bool _track1Pregap; + [ObservableProperty] + bool _track1PregapVisible; + [ObservableProperty] + bool _trim; + bool _useResume; + [ObservableProperty] + bool _useSidecar; public MediaDumpViewModel(string devicePath, DeviceInfo deviceInfo, Window view, [CanBeNull] ScsiInfo scsiInfo = null) @@ -124,10 +160,10 @@ public sealed class MediaDumpViewModel : ViewModelBase StartVisible = true; CloseVisible = true; OptionsVisible = true; - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); - DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); + DestinationCommand = new AsyncRelayCommand(DestinationAsync); PluginsList = []; Encodings = []; @@ -137,7 +173,7 @@ public sealed class MediaDumpViewModel : ViewModelBase Persistent = true; Resume = true; Track1Pregap = false; - Sidecar = true; + UseSidecar = true; Trim = true; ExistingMetadata = false; Retries = 5; @@ -186,19 +222,21 @@ public sealed class MediaDumpViewModel : ViewModelBase } } - Encodings.AddRange(Encoding.GetEncodings() - .Select(info => new EncodingModel - { - Name = info.Name, - DisplayName = info.GetEncoding().EncodingName - })); - - Encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings() - .Select(info => new EncodingModel - { - Name = info.Name, - DisplayName = info.DisplayName - })); + foreach(EncodingModel model in Encoding.GetEncodings() + .Select(info => new EncodingModel + { + Name = info.Name, + DisplayName = info.GetEncoding().EncodingName + }) + .Concat(Claunia.Encoding.Encoding.GetEncodings() + .Select(info => new EncodingModel + { + Name = info.Name, + DisplayName = info.DisplayName + })) + .AsParallel() + .OrderBy(m => m.DisplayName)) + Encodings.Add(model); Track1PregapVisible = mediaType switch { @@ -270,28 +308,22 @@ public sealed class MediaDumpViewModel : ViewModelBase public string CloseLabel => UI.ButtonLabel_Close; public string StopLabel => UI.ButtonLabel_Stop; - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } - public ReactiveCommand DestinationCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } + public ICommand DestinationCommand { get; } public ObservableCollection PluginsList { get; } public ObservableCollection Encodings { get; } public string Title { get; } - public bool OptionsVisible - { - get => _optionsVisible; - set => this.RaiseAndSetIfChanged(ref _optionsVisible, value); - } - public ImagePluginModel SelectedPlugin { get => _selectedPlugin; set { - this.RaiseAndSetIfChanged(ref _selectedPlugin, value); + SetProperty(ref _selectedPlugin, value); Destination = ""; @@ -399,107 +431,27 @@ public sealed class MediaDumpViewModel : ViewModelBase } } - public string FormatReadOnly - { - get => _formatReadOnly; - set => this.RaiseAndSetIfChanged(ref _formatReadOnly, value); - } - - public string Destination - { - get => _destination; - set => this.RaiseAndSetIfChanged(ref _destination, value); - } - - public bool DestinationEnabled - { - get => _destinationEnabled; - set => this.RaiseAndSetIfChanged(ref _destinationEnabled, value); - } - - public bool StopOnError - { - get => _stopOnError; - set => this.RaiseAndSetIfChanged(ref _stopOnError, value); - } - - public bool Force - { - get => _force; - set => this.RaiseAndSetIfChanged(ref _force, value); - } - - public double Retries - { - get => _retries; - set => this.RaiseAndSetIfChanged(ref _retries, value); - } - - public bool Persistent - { - get => _persistent; - set => this.RaiseAndSetIfChanged(ref _persistent, value); - } public bool Resume { get => _useResume; set { - this.RaiseAndSetIfChanged(ref _useResume, value); + SetProperty(ref _useResume, value); if(!value) return; - if(_outputPrefix != null) CheckResumeFile().GetAwaiter().GetResult(); + if(_outputPrefix != null) CheckResumeFileAsync().GetAwaiter().GetResult(); } } - public bool Track1Pregap - { - get => _track1Pregap; - set => this.RaiseAndSetIfChanged(ref _track1Pregap, value); - } - - public bool Track1PregapVisible - { - get => _track1PregapVisible; - set => this.RaiseAndSetIfChanged(ref _track1PregapVisible, value); - } - - public double Skipped - { - get => _skipped; - set => this.RaiseAndSetIfChanged(ref _skipped, value); - } - - public bool Sidecar - { - get => _useSidecar; - set - { - this.RaiseAndSetIfChanged(ref _useSidecar, value); - EncodingVisible = value; - } - } - - public bool EncodingVisible - { - get => _encodingVisible; - set => this.RaiseAndSetIfChanged(ref _encodingVisible, value); - } - - public bool Trim - { - get => _trim; - set => this.RaiseAndSetIfChanged(ref _trim, value); - } public bool ExistingMetadata { get => _existingMetadata; set { - this.RaiseAndSetIfChanged(ref _existingMetadata, value); + SetProperty(ref _existingMetadata, value); if(!value) { @@ -553,115 +505,7 @@ public sealed class MediaDumpViewModel : ViewModelBase } } - public EncodingModel SelectedEncoding - { - get => _selectedEncoding; - set => this.RaiseAndSetIfChanged(ref _selectedEncoding, value); - } - - public string EncodingEnabled - { - get => _encodingEnabled; - set => this.RaiseAndSetIfChanged(ref _encodingEnabled, value); - } - - public bool ProgressVisible - { - get => _progressVisible; - set => this.RaiseAndSetIfChanged(ref _progressVisible, value); - } - - public string Log - { - get => _log; - set => this.RaiseAndSetIfChanged(ref _log, value); - } - - public bool Progress1Visible - { - get => _progress1Visible; - set => this.RaiseAndSetIfChanged(ref _progress1Visible, 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 ProgressMaxValue - { - get => _progressMaxValue; - set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value); - } - - public bool ProgressIndeterminate - { - get => _progressIndeterminate; - set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value); - } - - public bool Progress2Visible - { - get => _progress2Visible; - set => this.RaiseAndSetIfChanged(ref _progress2Visible, value); - } - - public string Progress2Text - { - get => _progress2Text; - set => this.RaiseAndSetIfChanged(ref _progress2Text, value); - } - - public double Progress2Value - { - get => _progress2Value; - set => this.RaiseAndSetIfChanged(ref _progress2Value, value); - } - - public double Progress2MaxValue - { - get => _progress2MaxValue; - set => this.RaiseAndSetIfChanged(ref _progress2MaxValue, value); - } - - public bool Progress2Indeterminate - { - get => _progress2Indeterminate; - set => this.RaiseAndSetIfChanged(ref _progress2Indeterminate, 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 StopVisible - { - get => _stopVisible; - set => this.RaiseAndSetIfChanged(ref _stopVisible, value); - } - - public bool StopEnabled - { - get => _stopEnabled; - set => this.RaiseAndSetIfChanged(ref _stopEnabled, value); - } - - async Task ExecuteDestinationCommand() + async Task DestinationAsync() { if(SelectedPlugin is null) return; @@ -696,7 +540,7 @@ public sealed class MediaDumpViewModel : ViewModelBase Resume = true; } - async Task CheckResumeFile() + async Task CheckResumeFileAsync() { _resume = null; @@ -760,15 +604,15 @@ public sealed class MediaDumpViewModel : ViewModelBase Resume = false; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() + internal void Stop() { StopEnabled = false; _dumper?.Abort(); } - void ExecuteStartCommand() + void Start() { Log = ""; CloseVisible = false; @@ -929,10 +773,10 @@ public sealed class MediaDumpViewModel : ViewModelBase _dev.Close(); - await WorkFinished(); + await WorkFinishedAsync(); } - async Task WorkFinished() => await Dispatcher.UIThread.InvokeAsync(() => + async Task WorkFinishedAsync() => await Dispatcher.UIThread.InvokeAsync(() => { CloseVisible = true; StopVisible = false; @@ -987,7 +831,7 @@ public sealed class MediaDumpViewModel : ViewModelBase await MessageBoxManager.GetMessageBoxStandard(UI.Title_Error, $"{text}", ButtonEnum.Ok, Icon.Error) .ShowWindowDialogAsync(_view); - await WorkFinished(); + await WorkFinishedAsync(); }); [SuppressMessage("ReSharper", "AsyncVoidMethod")] diff --git a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs index 2ebcd74f1..0046a1691 100644 --- a/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/MediaScanViewModel.cs @@ -32,9 +32,9 @@ using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; -using System.Reactive; using System.Threading; using System.Threading.Tasks; +using System.Windows.Input; using Aaru.CommonTypes.Enums; using Aaru.Core; using Aaru.Core.Devices.Scanning; @@ -43,69 +43,110 @@ using Aaru.Localization; using Avalonia.Controls; using Avalonia.Media; using Avalonia.Threading; +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; using Humanizer; using Humanizer.Bytes; using Humanizer.Localisation; using MsBox.Avalonia; using MsBox.Avalonia.Enums; -using ReactiveUI; //using OxyPlot; namespace Aaru.Gui.ViewModels.Windows; -public sealed class MediaScanViewModel : ViewModelBase +public sealed partial class MediaScanViewModel : ViewModelBase { readonly Window _view; - string _a; - string _avgSpeed; - Color _axesColor; - string _b; - ulong _blocks; - ulong _blocksToRead; - string _c; - bool _closeVisible; - string _d; - string _devicePath; - string _e; - string _f; - Color _lineColor; - ScanResults _localResults; - string _maxSpeed; - double _maxX; - double _maxY; - string _minSpeed; - double _minX; - double _minY; - bool _progress1Visible; - string _progress2Indeterminate; - string _progress2MaxValue; - string _progress2Text; - string _progress2Value; - string _progress2Visible; - bool _progressIndeterminate; - double _progressMaxValue; - string _progressText; - double _progressValue; - bool _progressVisible; - bool _resultsVisible; - MediaScan _scanner; - bool _startVisible; - double _stepsX; - double _stepsY; - string _stopEnabled; - bool _stopVisible; - string _totalTime; - string _unreadableSectors; + [ObservableProperty] + string _a; + [ObservableProperty] + string _avgSpeed; + [ObservableProperty] + Color _axesColor; + [ObservableProperty] + string _b; + [ObservableProperty] + ulong _blocks; + [ObservableProperty] + ulong _blocksToRead; + [ObservableProperty] + string _c; + [ObservableProperty] + bool _closeVisible; + [ObservableProperty] + string _d; + [ObservableProperty] + string _devicePath; + [ObservableProperty] + string _e; + [ObservableProperty] + string _f; + [ObservableProperty] + Color _lineColor; + [ObservableProperty] + ScanResults _localResults; + [ObservableProperty] + string _maxSpeed; + [ObservableProperty] + double _maxX; + [ObservableProperty] + double _maxY; + [ObservableProperty] + string _minSpeed; + [ObservableProperty] + double _minX; + [ObservableProperty] + double _minY; + [ObservableProperty] + bool _progress1Visible; + [ObservableProperty] + string _progress2Indeterminate; + [ObservableProperty] + string _progress2MaxValue; + [ObservableProperty] + string _progress2Text; + [ObservableProperty] + string _progress2Value; + [ObservableProperty] + string _progress2Visible; + [ObservableProperty] + bool _progressIndeterminate; + [ObservableProperty] + double _progressMaxValue; + [ObservableProperty] + string _progressText; + [ObservableProperty] + double _progressValue; + [ObservableProperty] + bool _progressVisible; + [ObservableProperty] + bool _resultsVisible; + [ObservableProperty] + MediaScan _scanner; + [ObservableProperty] + bool _startVisible; + [ObservableProperty] + double _stepsX; + [ObservableProperty] + double _stepsY; + [ObservableProperty] + string _stopEnabled; + [ObservableProperty] + bool _stopVisible; + [ObservableProperty] + string _totalTime; + [ObservableProperty] + string _unreadableSectors; public MediaScanViewModel(string devicePath, Window view) { _devicePath = devicePath; _view = view; StopVisible = false; - StartCommand = ReactiveCommand.Create(ExecuteStartCommand); - CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand); - StopCommand = ReactiveCommand.Create(ExecuteStopCommand); + StartCommand = new RelayCommand(Start); + CloseCommand = new RelayCommand(Close); + StopCommand = new RelayCommand(Stop); StartVisible = true; CloseVisible = true; BlockMapList = []; @@ -124,207 +165,21 @@ public sealed class MediaScanViewModel : ViewModelBase public string CloseLabel => UI.ButtonLabel_Close; public string StopLabel => UI.ButtonLabel_Stop; - public Color AxesColor - { - get => _axesColor; - set => this.RaiseAndSetIfChanged(ref _axesColor, value); - } - - public Color LineColor - { - get => _lineColor; - set => this.RaiseAndSetIfChanged(ref _lineColor, value); - } - public ObservableCollection<(ulong block, double duration)> BlockMapList { get; } // public ObservableCollection ChartPoints { get; } - public ulong Blocks - { - get => _blocks; - set => this.RaiseAndSetIfChanged(ref _blocks, value); - } - - public string A - { - get => _a; - set => this.RaiseAndSetIfChanged(ref _a, value); - } - - public string B - { - get => _b; - set => this.RaiseAndSetIfChanged(ref _b, value); - } - - public string C - { - get => _c; - set => this.RaiseAndSetIfChanged(ref _c, value); - } - - public string D - { - get => _d; - set => this.RaiseAndSetIfChanged(ref _d, value); - } - - public string E - { - get => _e; - set => this.RaiseAndSetIfChanged(ref _e, value); - } - - public string F - { - get => _f; - set => this.RaiseAndSetIfChanged(ref _f, value); - } - - public string UnreadableSectors - { - get => _unreadableSectors; - set => this.RaiseAndSetIfChanged(ref _unreadableSectors, value); - } - - public string TotalTime - { - get => _totalTime; - set => this.RaiseAndSetIfChanged(ref _totalTime, value); - } - - public string AvgSpeed - { - get => _avgSpeed; - set => this.RaiseAndSetIfChanged(ref _avgSpeed, value); - } - - public string MaxSpeed - { - get => _maxSpeed; - set => this.RaiseAndSetIfChanged(ref _maxSpeed, value); - } - - public string MinSpeed - { - get => _minSpeed; - set => this.RaiseAndSetIfChanged(ref _minSpeed, value); - } - - public bool ProgressVisible - { - get => _progressVisible; - set => this.RaiseAndSetIfChanged(ref _progressVisible, value); - } - - public bool Progress1Visible - { - get => _progress1Visible; - set => this.RaiseAndSetIfChanged(ref _progress1Visible, value); - } - - public string ProgressText - { - get => _progressText; - set => this.RaiseAndSetIfChanged(ref _progressText, value); - } - - public double ProgressMaxValue - { - get => _progressMaxValue; - set => this.RaiseAndSetIfChanged(ref _progressMaxValue, value); - } - - public bool ProgressIndeterminate - { - get => _progressIndeterminate; - set => this.RaiseAndSetIfChanged(ref _progressIndeterminate, value); - } - - public double ProgressValue - { - get => _progressValue; - set => this.RaiseAndSetIfChanged(ref _progressValue, 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 StopVisible - { - get => _stopVisible; - set => this.RaiseAndSetIfChanged(ref _stopVisible, value); - } - - public string StopEnabled - { - get => _stopEnabled; - set => this.RaiseAndSetIfChanged(ref _stopEnabled, value); - } - - public bool ResultsVisible - { - get => _resultsVisible; - set => this.RaiseAndSetIfChanged(ref _resultsVisible, value); - } - - public double MaxY - { - get => _maxY; - set => this.RaiseAndSetIfChanged(ref _maxY, value); - } - - public double MaxX - { - get => _maxX; - set => this.RaiseAndSetIfChanged(ref _maxX, value); - } - - public double MinY - { - get => _minY; - set => this.RaiseAndSetIfChanged(ref _minY, value); - } - - public double MinX - { - get => _minX; - set => this.RaiseAndSetIfChanged(ref _minX, value); - } - - public double StepsY - { - get => _stepsY; - set => this.RaiseAndSetIfChanged(ref _stepsY, value); - } - - public double StepsX - { - get => _stepsX; - set => this.RaiseAndSetIfChanged(ref _stepsX, value); - } - public string Title { get; } - public ReactiveCommand StartCommand { get; } - public ReactiveCommand CloseCommand { get; } - public ReactiveCommand StopCommand { get; } + public ICommand StartCommand { get; } + public ICommand CloseCommand { get; } + public ICommand StopCommand { get; } - void ExecuteCloseCommand() => _view.Close(); + void Close() => _view.Close(); - internal void ExecuteStopCommand() => _scanner?.Abort(); + internal void Stop() => _scanner?.Abort(); - void ExecuteStartCommand() + void Start() { StopVisible = true; StartVisible = false; diff --git a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs index 0947f9f96..bb584b691 100644 --- a/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/SplashWindowViewModel.cs @@ -45,36 +45,21 @@ using Aaru.Localization; using Aaru.Logging; using Aaru.Settings; using Avalonia.Threading; +using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.EntityFrameworkCore; -using ReactiveUI; using Sentry; namespace Aaru.Gui.ViewModels.Windows; -public sealed class SplashWindowViewModel(SplashWindow view) : ViewModelBase +public sealed partial class SplashWindowViewModel(SplashWindow view) : ViewModelBase { + [ObservableProperty] double _currentProgress; + [ObservableProperty] double _maxProgress; + [ObservableProperty] string _message; - public string Message - { - get => _message; - set => this.RaiseAndSetIfChanged(ref _message, value); - } - - public double MaxProgress - { - get => _maxProgress; - set => this.RaiseAndSetIfChanged(ref _maxProgress, value); - } - - public double CurrentProgress - { - get => _currentProgress; - set => this.RaiseAndSetIfChanged(ref _currentProgress, value); - } - internal void OnOpened() { Message = UI.Welcome_to_Aaru; diff --git a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs index 6a4209b59..f9080e724 100644 --- a/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs +++ b/Aaru.Gui/ViewModels/Windows/ViewSectorViewModel.cs @@ -34,21 +34,26 @@ using Aaru.CommonTypes.Enums; using Aaru.CommonTypes.Interfaces; using Aaru.Helpers; using Aaru.Localization; +using CommunityToolkit.Mvvm.ComponentModel; using JetBrains.Annotations; -using ReactiveUI; namespace Aaru.Gui.ViewModels.Windows; -public sealed class ViewSectorViewModel : ViewModelBase +public sealed partial class ViewSectorViewModel : ViewModelBase { const int HEX_COLUMNS = 32; readonly IMediaImage _inputFormat; - bool _longSectorChecked; - bool _longSectorVisible; - string _printHexText; - double _sectorNumber; - string _title; - string _totalSectorsText; + [ObservableProperty] + bool _longSectorChecked; + [ObservableProperty] + bool _longSectorVisible; + [ObservableProperty] + string _printHexText; + double _sectorNumber; + [ObservableProperty] + string _title; + [ObservableProperty] + string _totalSectorsText; public ViewSectorViewModel([NotNull] IMediaImage inputFormat) { @@ -68,18 +73,13 @@ public sealed class ViewSectorViewModel : ViewModelBase public string SectorLabel => UI.Title_Sector; public string LongSectorLabel => UI.Show_long_sector; - public string Title - { - get => _title; - set => this.RaiseAndSetIfChanged(ref _title, value); - } public double SectorNumber { get => _sectorNumber; set { - this.RaiseAndSetIfChanged(ref _sectorNumber, value); + SetProperty(ref _sectorNumber, value); ErrorNumber errno = LongSectorChecked ? _inputFormat.ReadSectorLong((ulong)SectorNumber, out byte[] sector) @@ -88,20 +88,4 @@ public sealed class ViewSectorViewModel : ViewModelBase 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); - } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs index 95fce709e..f2e08e0db 100644 --- a/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageChecksum.xaml.cs @@ -51,7 +51,7 @@ public sealed class ImageChecksum : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as ImageChecksumViewModel)?.ExecuteStopCommand(); + (DataContext as ImageChecksumViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs index ffb4ac1a7..8237e6078 100644 --- a/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageConvert.xaml.cs @@ -51,7 +51,7 @@ public sealed class ImageConvert : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as ImageConvertViewModel)?.ExecuteStopCommand(); + (DataContext as ImageConvertViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs index 3a6cceb48..5248b563e 100644 --- a/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageEntropy.xaml.cs @@ -51,7 +51,7 @@ public sealed class ImageEntropy : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as ImageEntropyViewModel)?.ExecuteStopCommand(); + (DataContext as ImageEntropyViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs index 36d29fbd4..f2b226e77 100644 --- a/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs +++ b/Aaru.Gui/Views/Windows/ImageVerify.xaml.cs @@ -51,7 +51,7 @@ public sealed class ImageVerify : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as ImageVerifyViewModel)?.ExecuteStopCommand(); + (DataContext as ImageVerifyViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs index 9f8ae0a29..0ed2d0715 100644 --- a/Aaru.Gui/Views/Windows/MediaDump.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaDump.xaml.cs @@ -51,7 +51,7 @@ public sealed class MediaDump : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as MediaDumpViewModel)?.ExecuteStopCommand(); + (DataContext as MediaDumpViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs index b62f30b45..f32bcdc5c 100644 --- a/Aaru.Gui/Views/Windows/MediaScan.xaml.cs +++ b/Aaru.Gui/Views/Windows/MediaScan.xaml.cs @@ -51,7 +51,7 @@ public sealed class MediaScan : Window protected override void OnClosing(WindowClosingEventArgs e) { - (DataContext as MediaScanViewModel)?.ExecuteStopCommand(); + (DataContext as MediaScanViewModel)?.Stop(); base.OnClosing(e); } } \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props index 7c1f7a204..798715635 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,11 +6,11 @@ - +