2020-04-10 01:10:55 +01:00
|
|
|
|
using System.Reactive;
|
|
|
|
|
|
using Aaru.Gui.Views;
|
2020-04-09 18:18:56 +01:00
|
|
|
|
using Avalonia;
|
|
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
using ReactiveUI;
|
2020-04-09 18:18:56 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Aaru.Gui.ViewModels
|
2020-04-09 02:26:04 +01:00
|
|
|
|
{
|
|
|
|
|
|
public class MainWindowViewModel : ViewModelBase
|
|
|
|
|
|
{
|
2020-04-10 01:10:55 +01:00
|
|
|
|
readonly MainWindow _view;
|
|
|
|
|
|
|
|
|
|
|
|
public MainWindowViewModel(MainWindow view)
|
|
|
|
|
|
{
|
2020-04-10 02:50:38 +01:00
|
|
|
|
AboutCommand = ReactiveCommand.Create(ExecuteAboutCommand);
|
|
|
|
|
|
EncodingsCommand = ReactiveCommand.Create(ExecuteEncodingsCommand);
|
2020-04-10 04:16:48 +01:00
|
|
|
|
PluginsCommand = ReactiveCommand.Create(ExecutePluginsCommand);
|
2020-04-10 02:50:38 +01:00
|
|
|
|
_view = view;
|
2020-04-10 01:10:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 04:18:29 +01:00
|
|
|
|
public string Greeting => "Welcome to Aaru!";
|
2020-04-09 18:18:56 +01:00
|
|
|
|
|
2020-04-10 01:10:55 +01:00
|
|
|
|
public bool NativeMenuNotSupported =>
|
|
|
|
|
|
!NativeMenu.GetIsNativeMenuExported((Application.Current.ApplicationLifetime as
|
|
|
|
|
|
IClassicDesktopStyleApplicationLifetime)?.MainWindow);
|
|
|
|
|
|
|
2020-04-10 02:50:38 +01:00
|
|
|
|
public ReactiveCommand<Unit, Unit> AboutCommand { get; }
|
|
|
|
|
|
public ReactiveCommand<Unit, Unit> EncodingsCommand { get; }
|
2020-04-10 04:16:48 +01:00
|
|
|
|
public ReactiveCommand<Unit, Unit> PluginsCommand { get; }
|
2020-04-10 01:10:55 +01:00
|
|
|
|
|
|
|
|
|
|
internal void ExecuteAboutCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
var dialog = new AboutDialog();
|
|
|
|
|
|
dialog.DataContext = new AboutDialogViewModel(dialog);
|
|
|
|
|
|
dialog.ShowDialog(_view);
|
|
|
|
|
|
}
|
2020-04-10 02:50:38 +01:00
|
|
|
|
|
|
|
|
|
|
internal void ExecuteEncodingsCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
var dialog = new EncodingsDialog();
|
|
|
|
|
|
dialog.DataContext = new EncodingsDialogViewModel(dialog);
|
|
|
|
|
|
dialog.ShowDialog(_view);
|
|
|
|
|
|
}
|
2020-04-10 04:16:48 +01:00
|
|
|
|
|
|
|
|
|
|
internal void ExecutePluginsCommand()
|
|
|
|
|
|
{
|
|
|
|
|
|
var dialog = new PluginsDialog();
|
|
|
|
|
|
dialog.DataContext = new PluginsDialogViewModel(dialog);
|
|
|
|
|
|
dialog.ShowDialog(_view);
|
|
|
|
|
|
}
|
2020-04-09 02:26:04 +01:00
|
|
|
|
}
|
2020-04-09 04:18:29 +01:00
|
|
|
|
}
|