private void OpenLogFolder_Click(object sender, RoutedEventArgs e) { var logFolder = SteamCmdUpdater.GetLogFolder(); if (!Directory.Exists(logFolder)) { logFolder = Config.Default.DataDir; } Process.Start("explorer.exe", logFolder); }
private async void SteamCMD_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show(_globalizer.GetResourceString("MainWindow_SteamCmd_Label"), _globalizer.GetResourceString("MainWindow_SteamCmd_Title"), MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { ProgressWindow window = null; try { var updater = new SteamCmdUpdater(); var cancelSource = new CancellationTokenSource(); window = new ProgressWindow(_globalizer.GetResourceString("Progress_ReinstallSteamCmd_WindowTitle")); window.Closed += Window_Closed; window.Owner = this; window.Show(); await Task.Delay(1000); await updater.ReinstallSteamCmdAsync(new Progress <SteamCmdUpdater.Update>(u => { var resourceString = string.IsNullOrWhiteSpace(u.StatusKey) ? null : _globalizer.GetResourceString(u.StatusKey); var message = resourceString != null ? $"{SteamCmdUpdater.OUTPUT_PREFIX} {resourceString}" : u.StatusKey; window?.AddMessage(message); if (u.FailureText != null) { message = string.Format(_globalizer.GetResourceString("MainWindow_SteamCmd_FailedLabel"), u.FailureText); window?.AddMessage(message); MessageBox.Show(message, _globalizer.GetResourceString("MainWindow_SteamCmd_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error); } }), cancelSource.Token); } catch (Exception ex) { var message = string.Format(_globalizer.GetResourceString("MainWindow_SteamCmd_FailedLabel"), ex.Message); window?.AddMessage(message); MessageBox.Show(message, _globalizer.GetResourceString("MainWindow_SteamCmd_FailedTitle"), MessageBoxButton.OK, MessageBoxImage.Error); } finally { if (window != null) { window.CloseWindow(); } } } }
private async void SteamCMDAuthenticate_Click(object sender, RoutedEventArgs e) { var cursor = this.Cursor; try { if (string.IsNullOrWhiteSpace(Config.Default.SteamCmd_Username)) { MessageBox.Show("A steam username has not be entered.", "SteamCMD Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var steamCmdFile = SteamCmdUpdater.GetSteamCmdFile(Config.Default.DataDir); if (string.IsNullOrWhiteSpace(steamCmdFile) || !File.Exists(steamCmdFile)) { MessageBox.Show("Could not locate the SteamCMD executable. Try reinstalling SteamCMD.", "SteamCMD Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } Application.Current.Dispatcher.Invoke(() => this.Cursor = System.Windows.Input.Cursors.Wait); await Task.Delay(500); var steamCmdArgs = string.Format(Config.Default.SteamCmdAuthenticateArgs, Config.Default.SteamCmd_Username, Config.Default.SteamCmd_Password); var workingDirectory = Config.Default.DataDir; var result = await ProcessUtils.RunProcessAsync(steamCmdFile, steamCmdArgs, string.Empty, workingDirectory, null, null, null, CancellationToken.None); if (result) { MessageBox.Show("The authentication was completed.", "SteamCMD Authentication", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("An error occurred while trying to authenticate with steam. Please try again.", "SteamCMD Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "SteamCMD Authentication Error", MessageBoxButton.OK, MessageBoxImage.Error); throw; } finally { Application.Current.Dispatcher.Invoke(() => this.Cursor = cursor); } }