wabbajack/Wabbajack/View Models/ModeSelectionVM.cs
2019-11-30 03:21:20 -06:00

40 lines
1.3 KiB
C#

using Alphaleonis.Win32.Filesystem;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.Linq;
using System.Reactive.Linq;
using System.Windows.Input;
using Wabbajack.Common;
using Wabbajack.Lib;
namespace Wabbajack
{
public class ModeSelectionVM : ViewModel
{
private MainWindowVM _mainVM;
public ICommand BrowseCommand { get; }
public ICommand InstallCommand { get; }
public ICommand CompileCommand { get; }
public ModeSelectionVM(MainWindowVM mainVM)
{
_mainVM = mainVM;
InstallCommand = ReactiveCommand.Create(
execute: () =>
{
var path = mainVM.Settings.Installer.LastInstalledListLocation;
if (string.IsNullOrWhiteSpace(path)
|| !File.Exists(path))
{
path = UIUtils.OpenFileDialog($"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}");
}
_mainVM.OpenInstaller(path);
});
CompileCommand = ReactiveCommand.Create(() => mainVM.ActivePane = mainVM.Compiler.Value);
BrowseCommand = ReactiveCommand.Create(() => mainVM.ActivePane = mainVM.Gallery.Value);
}
}
}