wabbajack/Wabbajack/View Models/ModeSelectionVM.cs

41 lines
1.3 KiB
C#
Raw Normal View History

2020-01-10 04:27:59 +00:00
using ReactiveUI;
2019-11-24 08:12:28 +00:00
using ReactiveUI.Fody.Helpers;
2020-01-10 04:27:59 +00:00
using System.IO;
2019-11-24 08:12:28 +00:00
using System.Linq;
using System.Reactive.Linq;
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
using Wabbajack.UI;
2019-11-24 08:12:28 +00:00
namespace Wabbajack
{
public class ModeSelectionVM : ViewModel
{
private MainWindowVM _mainVM;
2019-11-30 09:08:04 +00:00
public ICommand BrowseCommand { get; }
2019-11-24 08:12:28 +00:00
public ICommand InstallCommand { get; }
public ICommand CompileCommand { get; }
public ModeSelectionVM(MainWindowVM mainVM)
{
_mainVM = mainVM;
2019-11-24 08:12:28 +00:00
InstallCommand = ReactiveCommand.Create(
execute: () =>
{
var path = mainVM.Settings.Installer.LastInstalledListLocation;
if (string.IsNullOrWhiteSpace(path)
|| !File.Exists(path))
{
path = UIUtils.OpenFileDialog($"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}");
}
2019-11-30 09:08:04 +00:00
_mainVM.OpenInstaller(path);
2019-11-24 08:12:28 +00:00
});
CompileCommand = ReactiveCommand.Create(() => mainVM.NavigateTo(mainVM.Compiler.Value));
BrowseCommand = ReactiveCommand.Create(() => mainVM.NavigateTo(mainVM.Gallery.Value));
2019-11-24 08:12:28 +00:00
}
}
}