gui: add event to handle EndUpdating

This commit is contained in:
2024-06-27 09:38:54 +02:00
parent 682a96bf85
commit a68ccb5daf
7 changed files with 26 additions and 6 deletions

View File

@@ -1,13 +1,16 @@
using Pilz.UI;
using Pilz.UI.Telerik.Dialogs;
using Pilz.Updating.Client.Gui.LangRes;
using Pilz.Updating.Client.GUI;
using Telerik.WinControls;
namespace Pilz.Updating.Client.Gui;
public class UpdateClientGui
{
// E v e n t s
public event UpdateEndedEventHandler OnUpdateEnded;
// F i e l d s
private Form parentForm;
@@ -16,7 +19,7 @@ public class UpdateClientGui
// P r o p e r t i e s
public bool UseHiddenSearch { get; set; } = false;
public bool UseHiddenSearch { get; set; }
private static Image MyAppIcon => Icon.ExtractAssociatedIcon(IO.Extensions.GetExecutablePath()).ToBitmap();
@@ -42,9 +45,15 @@ public class UpdateClientGui
}
private void EndUpdating()
{
EndUpdating(false);
}
private void EndUpdating(bool success)
{
curProgressDialog.AllowClose = true;
curProgressDialog?.Invoke(curProgressDialog.Close);
OnUpdateEnded?.Invoke(this, new(success));
}
// E v e n t s
@@ -86,6 +95,8 @@ public class UpdateClientGui
switch (e.Status)
{
case UpdateStatus.Done:
EndUpdating(true);
break;
case UpdateStatus.Failed:
case UpdateStatus.Canceled:
EndUpdating();