diff --git a/Directory.Packages.props b/Directory.Packages.props
index d91116e..c4d90c4 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -4,10 +4,10 @@
-
+
@@ -33,17 +33,14 @@
-
-
-
\ No newline at end of file
diff --git a/RomRepoMgr/Models/DatImporter.cs b/RomRepoMgr/Models/DatImporter.cs
index f560167..b503942 100644
--- a/RomRepoMgr/Models/DatImporter.cs
+++ b/RomRepoMgr/Models/DatImporter.cs
@@ -1,59 +1,29 @@
using System;
using System.Threading.Tasks;
using Avalonia.Media;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
using RomRepoMgr.Core.EventArgs;
namespace RomRepoMgr.Models;
-public class DatImporter : ReactiveObject
+public partial class DatImporter : ObservableObject
{
- bool _indeterminate;
- double _maximum;
- double _minimum;
- double _progress;
- Color _statusColor;
- string _statusMessage;
+ [ObservableProperty]
+ bool _indeterminate;
+ [ObservableProperty]
+ double _maximum;
+ [ObservableProperty]
+ double _minimum;
+ [ObservableProperty]
+ double _progress;
+ [ObservableProperty]
+ Color _statusColor;
+ [ObservableProperty]
+ string _statusMessage;
public string Filename { get; internal init; }
public Task Task { get; set; }
public bool Running { get; private set; } = true;
- public bool Indeterminate
- {
- get => _indeterminate;
- set => this.RaiseAndSetIfChanged(ref _indeterminate, value);
- }
-
- public double Progress
- {
- get => _progress;
- set => this.RaiseAndSetIfChanged(ref _progress, value);
- }
-
- public double Maximum
- {
- get => _maximum;
- set => this.RaiseAndSetIfChanged(ref _maximum, value);
- }
-
- public double Minimum
- {
- get => _minimum;
- set => this.RaiseAndSetIfChanged(ref _minimum, value);
- }
-
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public Color StatusColor
- {
- get => _statusColor;
- set => this.RaiseAndSetIfChanged(ref _statusColor, value);
- }
-
internal void OnErrorOccurred(object sender, ErrorEventArgs e)
{
StatusMessage = e.Message;
diff --git a/RomRepoMgr/Models/RomImporter.cs b/RomRepoMgr/Models/RomImporter.cs
index 37a1860..284c41b 100644
--- a/RomRepoMgr/Models/RomImporter.cs
+++ b/RomRepoMgr/Models/RomImporter.cs
@@ -1,75 +1,29 @@
using System;
using Avalonia.Media;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
using RomRepoMgr.Core.EventArgs;
namespace RomRepoMgr.Models;
-public class RomImporter : ReactiveObject
+public partial class RomImporter : ObservableObject
{
- bool _indeterminate;
- double _maximum;
- double _minimum;
- double _progress;
- bool _progressVisible = true;
- Color _statusColor;
- string _statusMessage;
+ [ObservableProperty]
+ bool _indeterminate;
+ [ObservableProperty]
+ double _maximum;
+ [ObservableProperty]
+ double _minimum;
+ [ObservableProperty]
+ double _progress;
+ [ObservableProperty]
+ bool _progressVisible = true;
+ [ObservableProperty]
+ Color _statusColor;
+ [ObservableProperty]
+ string _statusMessage;
public string Filename { get; internal init; }
public bool Running { get; private set; } = true;
- public bool Indeterminate
- {
- get => _indeterminate;
- set => this.RaiseAndSetIfChanged(ref _indeterminate, value);
- }
-
- public double Progress
- {
- get => _progress;
- set => this.RaiseAndSetIfChanged(ref _progress, value);
- }
-
- public double Maximum
- {
- get => _maximum;
- set => this.RaiseAndSetIfChanged(ref _maximum, value);
- }
-
- public double Minimum
- {
- get => _minimum;
- set => this.RaiseAndSetIfChanged(ref _minimum, value);
- }
-
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public Color StatusColor
- {
- get => _statusColor;
- set => this.RaiseAndSetIfChanged(ref _statusColor, value);
- }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- internal void OnErrorOccurred(object sender, ErrorEventArgs e)
- {
- StatusMessage = e.Message;
- StatusColor = Colors.Red;
-
- if(!Indeterminate) return;
-
- Indeterminate = false;
- Progress = 0;
- }
-
internal void OnSetIndeterminateProgress(object sender, EventArgs e)
{
Indeterminate = true;
diff --git a/RomRepoMgr/Program.cs b/RomRepoMgr/Program.cs
index 335c73b..1610310 100644
--- a/RomRepoMgr/Program.cs
+++ b/RomRepoMgr/Program.cs
@@ -25,7 +25,6 @@
using Avalonia;
using Avalonia.Logging;
-using Avalonia.ReactiveUI;
namespace RomRepoMgr;
@@ -39,6 +38,5 @@ internal static class Program
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure()
.UsePlatformDetect()
- .LogToTrace(LogEventLevel.Debug)
- .UseReactiveUI();
+ .LogToTrace(LogEventLevel.Debug);
}
\ No newline at end of file
diff --git a/RomRepoMgr/RomRepoMgr.csproj b/RomRepoMgr/RomRepoMgr.csproj
index 8783e63..3bac9e7 100644
--- a/RomRepoMgr/RomRepoMgr.csproj
+++ b/RomRepoMgr/RomRepoMgr.csproj
@@ -19,9 +19,9 @@
-
+
diff --git a/RomRepoMgr/ViewModels/AboutViewModel.cs b/RomRepoMgr/ViewModels/AboutViewModel.cs
index 5ff8e15..8cc6c99 100644
--- a/RomRepoMgr/ViewModels/AboutViewModel.cs
+++ b/RomRepoMgr/ViewModels/AboutViewModel.cs
@@ -26,20 +26,22 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Reactive;
using System.Reflection;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.Models;
using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public sealed class AboutViewModel : ViewModelBase
+public sealed partial class AboutViewModel : ViewModelBase
{
readonly About _view;
- string _versionText;
+ [ObservableProperty]
+ string _versionText;
public AboutViewModel()
{
@@ -57,26 +59,20 @@ public sealed class AboutViewModel : ViewModelBase
public string SuiteName => "ROM Repository Manager";
public string Copyright => "© 2020-2024 Natalia Portillo";
public string Website => "https://www.claunia.com";
- public ReactiveCommand WebsiteCommand { get; private set; }
- public ReactiveCommand LicenseCommand { get; private set; }
- public ReactiveCommand CloseCommand { get; private set; }
+ public ICommand WebsiteCommand { get; private set; }
+ public ICommand LicenseCommand { get; private set; }
+ public ICommand CloseCommand { get; private set; }
public ObservableCollection Assemblies { get; private set; }
- public string VersionText
- {
- get => _versionText;
- private set => this.RaiseAndSetIfChanged(ref _versionText, value);
- }
-
void LoadData()
{
VersionText =
(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(ExecuteWebsiteCommand);
+ LicenseCommand = new RelayCommand(ExecuteLicenseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
Assemblies = [];
diff --git a/RomRepoMgr/ViewModels/EditDatViewModel.cs b/RomRepoMgr/ViewModels/EditDatViewModel.cs
index 4f9c933..ae650d6 100644
--- a/RomRepoMgr/ViewModels/EditDatViewModel.cs
+++ b/RomRepoMgr/ViewModels/EditDatViewModel.cs
@@ -24,9 +24,10 @@
*******************************************************************************/
using System;
-using System.Reactive;
using System.Threading.Tasks;
-using ReactiveUI;
+using System.Windows.Input;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Models;
using RomRepoMgr.Database;
@@ -35,7 +36,7 @@ using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public class EditDatViewModel : ViewModelBase
+public partial class EditDatViewModel : ViewModelBase
{
readonly RomSetModel _romSet;
readonly EditDat _view;
@@ -45,9 +46,10 @@ public class EditDatViewModel : ViewModelBase
string _date;
string _description;
string _homepage;
- bool _modified;
- string _name;
- string _version;
+ [ObservableProperty]
+ bool _modified;
+ string _name;
+ string _version;
// Mock
public EditDatViewModel()
@@ -96,26 +98,20 @@ public class EditDatViewModel : ViewModelBase
_date = romSet.Date;
_description = romSet.Description;
_homepage = romSet.Homepage;
- SaveCommand = ReactiveCommand.CreateFromTask(ExecuteSaveCommandAsync);
- CancelCommand = ReactiveCommand.Create(ExecuteCloseCommand);
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
+ SaveCommand = new AsyncRelayCommand(ExecuteSaveCommandAsync);
+ CancelCommand = new RelayCommand(ExecuteCloseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
}
- public ReactiveCommand SaveCommand { get; }
- public ReactiveCommand CancelCommand { get; }
- public ReactiveCommand CloseCommand { get; }
- public long TotalMachines => _romSet.TotalMachines;
- public long CompleteMachines => _romSet.CompleteMachines;
- public long IncompleteMachines => _romSet.IncompleteMachines;
- public long TotalRoms => _romSet.TotalRoms;
- public long HaveRoms => _romSet.HaveRoms;
- public long MissRoms => _romSet.MissRoms;
-
- public bool Modified
- {
- get => _modified;
- set => this.RaiseAndSetIfChanged(ref _modified, value);
- }
+ public ICommand SaveCommand { get; }
+ public ICommand CancelCommand { get; }
+ public ICommand CloseCommand { get; }
+ public long TotalMachines => _romSet.TotalMachines;
+ public long CompleteMachines => _romSet.CompleteMachines;
+ public long IncompleteMachines => _romSet.IncompleteMachines;
+ public long TotalRoms => _romSet.TotalRoms;
+ public long HaveRoms => _romSet.HaveRoms;
+ public long MissRoms => _romSet.MissRoms;
public string Name
{
@@ -124,7 +120,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _name) Modified = true;
- this.RaiseAndSetIfChanged(ref _name, value);
+ SetProperty(ref _name, value);
}
}
@@ -135,7 +131,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _version) Modified = true;
- this.RaiseAndSetIfChanged(ref _version, value);
+ SetProperty(ref _version, value);
}
}
@@ -146,7 +142,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _author) Modified = true;
- this.RaiseAndSetIfChanged(ref _author, value);
+ SetProperty(ref _author, value);
}
}
@@ -157,7 +153,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _comment) Modified = true;
- this.RaiseAndSetIfChanged(ref _comment, value);
+ SetProperty(ref _comment, value);
}
}
@@ -168,7 +164,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _category) Modified = true;
- this.RaiseAndSetIfChanged(ref _category, value);
+ SetProperty(ref _category, value);
}
}
@@ -179,7 +175,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _date) Modified = true;
- this.RaiseAndSetIfChanged(ref _date, value);
+ SetProperty(ref _date, value);
}
}
@@ -190,7 +186,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _description) Modified = true;
- this.RaiseAndSetIfChanged(ref _description, value);
+ SetProperty(ref _description, value);
}
}
@@ -201,7 +197,7 @@ public class EditDatViewModel : ViewModelBase
{
if(value != _homepage) Modified = true;
- this.RaiseAndSetIfChanged(ref _homepage, value);
+ SetProperty(ref _homepage, value);
}
}
diff --git a/RomRepoMgr/ViewModels/ExportDatViewModel.cs b/RomRepoMgr/ViewModels/ExportDatViewModel.cs
index c914632..fe4612a 100644
--- a/RomRepoMgr/ViewModels/ExportDatViewModel.cs
+++ b/RomRepoMgr/ViewModels/ExportDatViewModel.cs
@@ -24,10 +24,11 @@
*******************************************************************************/
using System.IO;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Workers;
@@ -37,17 +38,22 @@ using ErrorEventArgs = RomRepoMgr.Core.EventArgs.ErrorEventArgs;
namespace RomRepoMgr.ViewModels;
-public sealed class ExportDatViewModel : ViewModelBase
+public sealed partial class ExportDatViewModel : ViewModelBase
{
readonly string _datHash;
readonly string _outPath;
readonly ExportDat _view;
readonly Compression _worker;
- bool _canClose;
- string _errorMessage;
- bool _errorVisible;
- bool _progressVisible;
- string _statusMessage;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ string _errorMessage;
+ [ObservableProperty]
+ bool _errorVisible;
+ [ObservableProperty]
+ bool _progressVisible;
+ [ObservableProperty]
+ string _statusMessage;
// Mock
public ExportDatViewModel() {}
@@ -57,7 +63,7 @@ public sealed class ExportDatViewModel : ViewModelBase
_view = view;
_datHash = datHash;
_outPath = outPath;
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
ProgressVisible = false;
ErrorVisible = false;
_worker = new Compression();
@@ -65,37 +71,7 @@ public sealed class ExportDatViewModel : ViewModelBase
_worker.FailedWithText += OnWorkerOnFailedWithText;
}
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public bool ErrorVisible
- {
- get => _errorVisible;
- set => this.RaiseAndSetIfChanged(ref _errorVisible, value);
- }
-
- public string ErrorMessage
- {
- get => _errorMessage;
- set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
- public ReactiveCommand CloseCommand { get; }
+ public ICommand CloseCommand { get; }
void OnWorkerOnFinishedWithText(object sender, MessageEventArgs args) => Dispatcher.UIThread.Post(() =>
{
diff --git a/RomRepoMgr/ViewModels/ExportRomsViewModel.cs b/RomRepoMgr/ViewModels/ExportRomsViewModel.cs
index 4f96043..250a876 100644
--- a/RomRepoMgr/ViewModels/ExportRomsViewModel.cs
+++ b/RomRepoMgr/ViewModels/ExportRomsViewModel.cs
@@ -24,39 +24,59 @@
*******************************************************************************/
using System;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public sealed class ExportRomsViewModel : ViewModelBase
+public sealed partial class ExportRomsViewModel : ViewModelBase
{
readonly long _romSetId;
readonly ExportRoms _view;
- bool _canClose;
- bool _progress2IsIndeterminate;
- double _progress2Maximum;
- double _progress2Minimum;
- double _progress2Value;
- bool _progress2Visible;
- bool _progress3IsIndeterminate;
- double _progress3Maximum;
- double _progress3Minimum;
- double _progress3Value;
- bool _progress3Visible;
- bool _progressIsIndeterminate;
- double _progressMaximum;
- double _progressMinimum;
- double _progressValue;
- bool _progressVisible;
- string _status2Message;
- string _status3Message;
- string _statusMessage;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ bool _progress2IsIndeterminate;
+ [ObservableProperty]
+ double _progress2Maximum;
+ [ObservableProperty]
+ double _progress2Minimum;
+ [ObservableProperty]
+ double _progress2Value;
+ [ObservableProperty]
+ bool _progress2Visible;
+ [ObservableProperty]
+ bool _progress3IsIndeterminate;
+ [ObservableProperty]
+ double _progress3Maximum;
+ [ObservableProperty]
+ double _progress3Minimum;
+ [ObservableProperty]
+ double _progress3Value;
+ [ObservableProperty]
+ bool _progress3Visible;
+ [ObservableProperty]
+ bool _progressIsIndeterminate;
+ [ObservableProperty]
+ double _progressMaximum;
+ [ObservableProperty]
+ double _progressMinimum;
+ [ObservableProperty]
+ double _progressValue;
+ [ObservableProperty]
+ bool _progressVisible;
+ [ObservableProperty]
+ string _status2Message;
+ [ObservableProperty]
+ string _status3Message;
+ [ObservableProperty]
+ string _statusMessage;
// Mock
public ExportRomsViewModel()
@@ -71,127 +91,12 @@ public sealed class ExportRomsViewModel : ViewModelBase
_view = view;
_romSetId = romSetId;
FolderPath = folderPath;
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
CanClose = false;
}
- public string FolderPath { get; }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public double ProgressMinimum
- {
- get => _progressMinimum;
- set => this.RaiseAndSetIfChanged(ref _progressMinimum, value);
- }
-
- public double ProgressMaximum
- {
- get => _progressMaximum;
- set => this.RaiseAndSetIfChanged(ref _progressMaximum, value);
- }
-
- public double ProgressValue
- {
- get => _progressValue;
- set => this.RaiseAndSetIfChanged(ref _progressValue, value);
- }
-
- public bool ProgressIsIndeterminate
- {
- get => _progressIsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progressIsIndeterminate, value);
- }
-
- public bool Progress2Visible
- {
- get => _progress2Visible;
- set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
- }
-
- public string Status2Message
- {
- get => _status2Message;
- set => this.RaiseAndSetIfChanged(ref _status2Message, value);
- }
-
- public double Progress2Minimum
- {
- get => _progress2Minimum;
- set => this.RaiseAndSetIfChanged(ref _progress2Minimum, value);
- }
-
- public double Progress2Maximum
- {
- get => _progress2Maximum;
- set => this.RaiseAndSetIfChanged(ref _progress2Maximum, value);
- }
-
- public double Progress2Value
- {
- get => _progress2Value;
- set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
- }
-
- public bool Progress2IsIndeterminate
- {
- get => _progress2IsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progress2IsIndeterminate, value);
- }
-
- public bool Progress3Visible
- {
- get => _progress3Visible;
- set => this.RaiseAndSetIfChanged(ref _progress3Visible, value);
- }
-
- public string Status3Message
- {
- get => _status3Message;
- set => this.RaiseAndSetIfChanged(ref _status3Message, value);
- }
-
- public double Progress3Minimum
- {
- get => _progress3Minimum;
- set => this.RaiseAndSetIfChanged(ref _progress3Minimum, value);
- }
-
- public double Progress3Maximum
- {
- get => _progress3Maximum;
- set => this.RaiseAndSetIfChanged(ref _progress3Maximum, value);
- }
-
- public double Progress3Value
- {
- get => _progress3Value;
- set => this.RaiseAndSetIfChanged(ref _progress3Value, value);
- }
-
- public bool Progress3IsIndeterminate
- {
- get => _progress3IsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progress3IsIndeterminate, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
- public ReactiveCommand CloseCommand { get; }
+ public string FolderPath { get; }
+ public ICommand CloseCommand { get; }
void ExecuteCloseCommand() => _view.Close();
diff --git a/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs b/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
index b6504aa..b72bfb7 100644
--- a/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
+++ b/RomRepoMgr/ViewModels/ImportDatFolderViewModel.cs
@@ -4,75 +4,70 @@ using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Models;
using RomRepoMgr.Resources;
namespace RomRepoMgr.ViewModels;
-public class ImportDatFolderViewModel : ViewModelBase
+public sealed partial class ImportDatFolderViewModel : ViewModelBase
{
readonly Stopwatch _stopwatch = new();
bool _allFilesChecked;
- bool _canClose;
- bool _canStart;
- string _category;
- string[] _datFiles;
- string _folderPath;
- bool _isImporting;
- bool _isReady;
- int _listPosition;
- bool _progressIsIndeterminate;
- double _progressMaximum;
- double _progressMinimum;
- double _progressValue;
- bool _progressVisible;
- bool _recursiveChecked;
- string _statusMessage;
- int _workers;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ bool _canStart;
+ [ObservableProperty]
+ string _category;
+ string[] _datFiles;
+ [ObservableProperty]
+ string _folderPath;
+ [ObservableProperty]
+ bool _isImporting;
+ [ObservableProperty]
+ bool _isReady;
+ int _listPosition;
+ [ObservableProperty]
+ bool _progressIsIndeterminate;
+ [ObservableProperty]
+ double _progressMaximum;
+ [ObservableProperty]
+ double _progressMinimum;
+ [ObservableProperty]
+ double _progressValue;
+ [ObservableProperty]
+ bool _progressVisible;
+ bool _recursiveChecked;
+ [ObservableProperty]
+ string _statusMessage;
+ int _workers;
public ImportDatFolderViewModel()
{
CanClose = true;
IsReady = true;
- SelectFolderCommand = ReactiveCommand.CreateFromTask(SelectFolderAsync);
- CloseCommand = ReactiveCommand.Create(Close);
- StartCommand = ReactiveCommand.Create(Start);
+ SelectFolderCommand = new AsyncRelayCommand(SelectFolderAsync);
+ CloseCommand = new RelayCommand(Close);
+ StartCommand = new RelayCommand(Start);
}
- public ReactiveCommand SelectFolderCommand { get; }
- public Window View { get; init; }
-
- public bool IsReady
- {
- get => _isReady;
- set => this.RaiseAndSetIfChanged(ref _isReady, value);
- }
-
- public string FolderPath
- {
- get => _folderPath;
- set => this.RaiseAndSetIfChanged(ref _folderPath, value);
- }
-
- public string Category
- {
- get => _category;
- set => this.RaiseAndSetIfChanged(ref _category, value);
- }
+ public ICommand SelectFolderCommand { get; }
+ public Window View { get; init; }
public bool AllFilesChecked
{
get => _allFilesChecked;
set
{
- this.RaiseAndSetIfChanged(ref _allFilesChecked, value);
+ SetProperty(ref _allFilesChecked, value);
RefreshFiles();
}
}
@@ -82,67 +77,13 @@ public class ImportDatFolderViewModel : ViewModelBase
get => _recursiveChecked;
set
{
- this.RaiseAndSetIfChanged(ref _recursiveChecked, value);
+ SetProperty(ref _recursiveChecked, value);
RefreshFiles();
}
}
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public bool ProgressIsIndeterminate
- {
- get => _progressIsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progressIsIndeterminate, value);
- }
-
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
- public bool CanStart
- {
- get => _canStart;
- set => this.RaiseAndSetIfChanged(ref _canStart, value);
- }
-
- public double ProgressMinimum
- {
- get => _progressMinimum;
- set => this.RaiseAndSetIfChanged(ref _progressMinimum, value);
- }
-
- public double ProgressMaximum
- {
- get => _progressMaximum;
- set => this.RaiseAndSetIfChanged(ref _progressMaximum, value);
- }
-
- public double ProgressValue
- {
- get => _progressValue;
- set => this.RaiseAndSetIfChanged(ref _progressValue, value);
- }
-
- public bool IsImporting
- {
- get => _isImporting;
- set => this.RaiseAndSetIfChanged(ref _isImporting, value);
- }
-
- public ReactiveCommand CloseCommand { get; }
- public ReactiveCommand StartCommand { get; }
+ public ICommand CloseCommand { get; }
+ public ICommand StartCommand { get; }
public ObservableCollection Importers { get; } = [];
void Start()
diff --git a/RomRepoMgr/ViewModels/ImportDatViewModel.cs b/RomRepoMgr/ViewModels/ImportDatViewModel.cs
index 90fed98..093ce22 100644
--- a/RomRepoMgr/ViewModels/ImportDatViewModel.cs
+++ b/RomRepoMgr/ViewModels/ImportDatViewModel.cs
@@ -24,29 +24,39 @@
*******************************************************************************/
using System;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public sealed class ImportDatViewModel : ViewModelBase
+public sealed partial class ImportDatViewModel : ViewModelBase
{
readonly ImportDat _view;
readonly DatImporter _worker;
- bool _canClose;
- double _currentValue;
- string _errorMessage;
- bool _errorVisible;
- bool _indeterminateProgress;
- double _maximumValue;
- double _minimumValue;
- bool _progressVisible;
- string _statusMessage;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ double _currentValue;
+ [ObservableProperty]
+ string _errorMessage;
+ [ObservableProperty]
+ bool _errorVisible;
+ [ObservableProperty]
+ bool _indeterminateProgress;
+ [ObservableProperty]
+ double _maximumValue;
+ [ObservableProperty]
+ double _minimumValue;
+ [ObservableProperty]
+ bool _progressVisible;
+ [ObservableProperty]
+ string _statusMessage;
// Mock
public ImportDatViewModel() {}
@@ -54,7 +64,7 @@ public sealed class ImportDatViewModel : ViewModelBase
public ImportDatViewModel(ImportDat view, string datPath)
{
_view = view;
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
IndeterminateProgress = true;
ProgressVisible = false;
ErrorVisible = false;
@@ -67,61 +77,7 @@ public sealed class ImportDatViewModel : ViewModelBase
_worker.WorkFinished += OnWorkerOnWorkFinished;
}
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public bool IndeterminateProgress
- {
- get => _indeterminateProgress;
- set => this.RaiseAndSetIfChanged(ref _indeterminateProgress, value);
- }
-
- public double MaximumValue
- {
- get => _maximumValue;
- set => this.RaiseAndSetIfChanged(ref _maximumValue, value);
- }
-
- public double MinimumValue
- {
- get => _minimumValue;
- set => this.RaiseAndSetIfChanged(ref _minimumValue, value);
- }
-
- public double CurrentValue
- {
- get => _currentValue;
- set => this.RaiseAndSetIfChanged(ref _currentValue, value);
- }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public bool ErrorVisible
- {
- get => _errorVisible;
- set => this.RaiseAndSetIfChanged(ref _errorVisible, value);
- }
-
- public string ErrorMessage
- {
- get => _errorMessage;
- set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
- public ReactiveCommand CloseCommand { get; }
+ public ICommand CloseCommand { get; }
void OnWorkerOnWorkFinished(object sender, MessageEventArgs args) => Dispatcher.UIThread.Post(() =>
{
diff --git a/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs b/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
index e60bc2b..076f5b6 100644
--- a/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
+++ b/RomRepoMgr/ViewModels/ImportRomFolderViewModel.cs
@@ -1,15 +1,17 @@
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
-using System.Reactive;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Database;
@@ -19,44 +21,65 @@ using RomRepoMgr.Resources;
namespace RomRepoMgr.ViewModels;
-public class ImportRomFolderViewModel : ViewModelBase
+public sealed partial class ImportRomFolderViewModel : ViewModelBase
{
readonly Context _ctx = Context.Create(Settings.Settings.Current.DatabasePath);
readonly ConcurrentBag _newDisks = [];
readonly ConcurrentBag _newFiles = [];
readonly ConcurrentBag _newMedias = [];
readonly Stopwatch _stopwatch = new();
- bool _canClose;
- bool _canStart;
- string _folderPath;
- bool _isImporting;
- bool _isReady;
- bool _knownOnlyChecked;
- int _listPosition;
- bool _progress2IsIndeterminate;
- double _progress2Maximum;
- double _progress2Minimum;
- double _progress2Value;
- bool _progress2Visible;
- bool _progressIsIndeterminate;
- double _progressMaximum;
- double _progressMinimum;
- double _progressValue;
- bool _progressVisible;
- bool _recurseArchivesChecked;
- bool _removeFilesChecked;
- bool _removeFilesEnabled;
- FileImporter _rootImporter;
- string _statusMessage;
- string _statusMessage2;
- bool _statusMessage2Visible;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ bool _canStart;
+ [ObservableProperty]
+ string _folderPath;
+ [ObservableProperty]
+ bool _isImporting;
+ [ObservableProperty]
+ bool _isReady;
+ [ObservableProperty]
+ bool _knownOnlyChecked;
+ int _listPosition;
+ [ObservableProperty]
+ bool _progress2IsIndeterminate;
+ [ObservableProperty]
+ double _progress2Maximum;
+ [ObservableProperty]
+ double _progress2Minimum;
+ [ObservableProperty]
+ double _progress2Value;
+ [ObservableProperty]
+ bool _progress2Visible;
+ [ObservableProperty]
+ bool _progressIsIndeterminate;
+ [ObservableProperty]
+ double _progressMaximum;
+ [ObservableProperty]
+ double _progressMinimum;
+ [ObservableProperty]
+ double _progressValue;
+ [ObservableProperty]
+ bool _progressVisible;
+ bool _recurseArchivesChecked;
+ [ObservableProperty]
+ bool _removeFilesChecked;
+ [ObservableProperty]
+ bool _removeFilesEnabled;
+ FileImporter _rootImporter;
+ [ObservableProperty]
+ string _statusMessage;
+ [ObservableProperty]
+ string _statusMessage2;
+ [ObservableProperty]
+ bool _statusMessage2Visible;
public ImportRomFolderViewModel()
{
- SelectFolderCommand = ReactiveCommand.CreateFromTask(SelectFolderAsync);
- CloseCommand = ReactiveCommand.Create(Close);
- StartCommand = ReactiveCommand.Create(Start);
+ SelectFolderCommand = new AsyncRelayCommand(SelectFolderAsync);
+ CloseCommand = new RelayCommand(Close);
+ StartCommand = new RelayCommand(Start);
CanClose = true;
RemoveFilesChecked = false;
KnownOnlyChecked = true;
@@ -64,31 +87,13 @@ public class ImportRomFolderViewModel : ViewModelBase
RemoveFilesEnabled = false;
}
- public ReactiveCommand SelectFolderCommand { get; }
- public ReactiveCommand CloseCommand { get; }
- public ReactiveCommand StartCommand { get; }
- public Window View { get; init; }
+ public ICommand SelectFolderCommand { get; }
+ public ICommand CloseCommand { get; }
+ public ICommand StartCommand { get; }
+ public Window View { get; init; }
public bool RecurseArchivesEnabled => Settings.Settings.UnArUsable;
- public bool RemoveFilesChecked
- {
- get => _removeFilesChecked;
- set => this.RaiseAndSetIfChanged(ref _removeFilesChecked, value);
- }
-
- public bool KnownOnlyChecked
- {
- get => _knownOnlyChecked;
- set => this.RaiseAndSetIfChanged(ref _knownOnlyChecked, value);
- }
-
- public bool RemoveFilesEnabled
- {
- get => _removeFilesEnabled;
- set => this.RaiseAndSetIfChanged(ref _removeFilesEnabled, value);
- }
-
public bool RecurseArchivesChecked
{
get => _recurseArchivesChecked;
@@ -97,119 +102,10 @@ public class ImportRomFolderViewModel : ViewModelBase
if(value) RemoveFilesChecked = false;
RemoveFilesEnabled = !value;
- this.RaiseAndSetIfChanged(ref _recurseArchivesChecked, value);
+ SetProperty(ref _recurseArchivesChecked, value);
}
}
- public bool IsReady
- {
- get => _isReady;
- set => this.RaiseAndSetIfChanged(ref _isReady, value);
- }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public double ProgressMinimum
- {
- get => _progressMinimum;
- set => this.RaiseAndSetIfChanged(ref _progressMinimum, value);
- }
-
- public double ProgressMaximum
- {
- get => _progressMaximum;
- set => this.RaiseAndSetIfChanged(ref _progressMaximum, value);
- }
-
- public double ProgressValue
- {
- get => _progressValue;
- set => this.RaiseAndSetIfChanged(ref _progressValue, value);
- }
-
- public bool ProgressIsIndeterminate
- {
- get => _progressIsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progressIsIndeterminate, value);
- }
-
- public bool Progress2Visible
- {
- get => _progress2Visible;
- set => this.RaiseAndSetIfChanged(ref _progress2Visible, value);
- }
-
- public bool StatusMessage2Visible
- {
- get => _statusMessage2Visible;
- set => this.RaiseAndSetIfChanged(ref _statusMessage2Visible, value);
- }
-
- public string StatusMessage2
- {
- get => _statusMessage2;
- set => this.RaiseAndSetIfChanged(ref _statusMessage2, value);
- }
-
- public double Progress2Minimum
- {
- get => _progress2Minimum;
- set => this.RaiseAndSetIfChanged(ref _progress2Minimum, value);
- }
-
- public double Progress2Maximum
- {
- get => _progress2Maximum;
- set => this.RaiseAndSetIfChanged(ref _progress2Maximum, value);
- }
-
- public double Progress2Value
- {
- get => _progress2Value;
- set => this.RaiseAndSetIfChanged(ref _progress2Value, value);
- }
-
- public bool Progress2IsIndeterminate
- {
- get => _progress2IsIndeterminate;
- set => this.RaiseAndSetIfChanged(ref _progress2IsIndeterminate, value);
- }
-
- public string FolderPath
- {
- get => _folderPath;
- set => this.RaiseAndSetIfChanged(ref _folderPath, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
- public bool CanStart
- {
- get => _canStart;
- set => this.RaiseAndSetIfChanged(ref _canStart, value);
- }
-
- public bool IsImporting
- {
- get => _isImporting;
- set => this.RaiseAndSetIfChanged(ref _isImporting, value);
- }
-
-
public ObservableCollection Importers { get; } = [];
void Start()
diff --git a/RomRepoMgr/ViewModels/MainWindowViewModel.cs b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
index 91c8ee5..4ca7459 100644
--- a/RomRepoMgr/ViewModels/MainWindowViewModel.cs
+++ b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
@@ -28,16 +28,17 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
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 RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Filesystem;
using RomRepoMgr.Core.Models;
@@ -46,11 +47,13 @@ using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public class MainWindowViewModel : ViewModelBase
+public sealed partial class MainWindowViewModel : ViewModelBase
{
readonly MainWindow _view;
- RomSetModel _selectedRomSet;
- Vfs _vfs;
+ [ObservableProperty]
+ RomSetModel _selectedRomSet;
+ [ObservableProperty]
+ Vfs _vfs;
// Mock
public MainWindowViewModel() {}
@@ -58,19 +61,19 @@ public class MainWindowViewModel : ViewModelBase
public MainWindowViewModel(MainWindow view, List romSets)
{
_view = view;
- ExitCommand = ReactiveCommand.Create(ExecuteExitCommand);
- SettingsCommand = ReactiveCommand.CreateFromTask(ExecuteSettingsCommandAsync);
- AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand);
- ImportDatCommand = ReactiveCommand.CreateFromTask(ExecuteImportDatCommandAsync);
- ImportDatFolderCommand = ReactiveCommand.CreateFromTask(ExecuteImportDatFolderCommandAsync);
- ImportRomFolderCommand = ReactiveCommand.CreateFromTask(ExecuteImportRomFolderCommandAsync);
- DeleteRomSetCommand = ReactiveCommand.CreateFromTask(ExecuteDeleteRomSetCommandAsync);
- EditRomSetCommand = ReactiveCommand.Create(ExecuteEditRomSetCommand);
- ExportDatCommand = ReactiveCommand.CreateFromTask(ExecuteExportDatCommandAsync);
- ExportRomsCommand = ReactiveCommand.CreateFromTask(ExecuteExportRomsCommandAsync);
- MountCommand = ReactiveCommand.CreateFromTask(ExecuteMountCommandAsync);
- UmountCommand = ReactiveCommand.Create(ExecuteUmountCommand);
- UpdateStatsCommand = ReactiveCommand.CreateFromTask(ExecuteUpdateStatsCommandAsync);
+ ExitCommand = new RelayCommand(ExecuteExitCommand);
+ SettingsCommand = new AsyncRelayCommand(ExecuteSettingsCommandAsync);
+ AboutCommand = new RelayCommand(ExecuteAboutCommand);
+ ImportDatCommand = new AsyncRelayCommand(ExecuteImportDatCommandAsync);
+ ImportDatFolderCommand = new AsyncRelayCommand(ExecuteImportDatFolderCommandAsync);
+ ImportRomFolderCommand = new AsyncRelayCommand(ExecuteImportRomFolderCommandAsync);
+ DeleteRomSetCommand = new AsyncRelayCommand(ExecuteDeleteRomSetCommandAsync);
+ EditRomSetCommand = new RelayCommand(ExecuteEditRomSetCommand);
+ ExportDatCommand = new AsyncRelayCommand(ExecuteExportDatCommandAsync);
+ ExportRomsCommand = new AsyncRelayCommand(ExecuteExportRomsCommandAsync);
+ MountCommand = new AsyncRelayCommand(ExecuteMountCommandAsync);
+ UmountCommand = new RelayCommand(ExecuteUmountCommand);
+ UpdateStatsCommand = new AsyncRelayCommand(ExecuteUpdateStatsCommandAsync);
RomSets = new ObservableCollection(romSets);
}
@@ -81,31 +84,19 @@ public class MainWindowViewModel : ViewModelBase
NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as
IClassicDesktopStyleApplicationLifetime)?.MainWindow);
- public ReactiveCommand AboutCommand { get; }
- public ReactiveCommand ExitCommand { get; }
- public ReactiveCommand SettingsCommand { get; }
- public ReactiveCommand ImportDatCommand { get; }
- public ReactiveCommand ImportDatFolderCommand { get; }
- public ReactiveCommand ImportRomFolderCommand { get; }
- public ReactiveCommand DeleteRomSetCommand { get; }
- public ReactiveCommand EditRomSetCommand { get; }
- public ReactiveCommand ExportDatCommand { get; }
- public ReactiveCommand ExportRomsCommand { get; }
- public ReactiveCommand MountCommand { get; }
- public ReactiveCommand UmountCommand { get; }
- public ReactiveCommand UpdateStatsCommand { get; }
-
- public Vfs Vfs
- {
- get => _vfs;
- set => this.RaiseAndSetIfChanged(ref _vfs, value);
- }
-
- public RomSetModel SelectedRomSet
- {
- get => _selectedRomSet;
- set => this.RaiseAndSetIfChanged(ref _selectedRomSet, value);
- }
+ public ICommand AboutCommand { get; }
+ public ICommand ExitCommand { get; }
+ public ICommand SettingsCommand { get; }
+ public ICommand ImportDatCommand { get; }
+ public ICommand ImportDatFolderCommand { get; }
+ public ICommand ImportRomFolderCommand { get; }
+ public ICommand DeleteRomSetCommand { get; }
+ public ICommand EditRomSetCommand { get; }
+ public ICommand ExportDatCommand { get; }
+ public ICommand ExportRomsCommand { get; }
+ public ICommand MountCommand { get; }
+ public ICommand UmountCommand { get; }
+ public ICommand UpdateStatsCommand { get; }
internal Task ExecuteSettingsCommandAsync()
{
diff --git a/RomRepoMgr/ViewModels/RemoveDatViewModel.cs b/RomRepoMgr/ViewModels/RemoveDatViewModel.cs
index 53a2d84..b6e00cb 100644
--- a/RomRepoMgr/ViewModels/RemoveDatViewModel.cs
+++ b/RomRepoMgr/ViewModels/RemoveDatViewModel.cs
@@ -26,7 +26,7 @@
using System.IO;
using System.Threading.Tasks;
using Avalonia.Threading;
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
using RomRepoMgr.Core;
using RomRepoMgr.Database;
using RomRepoMgr.Database.Models;
@@ -35,11 +35,12 @@ using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public sealed class RemoveDatViewModel : ViewModelBase
+public sealed partial class RemoveDatViewModel : ViewModelBase
{
readonly long _romSetId;
readonly RemoveDat _view;
- string _statusMessage;
+ [ObservableProperty]
+ string _statusMessage;
// Mock
public RemoveDatViewModel() {}
@@ -50,12 +51,6 @@ public sealed class RemoveDatViewModel : ViewModelBase
_romSetId = romSetId;
}
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
internal void OnOpened()
{
_ = Task.Run(() =>
diff --git a/RomRepoMgr/ViewModels/SettingsViewModel.cs b/RomRepoMgr/ViewModels/SettingsViewModel.cs
index 2036955..5dc6bee 100644
--- a/RomRepoMgr/ViewModels/SettingsViewModel.cs
+++ b/RomRepoMgr/ViewModels/SettingsViewModel.cs
@@ -26,14 +26,15 @@
using System;
using System.Collections.Generic;
using System.IO;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using Microsoft.EntityFrameworkCore;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;
-using ReactiveUI;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Database;
@@ -43,7 +44,7 @@ using ErrorEventArgs = RomRepoMgr.Core.EventArgs.ErrorEventArgs;
namespace RomRepoMgr.ViewModels;
-public sealed class SettingsViewModel : ViewModelBase
+public sealed partial class SettingsViewModel : ViewModelBase
{
readonly SettingsDialog _view;
bool _databaseChanged;
@@ -53,8 +54,10 @@ public sealed class SettingsViewModel : ViewModelBase
bool _temporaryChanged;
string _temporaryPath;
bool _unArChanged;
- string _unArPath;
- string _unArVersion;
+ [ObservableProperty]
+ string _unArPath;
+ [ObservableProperty]
+ string _unArVersion;
// Mock
public SettingsViewModel() {}
@@ -67,12 +70,12 @@ public sealed class SettingsViewModel : ViewModelBase
_temporaryChanged = false;
_unArChanged = false;
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
- UnArCommand = ReactiveCommand.CreateFromTask(ExecuteUnArCommandAsync);
- TemporaryCommand = ReactiveCommand.CreateFromTask(ExecuteTemporaryCommandAsync);
- RepositoryCommand = ReactiveCommand.CreateFromTask(ExecuteRepositoryCommandAsync);
- DatabaseCommand = ReactiveCommand.CreateFromTask(ExecuteDatabaseCommandAsync);
- SaveCommand = ReactiveCommand.Create(ExecuteSaveCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
+ UnArCommand = new AsyncRelayCommand(ExecuteUnArCommandAsync);
+ TemporaryCommand = new AsyncRelayCommand(ExecuteTemporaryCommandAsync);
+ RepositoryCommand = new AsyncRelayCommand(ExecuteRepositoryCommandAsync);
+ DatabaseCommand = new AsyncRelayCommand(ExecuteDatabaseCommandAsync);
+ SaveCommand = new RelayCommand(ExecuteSaveCommand);
DatabasePath = Settings.Settings.Current.DatabasePath;
RepositoryPath = Settings.Settings.Current.RepositoryPath;
@@ -82,19 +85,19 @@ public sealed class SettingsViewModel : ViewModelBase
if(!string.IsNullOrWhiteSpace(UnArPath)) CheckUnAr();
}
- public ReactiveCommand UnArCommand { get; }
- public ReactiveCommand TemporaryCommand { get; }
- public ReactiveCommand RepositoryCommand { get; }
- public ReactiveCommand DatabaseCommand { get; }
- public ReactiveCommand CloseCommand { get; }
- public ReactiveCommand SaveCommand { get; }
+ public ICommand UnArCommand { get; }
+ public ICommand TemporaryCommand { get; }
+ public ICommand RepositoryCommand { get; }
+ public ICommand DatabaseCommand { get; }
+ public ICommand CloseCommand { get; }
+ public ICommand SaveCommand { get; }
public string DatabasePath
{
get => _databasePath;
set
{
- this.RaiseAndSetIfChanged(ref _databasePath, value);
+ SetProperty(ref _databasePath, value);
_databaseChanged = true;
}
}
@@ -104,7 +107,7 @@ public sealed class SettingsViewModel : ViewModelBase
get => _repositoryPath;
set
{
- this.RaiseAndSetIfChanged(ref _repositoryPath, value);
+ SetProperty(ref _repositoryPath, value);
// TODO: Refresh repository existing files
_repositoryChanged = true;
@@ -116,23 +119,11 @@ public sealed class SettingsViewModel : ViewModelBase
get => _temporaryPath;
set
{
- this.RaiseAndSetIfChanged(ref _temporaryPath, value);
+ SetProperty(ref _temporaryPath, value);
_temporaryChanged = true;
}
}
- public string UnArPath
- {
- get => _unArPath;
- set => this.RaiseAndSetIfChanged(ref _unArPath, value);
- }
-
- public string UnArVersion
- {
- get => _unArVersion;
- set => this.RaiseAndSetIfChanged(ref _unArVersion, value);
- }
-
void CheckUnAr()
{
var worker = new Compression();
diff --git a/RomRepoMgr/ViewModels/SplashWindowViewModel.cs b/RomRepoMgr/ViewModels/SplashWindowViewModel.cs
index 3af0044..0df76b6 100644
--- a/RomRepoMgr/ViewModels/SplashWindowViewModel.cs
+++ b/RomRepoMgr/ViewModels/SplashWindowViewModel.cs
@@ -26,13 +26,14 @@
using System;
using System.IO;
using System.Linq;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Threading;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using Microsoft.EntityFrameworkCore;
-using ReactiveUI;
using RomRepoMgr.Core.EventArgs;
using RomRepoMgr.Core.Models;
using RomRepoMgr.Core.Workers;
@@ -40,28 +41,44 @@ using RomRepoMgr.Database;
namespace RomRepoMgr.ViewModels;
-public sealed class SplashWindowViewModel : ViewModelBase
+public sealed partial class SplashWindowViewModel : ViewModelBase
{
+ [ObservableProperty]
bool _checkingUnArError;
+ [ObservableProperty]
bool _checkingUnArOk;
+ [ObservableProperty]
bool _checkingUnArUnknown;
+ [ObservableProperty]
bool _exitVisible;
+ [ObservableProperty]
bool _loadingDatabaseError;
+ [ObservableProperty]
bool _loadingDatabaseOk;
+ [ObservableProperty]
bool _loadingDatabaseUnknown;
+ [ObservableProperty]
bool _loadingRomSetsError;
+ [ObservableProperty]
bool _loadingRomSetsOk;
+ [ObservableProperty]
bool _loadingRomSetsUnknown;
+ [ObservableProperty]
bool _loadingSettingsError;
+ [ObservableProperty]
bool _loadingSettingsOk;
+ [ObservableProperty]
bool _loadingSettingsUnknown;
+ [ObservableProperty]
bool _migratingDatabaseError;
+ [ObservableProperty]
bool _migratingDatabaseOk;
+ [ObservableProperty]
bool _migratingDatabaseUnknown;
public SplashWindowViewModel()
{
- ExitCommand = ReactiveCommand.Create(ExecuteExitCommand);
+ ExitCommand = new RelayCommand(ExecuteExitCommand);
LoadingSettingsOk = false;
LoadingSettingsError = false;
@@ -81,103 +98,7 @@ public sealed class SplashWindowViewModel : ViewModelBase
ExitVisible = false;
}
- public ReactiveCommand ExitCommand { get; }
-
- public bool LoadingSettingsOk
- {
- get => _loadingSettingsOk;
- set => this.RaiseAndSetIfChanged(ref _loadingSettingsOk, value);
- }
-
- public bool LoadingSettingsError
- {
- get => _loadingSettingsError;
- set => this.RaiseAndSetIfChanged(ref _loadingSettingsError, value);
- }
-
- public bool LoadingSettingsUnknown
- {
- get => _loadingSettingsUnknown;
- set => this.RaiseAndSetIfChanged(ref _loadingSettingsUnknown, value);
- }
-
- public bool CheckingUnArOk
- {
- get => _checkingUnArOk;
- set => this.RaiseAndSetIfChanged(ref _checkingUnArOk, value);
- }
-
- public bool CheckingUnArError
- {
- get => _checkingUnArError;
- set => this.RaiseAndSetIfChanged(ref _checkingUnArError, value);
- }
-
- public bool CheckingUnArUnknown
- {
- get => _checkingUnArUnknown;
- set => this.RaiseAndSetIfChanged(ref _checkingUnArUnknown, value);
- }
-
- public bool LoadingDatabaseOk
- {
- get => _loadingDatabaseOk;
- set => this.RaiseAndSetIfChanged(ref _loadingDatabaseOk, value);
- }
-
- public bool LoadingDatabaseError
- {
- get => _loadingDatabaseError;
- set => this.RaiseAndSetIfChanged(ref _loadingDatabaseError, value);
- }
-
- public bool LoadingDatabaseUnknown
- {
- get => _loadingDatabaseUnknown;
- set => this.RaiseAndSetIfChanged(ref _loadingDatabaseUnknown, value);
- }
-
- public bool MigratingDatabaseOk
- {
- get => _migratingDatabaseOk;
- set => this.RaiseAndSetIfChanged(ref _migratingDatabaseOk, value);
- }
-
- public bool MigratingDatabaseError
- {
- get => _migratingDatabaseError;
- set => this.RaiseAndSetIfChanged(ref _migratingDatabaseError, value);
- }
-
- public bool MigratingDatabaseUnknown
- {
- get => _migratingDatabaseUnknown;
- set => this.RaiseAndSetIfChanged(ref _migratingDatabaseUnknown, value);
- }
-
- public bool ExitVisible
- {
- get => _exitVisible;
- set => this.RaiseAndSetIfChanged(ref _exitVisible, value);
- }
-
- public bool LoadingRomSetsOk
- {
- get => _loadingRomSetsOk;
- set => this.RaiseAndSetIfChanged(ref _loadingRomSetsOk, value);
- }
-
- public bool LoadingRomSetsError
- {
- get => _loadingRomSetsError;
- set => this.RaiseAndSetIfChanged(ref _loadingRomSetsError, value);
- }
-
- public bool LoadingRomSetsUnknown
- {
- get => _loadingRomSetsUnknown;
- set => this.RaiseAndSetIfChanged(ref _loadingRomSetsUnknown, value);
- }
+ public ICommand ExitCommand { get; }
public string LoadingText => "ROM Repository Manager";
diff --git a/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs b/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
index fbc26cf..4580c6e 100644
--- a/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
+++ b/RomRepoMgr/ViewModels/UpdateStatsViewModel.cs
@@ -26,11 +26,12 @@
using System;
using System.Collections.ObjectModel;
using System.Linq;
-using System.Reactive;
using System.Threading.Tasks;
+using System.Windows.Input;
using Avalonia.Threading;
+using CommunityToolkit.Mvvm.ComponentModel;
+using CommunityToolkit.Mvvm.Input;
using Microsoft.EntityFrameworkCore;
-using ReactiveUI;
using RomRepoMgr.Core.Models;
using RomRepoMgr.Database;
using RomRepoMgr.Database.Models;
@@ -39,17 +40,25 @@ using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
-public sealed class UpdateStatsViewModel : ViewModelBase
+public sealed partial class UpdateStatsViewModel : ViewModelBase
{
readonly UpdateStats _view;
- bool _canClose;
- double _currentValue;
- bool _indeterminateProgress;
- double _maximumValue;
- double _minimumValue;
- bool _progressVisible;
- RomSetModel _selectedRomSet;
- string _statusMessage;
+ [ObservableProperty]
+ bool _canClose;
+ [ObservableProperty]
+ double _currentValue;
+ [ObservableProperty]
+ bool _indeterminateProgress;
+ [ObservableProperty]
+ double _maximumValue;
+ [ObservableProperty]
+ double _minimumValue;
+ [ObservableProperty]
+ bool _progressVisible;
+ [ObservableProperty]
+ RomSetModel _selectedRomSet;
+ [ObservableProperty]
+ string _statusMessage;
// Mock
public UpdateStatsViewModel() {}
@@ -57,63 +66,15 @@ public sealed class UpdateStatsViewModel : ViewModelBase
public UpdateStatsViewModel(UpdateStats view)
{
_view = view;
- CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
+ CloseCommand = new RelayCommand(ExecuteCloseCommand);
IndeterminateProgress = true;
ProgressVisible = false;
RomSets = [];
}
- public string StatusMessage
- {
- get => _statusMessage;
- set => this.RaiseAndSetIfChanged(ref _statusMessage, value);
- }
-
- public bool IndeterminateProgress
- {
- get => _indeterminateProgress;
- set => this.RaiseAndSetIfChanged(ref _indeterminateProgress, value);
- }
-
- public double MaximumValue
- {
- get => _maximumValue;
- set => this.RaiseAndSetIfChanged(ref _maximumValue, value);
- }
-
- public double MinimumValue
- {
- get => _minimumValue;
- set => this.RaiseAndSetIfChanged(ref _minimumValue, value);
- }
-
- public double CurrentValue
- {
- get => _currentValue;
- set => this.RaiseAndSetIfChanged(ref _currentValue, value);
- }
-
- public bool ProgressVisible
- {
- get => _progressVisible;
- set => this.RaiseAndSetIfChanged(ref _progressVisible, value);
- }
-
- public RomSetModel SelectedRomSet
- {
- get => _selectedRomSet;
- set => this.RaiseAndSetIfChanged(ref _selectedRomSet, value);
- }
-
- public bool CanClose
- {
- get => _canClose;
- set => this.RaiseAndSetIfChanged(ref _canClose, value);
- }
-
public ObservableCollection RomSets { get; }
- public ReactiveCommand CloseCommand { get; }
+ public ICommand CloseCommand { get; }
internal void OnOpened()
{
diff --git a/RomRepoMgr/ViewModels/ViewModelBase.cs b/RomRepoMgr/ViewModels/ViewModelBase.cs
index 7c00218..9df7ad2 100644
--- a/RomRepoMgr/ViewModels/ViewModelBase.cs
+++ b/RomRepoMgr/ViewModels/ViewModelBase.cs
@@ -23,8 +23,8 @@
// Copyright © 2020-2024 Natalia Portillo
*******************************************************************************/
-using ReactiveUI;
+using CommunityToolkit.Mvvm.ComponentModel;
namespace RomRepoMgr.ViewModels;
-public class ViewModelBase : ReactiveObject {}
\ No newline at end of file
+public class ViewModelBase : ObservableObject;
\ No newline at end of file