2021-12-26 21:56:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Input;
|
2021-12-27 23:15:30 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using Wabbajack.Lib;
|
2021-12-27 23:15:30 +00:00
|
|
|
|
using Wabbajack.Networking.WabbajackClientApi;
|
|
|
|
|
using Wabbajack.Services.OSIntegrated.TokenProviders;
|
2021-12-27 05:53:39 +00:00
|
|
|
|
using Wabbajack.View_Models.Settings;
|
2021-12-26 21:56:44 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
public class SettingsVM : BackNavigatingVM
|
|
|
|
|
{
|
|
|
|
|
public MainWindowVM MWVM { get; }
|
|
|
|
|
public LoginManagerVM Login { get; }
|
|
|
|
|
public PerformanceSettings Performance { get; }
|
|
|
|
|
public FiltersSettings Filters { get; }
|
|
|
|
|
public AuthorFilesVM AuthorFile { get; }
|
|
|
|
|
|
|
|
|
|
public ICommand OpenTerminalCommand { get; }
|
|
|
|
|
|
2021-12-28 21:39:20 +00:00
|
|
|
|
public SettingsVM(ILogger<SettingsVM> logger, MainWindowVM mainWindowVM, IServiceProvider provider)
|
2021-12-29 17:26:12 +00:00
|
|
|
|
: base(logger)
|
2021-12-26 21:56:44 +00:00
|
|
|
|
{
|
|
|
|
|
MWVM = mainWindowVM;
|
2021-12-28 23:18:55 +00:00
|
|
|
|
Login = new LoginManagerVM(provider.GetRequiredService<ILogger<LoginManagerVM>>(), this);
|
2021-12-26 21:56:44 +00:00
|
|
|
|
Performance = mainWindowVM.Settings.Performance;
|
2021-12-28 23:18:55 +00:00
|
|
|
|
AuthorFile = new AuthorFilesVM(provider.GetRequiredService<ILogger<AuthorFilesVM>>()!,
|
|
|
|
|
provider.GetRequiredService<WabbajackApiTokenProvider>()!, provider.GetRequiredService<Client>()!, this);
|
2021-12-26 21:56:44 +00:00
|
|
|
|
Filters = mainWindowVM.Settings.Filters;
|
2021-12-27 23:15:30 +00:00
|
|
|
|
OpenTerminalCommand = ReactiveCommand.CreateFromTask(OpenTerminal);
|
2021-12-26 21:56:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task OpenTerminal()
|
|
|
|
|
{
|
|
|
|
|
var process = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = "cmd.exe",
|
2021-12-27 23:15:30 +00:00
|
|
|
|
WorkingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!
|
2021-12-26 21:56:44 +00:00
|
|
|
|
};
|
|
|
|
|
Process.Start(process);
|
|
|
|
|
await MWVM.ShutdownApplication();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|