Finished BackupServer and UpdateServer

This commit is contained in:
Brett Hewitson 2021-12-05 01:56:11 +10:00
parent 824daed0d1
commit 0f3c6e6be9
28 changed files with 618 additions and 216 deletions

View file

@ -10,7 +10,7 @@
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
xmlns:enum="clr-namespace:ServerManagerTool.Enums"
MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
Loaded="Window_Loaded" SizeChanged="Window_SizeChanged" StateChanged="Window_StateChanged" LocationChanged="Window_LocationChanged"
Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
<Window.Resources>
<ResourceDictionary>

View file

@ -6,6 +6,7 @@ using ServerManagerTool.Common.Utils;
using ServerManagerTool.Enums;
using ServerManagerTool.Lib;
using ServerManagerTool.Plugin.Common;
using ServerManagerTool.Utils;
using ServerManagerTool.Windows;
using System;
using System.Diagnostics;
@ -162,7 +163,7 @@ namespace ServerManagerTool
GlobalizedApplication.Instance.GlobalizationManager.ResourceDictionaryChangedEvent += ResourceDictionaryChangedEvent;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
//
// Kick off the initialization.
@ -192,15 +193,7 @@ namespace ServerManagerTool
this.scheduledTaskChecker.PostAction(CheckForScheduledTasks).DoNotWait();
}
private void Window_Closed(object sender, EventArgs e)
{
if (sender is Window window)
window.Closed -= Window_Closed;
this.Activate();
}
private void Window_LocationChanged(object sender, EventArgs e)
private void MainWindow_LocationChanged(object sender, EventArgs e)
{
if (this.WindowState == WindowState.Normal)
{
@ -209,7 +202,7 @@ namespace ServerManagerTool
}
}
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
private void MainWindow_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (this.WindowState == WindowState.Normal)
{
@ -218,7 +211,7 @@ namespace ServerManagerTool
}
}
private void Window_StateChanged(object sender, EventArgs e)
private void MainWindow_StateChanged(object sender, EventArgs e)
{
if (Config.Default.MainWindow_MinimizeToTray && this.WindowState == WindowState.Minimized)
{
@ -226,8 +219,26 @@ namespace ServerManagerTool
}
}
private void Window_Closed(object sender, EventArgs e)
{
if (sender is Window window)
window.Closed -= Window_Closed;
this.Activate();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
if (DiscordBotHelper.HasRunningCommands)
{
var result = MessageBox.Show(_globalizer.GetResourceString("MainWindow_DiscordBot_RunningCommandsLabel"), _globalizer.GetResourceString("MainWindow_DiscordBot_RunningCommandsTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.No)
{
e.Cancel = true;
return;
}
}
base.OnClosing(e);
RconWindow.CloseAllWindows();
PlayerListWindow.CloseAllWindows();

View file

@ -620,7 +620,7 @@ namespace ServerManagerTool.Windows
await Task.Delay(1000);
var branch = new BranchSnapshot() { BranchName = serverProfile.BranchName, BranchPassword = serverProfile.BranchPassword };
var branch = BranchSnapshot.Create(serverProfile);
return await server.UpgradeAsync(_upgradeCancellationSource.Token, updateServer, branch, true, updateMods, (p, m, n) => { TaskUtils.RunOnUIThreadAsync(() => { window?.AddMessage(m, n); }).DoNotWait(); });
}
else

View file

@ -1449,7 +1449,7 @@ namespace ServerManagerTool
await Task.Delay(1000);
var branch = new BranchSnapshot() { BranchName = this.Server.Profile.BranchName, BranchPassword = this.Server.Profile.BranchPassword };
var branch = BranchSnapshot.Create(this.Server.Profile);
return await this.Server.UpgradeAsync(_upgradeCancellationSource.Token, updateServer, branch, true, updateMods, (p, m, n) => { TaskUtils.RunOnUIThreadAsync(() => { window?.AddMessage(m, n); }).DoNotWait(); });
}
else