5 Commits

23 changed files with 117 additions and 48 deletions

View File

@@ -25,11 +25,9 @@
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 Avalonia.Threading;
using ReactiveUI;
@@ -43,10 +41,35 @@ public sealed class AboutViewModel : ViewModelBase
readonly About _view;
string _versionText;
public AboutViewModel()
{
LoadData();
}
public AboutViewModel(About view)
{
_view = view;
LoadData();
}
public string SoftwareName => "RomRepoMgr";
public string SuiteName => "ROM Repository Manager";
public string Copyright => "© 2020-2024 Natalia Portillo";
public string Website => "https://www.claunia.com";
public ReactiveCommand<Unit, Unit> WebsiteCommand { get; private set; }
public ReactiveCommand<Unit, Unit> LicenseCommand { get; private set; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; private set; }
public ObservableCollection<AssemblyModel> 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;
@@ -81,21 +104,6 @@ public sealed class AboutViewModel : ViewModelBase
});
}
public string SoftwareName => "RomRepoMgr";
public string SuiteName => "ROM Repository Manager";
public string Copyright => "© 2020-2024 Natalia Portillo";
public string Website => "https://www.claunia.com";
public ReactiveCommand<Unit, Unit> WebsiteCommand { get; }
public ReactiveCommand<Unit, Unit> LicenseCommand { get; }
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
public ObservableCollection<AssemblyModel> Assemblies { get; }
public string VersionText
{
get => _versionText;
set => this.RaiseAndSetIfChanged(ref _versionText, value);
}
void ExecuteWebsiteCommand()
{
_ = _view.Launcher.LaunchUriAsync(new Uri("https://www.claunia.com"));

View File

@@ -49,6 +49,41 @@ public class EditDatViewModel : ViewModelBase
string _name;
string _version;
// Mock
public EditDatViewModel()
{
var romSet = new RomSetModel
{
Author = "Author",
Comment = "Comment",
Category = "Category",
Date = "Date",
Description = "Description",
Homepage = "http://example.com",
Name = "Name",
Version = "Version",
Filename = "Filename.dat",
Sha384 = "MOCKEDSHA384HASH",
TotalMachines = 100,
CompleteMachines = 80,
IncompleteMachines = 20,
TotalRoms = 1000,
HaveRoms = 800,
MissRoms = 200,
Id = 1
};
_romSet = romSet;
_name = romSet.Name;
_version = romSet.Version;
_author = romSet.Author;
_comment = romSet.Comment;
_category = romSet.Category;
_date = romSet.Date;
_description = romSet.Description;
_homepage = romSet.Homepage;
}
public EditDatViewModel(EditDat view, RomSetModel romSet)
{
_view = view;

View File

@@ -49,6 +49,9 @@ public sealed class ExportDatViewModel : ViewModelBase
bool _progressVisible;
string _statusMessage;
// Mock
public ExportDatViewModel() {}
public ExportDatViewModel(ExportDat view, string datHash, string outPath)
{
_view = view;

View File

@@ -58,6 +58,14 @@ public sealed class ExportRomsViewModel : ViewModelBase
string _status3Message;
string _statusMessage;
// Mock
public ExportRomsViewModel()
{
#pragma warning disable PH2080
FolderPath = "C:\\ExportedRoms";
#pragma warning restore PH2080
}
public ExportRomsViewModel(ExportRoms view, string folderPath, long romSetId)
{
_view = view;

View File

@@ -64,6 +64,14 @@ public sealed class ImportDatFolderViewModel : ViewModelBase
string _status2Message;
string _statusMessage;
// Mock
public ImportDatFolderViewModel()
{
#pragma warning disable PH2080
FolderPath = "C:\\ROMs";
#pragma warning restore PH2080
}
public ImportDatFolderViewModel(ImportDatFolder view, string folderPath)
{
_view = view;

View File

@@ -48,6 +48,9 @@ public sealed class ImportDatViewModel : ViewModelBase
bool _progressVisible;
string _statusMessage;
// Mock
public ImportDatViewModel() {}
public ImportDatViewModel(ImportDat view, string datPath)
{
_view = view;

View File

@@ -61,6 +61,14 @@ public sealed class ImportRomFolderViewModel : ViewModelBase
string _status2Message;
string _statusMessage;
// Mock
public ImportRomFolderViewModel()
{
#pragma warning disable PH2080
FolderPath = "C:\\ROMs";
#pragma warning restore PH2080
}
public ImportRomFolderViewModel(ImportRomFolder view, string folderPath)
{
_view = view;

View File

@@ -52,6 +52,9 @@ public class MainWindowViewModel : ViewModelBase
RomSetModel _selectedRomSet;
Vfs _vfs;
// Mock
public MainWindowViewModel() {}
public MainWindowViewModel(MainWindow view, List<RomSetModel> romSets)
{
_view = view;

View File

@@ -35,9 +35,20 @@ using RomRepoMgr.Views;
namespace RomRepoMgr.ViewModels;
public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewModelBase
public sealed class RemoveDatViewModel : ViewModelBase
{
string _statusMessage;
readonly long _romSetId;
readonly RemoveDat _view;
string _statusMessage;
// Mock
public RemoveDatViewModel() {}
public RemoveDatViewModel(RemoveDat view, long romSetId)
{
_view = view;
_romSetId = romSetId;
}
public string StatusMessage
{
@@ -53,7 +64,7 @@ public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewMode
Dispatcher.UIThread.Post(() => StatusMessage = Localization.RetrievingRomSetFromDatabase);
RomSet romSet = ctx.RomSets.Find(romSetId);
RomSet romSet = ctx.RomSets.Find(_romSetId);
if(romSet == null) return;
@@ -93,7 +104,7 @@ public sealed class RemoveDatViewModel(RemoveDat view, long romSetId) : ViewMode
if(File.Exists(compressedDatPath)) File.Delete(compressedDatPath);
Dispatcher.UIThread.Post(view.Close);
Dispatcher.UIThread.Post(_view.Close);
});
}
}

View File

@@ -56,6 +56,9 @@ public sealed class SettingsViewModel : ViewModelBase
string _unArPath;
string _unArVersion;
// Mock
public SettingsViewModel() {}
public SettingsViewModel(SettingsDialog view)
{
_view = view;

View File

@@ -51,6 +51,9 @@ public sealed class UpdateStatsViewModel : ViewModelBase
RomSetModel _selectedRomSet;
string _statusMessage;
// Mock
public UpdateStatsViewModel() {}
public UpdateStatsViewModel(UpdateStats view)
{
_view = view;

View File

@@ -31,10 +31,8 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="320"
Width="600"
Height="400"
x:Class="RomRepoMgr.Views.About"
Icon="/Assets/avalonia-logo.ico"
CanResize="False"

View File

@@ -31,10 +31,8 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="720"
Height="480"
Height="500"
x:Class="RomRepoMgr.Views.EditDat"
Icon="/Assets/avalonia-logo.ico"
CanResize="False"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="90"
x:Class="RomRepoMgr.Views.ExportDat"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="150"
x:Class="RomRepoMgr.Views.ExportRoms"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="90"
x:Class="RomRepoMgr.Views.ImportDat"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="360"
x:Class="RomRepoMgr.Views.ImportDatFolder"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="360"
x:Class="RomRepoMgr.Views.ImportRomFolder"

View File

@@ -5,8 +5,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
x:Class="RomRepoMgr.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="RomRepoMgr">

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="90"
x:Class="RomRepoMgr.Views.RemoveDat"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
Width="480"
Height="320"
x:Class="RomRepoMgr.Views.SettingsDialog"

View File

@@ -6,8 +6,6 @@
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="450"
d:DesignHeight="250"
x:Class="RomRepoMgr.Views.SplashWindow"
Icon="/Assets/avalonia-logo.ico"
Title="ROM Repository Manager"

View File

@@ -31,8 +31,6 @@
xmlns:vm="clr-namespace:RomRepoMgr.ViewModels;assembly=RomRepoMgr"
xmlns:resources="clr-namespace:RomRepoMgr.Resources"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
x:Class="RomRepoMgr.Views.UpdateStats"
Icon="/Assets/avalonia-logo.ico"
CanResize="False"