wabbajack/Wabbajack.App.Wpf/View Models/Settings/SettingsVM.cs

54 lines
1.9 KiB
C#
Raw Normal View History

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-27 23:15:30 +00:00
public SettingsVM(ILogger<SettingsVM> logger, MainWindowVM mainWindowVM, ServiceProvider provider)
: base(logger, mainWindowVM)
2021-12-26 21:56:44 +00:00
{
MWVM = mainWindowVM;
Login = new LoginManagerVM(provider.GetService<ILogger<LoginManagerVM>>(), this);
2021-12-26 21:56:44 +00:00
Performance = mainWindowVM.Settings.Performance;
2021-12-27 23:15:30 +00:00
AuthorFile = new AuthorFilesVM(provider.GetService<ILogger<AuthorFilesVM>>()!,
provider.GetService<WabbajackApiTokenProvider>()!, provider.GetService<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();
}
}
}