wabbajack/Wabbajack.App.Wpf/View Models/ModeSelectionVM.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2021-12-26 21:56:44 +00:00
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
using System.IO;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
2021-12-27 05:18:52 +00:00
using Wabbajack.Paths.IO;
2021-12-26 21:56:44 +00:00
namespace Wabbajack
{
public class ModeSelectionVM : ViewModel
{
private MainWindowVM _mainVM;
public ICommand BrowseCommand { get; }
public ICommand InstallCommand { get; }
public ICommand CompileCommand { get; }
public ReactiveCommand<Unit, Unit> UpdateCommand { get; }
public ModeSelectionVM(MainWindowVM mainVM)
{
_mainVM = mainVM;
InstallCommand = ReactiveCommand.Create(
execute: () =>
{
var path = mainVM.Settings.Installer.LastInstalledListLocation;
2021-12-27 05:18:52 +00:00
if (path == default || !path.FileExists())
2021-12-26 21:56:44 +00:00
{
2021-12-27 05:18:52 +00:00
path = UIUtils.OpenFileDialog($"*{Ext.Wabbajack}|*{Ext.Wabbajack}");
2021-12-26 21:56:44 +00:00
}
_mainVM.OpenInstaller(path);
});
CompileCommand = ReactiveCommand.Create(() => mainVM.NavigateTo(mainVM.Compiler.Value));
BrowseCommand = ReactiveCommand.Create(() => mainVM.NavigateTo(mainVM.Gallery.Value));
}
}
}