2020-04-17 21:45:50 +01:00
|
|
|
|
// /***************************************************************************
|
|
|
|
|
|
// Aaru Data Preservation Suite
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// Filename : LicenseViewModel.cs
|
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
|
//
|
|
|
|
|
|
// Component : GUI view models.
|
|
|
|
|
|
//
|
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
//
|
|
|
|
|
|
// View model and code for the license 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/>.
|
|
|
|
|
|
//
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-05-01 04:17:32 +01:00
|
|
|
|
// Copyright © 2011-2024 Natalia Portillo
|
2020-04-17 21:45:50 +01:00
|
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
2020-04-10 02:28:10 +01:00
|
|
|
|
using System.Reactive;
|
|
|
|
|
|
using System.Reflection;
|
2020-04-16 20:40:25 +01:00
|
|
|
|
using Aaru.Gui.Views.Dialogs;
|
2022-11-19 21:10:41 +00:00
|
|
|
|
using Aaru.Localization;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2020-04-10 02:28:10 +01:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
|
namespace Aaru.Gui.ViewModels.Dialogs;
|
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public sealed class LicenseViewModel : ViewModelBase
|
2020-04-10 02:28:10 +01:00
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
|
readonly LicenseDialog _view;
|
|
|
|
|
|
string _versionText;
|
2020-04-10 02:28:10 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public LicenseViewModel(LicenseDialog view)
|
|
|
|
|
|
{
|
|
|
|
|
|
_view = view;
|
|
|
|
|
|
CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
|
2020-04-10 02:28:10 +01:00
|
|
|
|
|
2022-11-19 21:10:41 +00:00
|
|
|
|
// TODO: Localize
|
2022-03-06 13:29:38 +00:00
|
|
|
|
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Aaru.Gui.LICENSE");
|
2020-07-22 13:20:25 +01:00
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
|
if(stream == null) return;
|
2020-07-22 13:20:25 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
using var reader = new StreamReader(stream);
|
2020-07-22 13:20:25 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
LicenseText = reader.ReadToEnd();
|
|
|
|
|
|
}
|
2020-04-10 02:28:10 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string Title => UI.Title_Aaru_license;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
[NotNull]
|
2022-11-19 21:10:41 +00:00
|
|
|
|
public string CloseLabel => UI.ButtonLabel_Close;
|
2023-10-03 23:27:57 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
public string LicenseText { get; }
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> CloseCommand { get; }
|
2020-04-10 02:28:10 +01:00
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
|
void ExecuteCloseCommand() => _view.Close();
|
2020-04-10 02:28:10 +01:00
|
|
|
|
}
|