2020-04-17 21:45:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : AboutViewModel.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// View model and code for the about dialog.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2020-12-31 23:08:23 +00:00
|
|
|
|
// Copyright © 2011-2021 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reactive;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Aaru.Gui.Models;
|
2020-04-16 20:40:25 +01:00
|
|
|
|
using Aaru.Gui.Views.Dialogs;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
2020-04-16 20:40:25 +01:00
|
|
|
|
namespace Aaru.Gui.ViewModels.Dialogs
|
2020-04-10 01:10:55 +01:00
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
public sealed class AboutViewModel : ViewModelBase
|
2020-04-10 01:10:55 +01:00
|
|
|
|
{
|
2020-04-16 21:29:40 +01:00
|
|
|
|
readonly About _view;
|
|
|
|
|
|
string _versionText;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
|
2020-04-16 21:29:40 +01:00
|
|
|
|
public AboutViewModel(About view)
|
2020-04-10 01:10:55 +01:00
|
|
|
|
{
|
|
|
|
|
|
_view = view;
|
|
|
|
|
|
|
|
|
|
|
|
VersionText =
|
|
|
|
|
|
(Attribute.GetCustomAttribute(typeof(App).Assembly, typeof(AssemblyInformationalVersionAttribute)) as
|
|
|
|
|
|
AssemblyInformationalVersionAttribute)?.InformationalVersion;
|
|
|
|
|
|
|
|
|
|
|
|
WebsiteCommand = ReactiveCommand.Create(ExecuteWebsiteCommand);
|
|
|
|
|
|
LicenseCommand = ReactiveCommand.Create(ExecuteLicenseCommand);
|
|
|
|
|
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
|
|
|
|
|
|
|
|
|
|
|
Assemblies = new ObservableCollection<AssemblyModel>();
|
|
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
|
|
|
|
|
|
{
|
2020-07-22 13:20:25 +01:00
|
|
|
|
string name = assembly.GetName().Name;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
|
|
|
|
|
|
string version =
|
|
|
|
|
|
(Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as
|
|
|
|
|
|
AssemblyInformationalVersionAttribute)?.InformationalVersion;
|
|
|
|
|
|
|
|
|
|
|
|
if(name is null ||
|
|
|
|
|
|
version is null)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
Assemblies.Add(new AssemblyModel
|
|
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
Name = name,
|
|
|
|
|
|
Version = version
|
2020-04-10 01:10:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-22 13:20:25 +01:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string AboutLabel => "About";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string LibrariesLabel => "Libraries";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string AuthorsLabel => "Authors";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string Title => "About Aaru";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string SoftwareName => "Aaru";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string SuiteName => "Aaru Data Preservation Suite";
|
|
|
|
|
|
[NotNull]
|
2020-12-31 23:08:23 +00:00
|
|
|
|
public string Copyright => "© 2011-2021 Natalia Portillo";
|
2020-07-22 13:20:25 +01:00
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string Website => "https://aaru.app";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string License => "License: GNU General Public License Version 3";
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
|
public string CloseLabel => "Close";
|
|
|
|
|
|
[NotNull]
|
2020-04-10 01:10:55 +01:00
|
|
|
|
public string AssembliesLibraryText => "Library";
|
2020-07-22 13:20:25 +01:00
|
|
|
|
[NotNull]
|
2020-04-10 01:10:55 +01:00
|
|
|
|
public string AssembliesVersionText => "Version";
|
2020-07-22 13:20:25 +01:00
|
|
|
|
[NotNull]
|
2020-04-10 01:10:55 +01:00
|
|
|
|
public string Authors => @"Developers:
|
|
|
|
|
|
Natalia Portillo
|
|
|
|
|
|
Michael Drüing
|
2020-04-15 18:54:38 +01:00
|
|
|
|
Rebecca Wallander
|
2020-04-10 01:10:55 +01:00
|
|
|
|
|
|
|
|
|
|
Testers:
|
|
|
|
|
|
Silas Laspada
|
|
|
|
|
|
|
|
|
|
|
|
Public relations:
|
2020-04-10 18:52:00 +01:00
|
|
|
|
Noah Bacon
|
|
|
|
|
|
|
|
|
|
|
|
Logo and art:
|
|
|
|
|
|
Juan Carlos Pastor Segura (Denymetanol)";
|
2020-04-10 01:10:55 +01:00
|
|
|
|
public ReactiveCommand<Unit, Unit> WebsiteCommand { get; }
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> LicenseCommand { get; }
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
|
|
|
|
|
|
public ObservableCollection<AssemblyModel> Assemblies { get; }
|
|
|
|
|
|
|
|
|
|
|
|
public string VersionText
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _versionText;
|
|
|
|
|
|
set => this.RaiseAndSetIfChanged(ref _versionText, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ExecuteWebsiteCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
var process = new Process
|
|
|
|
|
|
{
|
|
|
|
|
|
StartInfo =
|
|
|
|
|
|
{
|
2020-07-20 04:34:16 +01:00
|
|
|
|
UseShellExecute = false,
|
|
|
|
|
|
CreateNoWindow = true,
|
|
|
|
|
|
Arguments = "https://aaru.app"
|
2020-04-10 01:10:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
switch(RuntimeEnvironment.OperatingSystemPlatform)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Platform.Unknown: return;
|
|
|
|
|
|
case Platform.Windows:
|
|
|
|
|
|
process.StartInfo.FileName = "cmd";
|
|
|
|
|
|
process.StartInfo.Arguments = $"/c start {process.StartInfo.Arguments.Replace("&", "^&")}";
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Platform.FreeBSD:
|
|
|
|
|
|
case Platform.Linux:
|
|
|
|
|
|
process.StartInfo.FileName = "xdg-open";
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Platform.Darwin:
|
|
|
|
|
|
process.StartInfo.FileName = "open";
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
if(Debugger.IsAttached)
|
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
process.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-10 02:28:10 +01:00
|
|
|
|
void ExecuteLicenseCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
var dialog = new LicenseDialog();
|
2020-04-16 21:29:40 +01:00
|
|
|
|
dialog.DataContext = new LicenseViewModel(dialog);
|
2020-04-10 02:28:10 +01:00
|
|
|
|
dialog.ShowDialog(_view);
|
|
|
|
|
|
}
|
2020-04-10 01:10:55 +01:00
|
|
|
|
|
|
|
|
|
|
void ExecuteCloseCommand() => _view.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|