wabbajack/Wabbajack.App.Blazor/Pages/SelectInstall.razor.cs

73 lines
2.3 KiB
C#
Raw Normal View History

2022-01-15 06:29:44 +00:00
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using DynamicData;
2022-01-15 06:29:44 +00:00
using Fluxor;
using Microsoft.AspNetCore.Components;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs;
2022-01-15 06:29:44 +00:00
using Wabbajack.App.Blazor.Store;
using Wabbajack.Common;
2022-01-15 06:29:44 +00:00
using Wabbajack.DTOs;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Installer;
using Wabbajack.Paths;
namespace Wabbajack.App.Blazor.Pages
{
public partial class SelectInstall
{
[Inject] private NavigationManager NavigationManager { get; set; }
[Inject] private IState<InstallState> _installState { get; set; }
[Inject] private IDispatcher _dispatcher { get; set; }
private AbsolutePath _modListPath { get; set; }
2022-01-15 06:29:44 +00:00
private void SelectFile()
{
using (var dialog = new CommonOpenFileDialog())
2022-01-15 06:29:44 +00:00
{
dialog.Multiselect = false;
dialog.Filters.Add(new CommonFileDialogFilter("Wabbajack File", "*" + Ext.Wabbajack));
if (dialog.ShowDialog() != CommonFileDialogResult.Ok) return;
_modListPath = dialog.FileName.ToAbsolutePath();
2022-01-15 06:29:44 +00:00
}
VerifyFile(_modListPath);
2022-01-15 06:29:44 +00:00
}
// private void SelectFile()
// {
// var file = new OpenFileDialog
// {
// Filter = "Wabbajack (*.wabbajack)|*.wabbajack",
// FilterIndex = 1,
// Multiselect = false,
// Title = "Wabbajack file for install"
// };
//
// try
// {
// if (file.ShowDialog() != true) return;
// var path = file.FileName.ToAbsolutePath();
// VerifyFile(path);
// }
// catch (Exception ex)
// {
// Debug.Print(ex.Message);
// }
// }
private void VerifyFile(AbsolutePath path)
2022-01-15 06:29:44 +00:00
{
try
{
_dispatcher.Dispatch(new UpdateInstallState(InstallState.InstallStateEnum.Configuration, null, path, null, null));
2022-01-15 06:29:44 +00:00
NavigationManager.NavigateTo("/configure");
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
}
}
}