diff --git a/RomRepoMgr/App.xaml b/RomRepoMgr/App.xaml
index 8895765..e2f6158 100644
--- a/RomRepoMgr/App.xaml
+++ b/RomRepoMgr/App.xaml
@@ -7,4 +7,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RomRepoMgr/App.xaml.cs b/RomRepoMgr/App.xaml.cs
index 14a7810..7e7e623 100644
--- a/RomRepoMgr/App.xaml.cs
+++ b/RomRepoMgr/App.xaml.cs
@@ -64,11 +64,41 @@ namespace RomRepoMgr
// Create and show main window
desktop.MainWindow = new MainWindow();
- desktop.MainWindow.DataContext = new MainWindowViewModel();
+ desktop.MainWindow.DataContext = new MainWindowViewModel(desktop.MainWindow as MainWindow);
desktop.MainWindow.Show();
// Now can close when all windows are closed
desktop.ShutdownMode = ShutdownMode.OnLastWindowClose;
}
+
+ void OnAboutClicked(object sender, EventArgs args)
+ {
+ if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) ||
+ !(desktop.MainWindow is MainWindow mainWindow) ||
+ !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel))
+ return;
+
+ mainWindowViewModel.ExecuteAboutCommand();
+ }
+
+ void OnQuitClicked(object sender, EventArgs args)
+ {
+ if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) ||
+ !(desktop.MainWindow is MainWindow mainWindow) ||
+ !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel))
+ return;
+
+ mainWindowViewModel.ExecuteExitCommand();
+ }
+
+ void OnPreferencesClicked(object sender, EventArgs args)
+ {
+ if(!(ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) ||
+ !(desktop.MainWindow is MainWindow mainWindow) ||
+ !(mainWindow.DataContext is MainWindowViewModel mainWindowViewModel))
+ return;
+
+ mainWindowViewModel.ExecuteSettingsCommand();
+ }
}
}
\ No newline at end of file
diff --git a/RomRepoMgr/Models/AssemblyModel.cs b/RomRepoMgr/Models/AssemblyModel.cs
new file mode 100644
index 0000000..02ee441
--- /dev/null
+++ b/RomRepoMgr/Models/AssemblyModel.cs
@@ -0,0 +1,33 @@
+/******************************************************************************
+// RomRepoMgr - ROM repository manager
+// ----------------------------------------------------------------------------
+//
+// Author(s) : Natalia Portillo
+//
+// --[ 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 .
+//
+// ----------------------------------------------------------------------------
+// Copyright © 2020 Natalia Portillo
+*******************************************************************************/
+
+namespace RomRepoMgr.Models
+{
+ public sealed class AssemblyModel
+ {
+ public string Name { get; set; }
+ public string Version { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/RomRepoMgr/RomRepoMgr.csproj b/RomRepoMgr/RomRepoMgr.csproj
index dee2f2e..09576ed 100644
--- a/RomRepoMgr/RomRepoMgr.csproj
+++ b/RomRepoMgr/RomRepoMgr.csproj
@@ -15,6 +15,7 @@
+
diff --git a/RomRepoMgr/ViewModels/AboutViewModel.cs b/RomRepoMgr/ViewModels/AboutViewModel.cs
new file mode 100644
index 0000000..d67b53e
--- /dev/null
+++ b/RomRepoMgr/ViewModels/AboutViewModel.cs
@@ -0,0 +1,171 @@
+/******************************************************************************
+// RomRepoMgr - ROM repository manager
+// ----------------------------------------------------------------------------
+//
+// Author(s) : Natalia Portillo
+//
+// --[ 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 .
+//
+// ----------------------------------------------------------------------------
+// Copyright © 2020 Natalia Portillo
+*******************************************************************************/
+
+using System;
+using System.Collections.ObjectModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Reactive;
+using System.Reflection;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Microsoft.DotNet.PlatformAbstractions;
+using ReactiveUI;
+using RomRepoMgr.Models;
+using RomRepoMgr.Views;
+
+namespace RomRepoMgr.ViewModels
+{
+ public sealed class AboutViewModel : ViewModelBase
+ {
+ readonly About _view;
+ string _versionText;
+
+ public AboutViewModel(About view)
+ {
+ _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();
+
+ // TODO: They do not load in time
+ Task.Run(() =>
+ {
+ foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies().OrderBy(a => a.FullName))
+ {
+ string name = assembly.GetName().Name;
+
+ string version =
+ (Attribute.GetCustomAttribute(assembly, typeof(AssemblyInformationalVersionAttribute)) as
+ AssemblyInformationalVersionAttribute)?.InformationalVersion;
+
+ if(name is null ||
+ version is null)
+ continue;
+
+ Assemblies.Add(new AssemblyModel
+ {
+ Name = name,
+ Version = version
+ });
+ }
+ });
+ }
+
+ [NotNull]
+ public string AboutLabel => "About";
+ [NotNull]
+ public string LibrariesLabel => "Libraries";
+ [NotNull]
+ public string AuthorsLabel => "Authors";
+ [NotNull]
+ public string Title => "About ROM Repository Manager";
+ [NotNull]
+ public string SoftwareName => "RomRepoMgr";
+ [NotNull]
+ public string SuiteName => "ROM Repository Manager";
+ [NotNull]
+ public string Copyright => "© 2020 Natalia Portillo";
+ [NotNull]
+ public string Website => "https://www.claunia.com";
+ [NotNull]
+ public string License => "License: GNU General Public License Version 3";
+ [NotNull]
+ public string CloseLabel => "Close";
+ [NotNull]
+ public string AssembliesLibraryText => "Library";
+ [NotNull]
+ public string AssembliesVersionText => "Version";
+ [NotNull]
+ public string Authors => @"Developers:
+ Natalia Portillo
+";
+ public ReactiveCommand WebsiteCommand { get; }
+ public ReactiveCommand LicenseCommand { get; }
+ public ReactiveCommand CloseCommand { get; }
+ public ObservableCollection Assemblies { get; }
+
+ public string VersionText
+ {
+ get => _versionText;
+ set => this.RaiseAndSetIfChanged(ref _versionText, value);
+ }
+
+ void ExecuteWebsiteCommand()
+ {
+ var process = new Process
+ {
+ StartInfo =
+ {
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ Arguments = "https://www.claunia.com"
+ }
+ };
+
+ 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();
+ }
+
+ void ExecuteLicenseCommand()
+ {
+ /* var dialog = new LicenseDialog();
+ dialog.DataContext = new LicenseViewModel(dialog);
+ dialog.ShowDialog(_view);*/
+ }
+
+ void ExecuteCloseCommand() => _view.Close();
+ }
+}
\ No newline at end of file
diff --git a/RomRepoMgr/ViewModels/MainWindowViewModel.cs b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
index 7ce869a..0026bb7 100644
--- a/RomRepoMgr/ViewModels/MainWindowViewModel.cs
+++ b/RomRepoMgr/ViewModels/MainWindowViewModel.cs
@@ -23,10 +23,51 @@
// Copyright © 2020 Natalia Portillo
*******************************************************************************/
+using System.Reactive;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Controls.ApplicationLifetimes;
+using ReactiveUI;
+using RomRepoMgr.Views;
+
namespace RomRepoMgr.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
+ readonly MainWindow _view;
+
+ public MainWindowViewModel(MainWindow view)
+ {
+ _view = view;
+ ExitCommand = ReactiveCommand.Create(ExecuteExitCommand);
+ SettingsCommand = ReactiveCommand.Create(ExecuteSettingsCommand);
+ AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand);
+ }
+
public string Greeting => "Hello World!";
+ public bool NativeMenuSupported =>
+ NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as
+ IClassicDesktopStyleApplicationLifetime)?.MainWindow);
+
+ public ReactiveCommand AboutCommand { get; }
+ public ReactiveCommand ExitCommand { get; }
+ public ReactiveCommand SettingsCommand { get; }
+
+ internal async void ExecuteSettingsCommand()
+ {
+ /*var dialog = new SettingsDialog();
+ dialog.DataContext = new SettingsViewModel(dialog, false);
+ await dialog.ShowDialog(_view);*/
+ }
+
+ internal void ExecuteExitCommand() =>
+ (Application.Current.ApplicationLifetime as ClassicDesktopStyleApplicationLifetime)?.Shutdown();
+
+ internal void ExecuteAboutCommand()
+ {
+ var dialog = new About();
+ dialog.DataContext = new AboutViewModel(dialog);
+ dialog.ShowDialog(_view);
+ }
}
}
\ No newline at end of file
diff --git a/RomRepoMgr/Views/About.xaml b/RomRepoMgr/Views/About.xaml
new file mode 100644
index 0000000..3301c60
--- /dev/null
+++ b/RomRepoMgr/Views/About.xaml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RomRepoMgr/Views/About.xaml.cs b/RomRepoMgr/Views/About.xaml.cs
new file mode 100644
index 0000000..f631741
--- /dev/null
+++ b/RomRepoMgr/Views/About.xaml.cs
@@ -0,0 +1,37 @@
+/******************************************************************************
+// RomRepoMgr - ROM repository manager
+// ----------------------------------------------------------------------------
+//
+// Author(s) : Natalia Portillo
+//
+// --[ 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 .
+//
+// ----------------------------------------------------------------------------
+// Copyright © 2020 Natalia Portillo
+*******************************************************************************/
+
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+
+namespace RomRepoMgr.Views
+{
+ public sealed class About : Window
+ {
+ public About() => InitializeComponent();
+
+ void InitializeComponent() => AvaloniaXamlLoader.Load(this);
+ }
+}
\ No newline at end of file
diff --git a/RomRepoMgr/Views/MainWindow.xaml b/RomRepoMgr/Views/MainWindow.xaml
index 5cf0182..710127e 100644
--- a/RomRepoMgr/Views/MainWindow.xaml
+++ b/RomRepoMgr/Views/MainWindow.xaml
@@ -6,5 +6,19 @@
-
+
+
+
+
\ No newline at end of file