wabbajack/Wabbajack/View Models/ModeSelectionVM.cs

40 lines
1.3 KiB
C#
Raw Normal View History

2019-11-24 08:12:28 +00:00
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;
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
});
2019-11-30 09:08:04 +00:00
CompileCommand = ReactiveCommand.Create(() => mainVM.ActivePane = mainVM.Compiler.Value);
BrowseCommand = ReactiveCommand.Create(() => mainVM.ActivePane = mainVM.Gallery.Value);
2019-11-24 08:12:28 +00:00
}
}
}