mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
65
src/ConanServerManager/Windows/AutoUpdateWindow.xaml.cs
Normal file
65
src/ConanServerManager/Windows/AutoUpdateWindow.xaml.cs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
using ServerManagerTool.Common.Lib;
|
||||
using ServerManagerTool.Common.Utils;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using WPFSharp.Globalizer;
|
||||
|
||||
namespace ServerManagerTool
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AutoUpdateWindow.xaml
|
||||
/// </summary>
|
||||
public partial class AutoUpdateWindow : Window
|
||||
{
|
||||
private GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
|
||||
|
||||
private SteamCmdUpdater updater = new SteamCmdUpdater();
|
||||
private CancellationTokenSource cancelSource;
|
||||
|
||||
public AutoUpdateWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cancelSource = new CancellationTokenSource();
|
||||
updater.UpdateSteamCmdAsync(Config.Default.DataPath, new Progress<SteamCmdUpdater.Update>(async u =>
|
||||
{
|
||||
var message = string.IsNullOrWhiteSpace(u.StatusKey) ? string.Empty : _globalizer.GetResourceString(u.StatusKey) ?? u.StatusKey;
|
||||
this.StatusLabel.Content = message;
|
||||
this.CompletionProgress.Value = u.CompletionPercent;
|
||||
|
||||
if(u.FailureText != null)
|
||||
{
|
||||
// TODO: Report error through UI
|
||||
throw new Exception(u.FailureText);
|
||||
}
|
||||
|
||||
if (u.CompletionPercent >= 100 || u.Cancelled)
|
||||
{
|
||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
var mainWindow = new MainWindow();
|
||||
mainWindow.Show();
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
}), cancelSource.Token);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (cancelSource != null)
|
||||
cancelSource.Cancel();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
if (cancelSource != null)
|
||||
cancelSource.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue