2020-08-22 03:13:49 +01:00
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
// RomRepoMgr - ROM repository manager
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
|
|
// it under the terms of the GNU General Public License as
|
|
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
|
//
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
//
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-11-08 19:13:57 +00:00
|
|
|
|
// Copyright © 2020-2024 Natalia Portillo
|
2020-08-22 03:13:49 +01:00
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-07-24 11:11:27 +01:00
|
|
|
|
using System.Windows.Input;
|
2024-11-09 06:14:25 +00:00
|
|
|
|
using Avalonia.Threading;
|
2025-07-24 11:11:27 +01:00
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
2020-08-22 13:36:39 +01:00
|
|
|
|
using RomRepoMgr.Core.Models;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
using RomRepoMgr.Views;
|
|
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
|
namespace RomRepoMgr.ViewModels;
|
|
|
|
|
|
|
2025-07-24 11:11:27 +01:00
|
|
|
|
public sealed partial class AboutViewModel : ViewModelBase
|
2020-08-22 03:13:49 +01:00
|
|
|
|
{
|
2024-11-09 01:37:59 +00:00
|
|
|
|
readonly About _view;
|
2025-07-24 11:11:27 +01:00
|
|
|
|
[ObservableProperty]
|
|
|
|
|
|
string _versionText;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2025-07-09 01:27:09 +01:00
|
|
|
|
public AboutViewModel()
|
|
|
|
|
|
{
|
|
|
|
|
|
LoadData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
|
public AboutViewModel(About view)
|
|
|
|
|
|
{
|
|
|
|
|
|
_view = view;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2025-07-09 01:27:09 +01:00
|
|
|
|
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";
|
2025-07-24 11:11:27 +01:00
|
|
|
|
public ICommand WebsiteCommand { get; private set; }
|
|
|
|
|
|
public ICommand LicenseCommand { get; private set; }
|
|
|
|
|
|
public ICommand CloseCommand { get; private set; }
|
2025-07-09 01:27:09 +01:00
|
|
|
|
public ObservableCollection<AssemblyModel> Assemblies { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
void LoadData()
|
|
|
|
|
|
{
|
2024-11-09 01:37:59 +00:00
|
|
|
|
VersionText =
|
|
|
|
|
|
(Attribute.GetCustomAttribute(typeof(App).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
|
|
|
|
|
|
AssemblyInformationalVersionAttribute)?.InformationalVersion;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2025-07-24 11:11:27 +01:00
|
|
|
|
WebsiteCommand = new RelayCommand(ExecuteWebsiteCommand);
|
|
|
|
|
|
LicenseCommand = new RelayCommand(ExecuteLicenseCommand);
|
|
|
|
|
|
CloseCommand = new RelayCommand(ExecuteCloseCommand);
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2024-11-12 06:39:06 +00:00
|
|
|
|
Assemblies = [];
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2025-07-07 22:17:27 +01:00
|
|
|
|
_ = Task.Run(() =>
|
2024-11-09 01:37:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
|
2020-08-22 03:13:49 +01:00
|
|
|
|
{
|
2024-11-09 01:37:59 +00:00
|
|
|
|
string name = assembly.GetName().Name;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
|
string version =
|
|
|
|
|
|
(Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as
|
|
|
|
|
|
AssemblyInformationalVersionAttribute)?.InformationalVersion;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2024-11-09 01:37:59 +00:00
|
|
|
|
if(name is null || version is null) continue;
|
2020-08-22 03:13:49 +01:00
|
|
|
|
|
2024-11-09 06:14:25 +00:00
|
|
|
|
Dispatcher.UIThread.Post(() =>
|
2024-11-09 01:37:59 +00:00
|
|
|
|
{
|
2024-11-09 06:14:25 +00:00
|
|
|
|
Assemblies.Add(new AssemblyModel
|
|
|
|
|
|
{
|
|
|
|
|
|
Name = name,
|
|
|
|
|
|
Version = version
|
|
|
|
|
|
});
|
2024-11-09 01:37:59 +00:00
|
|
|
|
});
|
2024-11-08 19:34:02 +00:00
|
|
|
|
}
|
2024-11-09 01:37:59 +00:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ExecuteWebsiteCommand()
|
|
|
|
|
|
{
|
2025-07-08 23:13:20 +01:00
|
|
|
|
_ = _view.Launcher.LaunchUriAsync(new Uri("https://www.claunia.com"));
|
2020-08-22 03:13:49 +01:00
|
|
|
|
}
|
2024-11-09 01:37:59 +00:00
|
|
|
|
|
|
|
|
|
|
void ExecuteLicenseCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
/* var dialog = new LicenseDialog();
|
|
|
|
|
|
dialog.DataContext = new LicenseViewModel(dialog);
|
2024-11-09 06:21:49 +00:00
|
|
|
|
dialog.ShowWindowDialogAsync(_view);*/
|
2024-11-09 01:37:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ExecuteCloseCommand() => _view.Close();
|
2020-08-22 03:13:49 +01:00
|
|
|
|
}
|