update client gui

This commit is contained in:
Pilzinsel64
2024-06-24 09:04:20 +02:00
parent d0048e008d
commit ebd9fb90da
16 changed files with 606 additions and 984 deletions

View File

@@ -1,54 +1,19 @@
using Microsoft.VisualBasic.CompilerServices;
using Pilz.UI;
using Pilz.UI.Telerik.Dialogs;
using Pilz.Updating.GUIBase;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Telerik.WinControls;
namespace Pilz.Updating.Client.GUI;
public class UpdateClientGUI
{
// F i e l d s
private Form parentForm;
private UpdateClient _UpdateClient;
private UpdateClient UpdateClient
{
[MethodImpl(MethodImplOptions.Synchronized)]
get
{
return _UpdateClient;
}
[MethodImpl(MethodImplOptions.Synchronized)]
set
{
if (_UpdateClient != null)
{
// U p d a t e C l i e n t - E v e n t s
_UpdateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged;
_UpdateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate;
_UpdateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate;
_UpdateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork;
_UpdateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound;
}
_UpdateClient = value;
if (_UpdateClient != null)
{
_UpdateClient.UpdateStatusChanged += MyUpdateClient_UpdateStatusChanged;
_UpdateClient.DownloadingUpdate += MyUpdateClient_DownloadingUpdate;
_UpdateClient.InstallingUpdate += MyUpdateClient_InstallingUpdate;
_UpdateClient.UpdateInstallerStarted += MyUpdateClient_FinishWork;
_UpdateClient.NoUpdatesFound += MyUpdateClient_NoUpdatesFound;
}
}
}
private SimpleActionDialog curProgressDialog = null;
private SimpleActionDialog curProgressDialog;
private readonly UpdateClient updateClient;
// P r o p e r t i e s
@@ -60,7 +25,21 @@ public class UpdateClientGUI
public UpdateClientGUI(UpdateClient updateClient)
{
UpdateClient = updateClient;
this.updateClient = updateClient;
updateClient.UpdateStatusChanged += MyUpdateClient_UpdateStatusChanged;
updateClient.DownloadingUpdate += MyUpdateClient_DownloadingUpdate;
updateClient.InstallingUpdate += MyUpdateClient_InstallingUpdate;
updateClient.UpdateInstallerStarted += MyUpdateClient_FinishWork;
updateClient.NoUpdatesFound += MyUpdateClient_NoUpdatesFound;
}
~UpdateClientGUI()
{
updateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged;
updateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate;
updateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate;
updateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork;
updateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound;
}
// F e a t u r e s
@@ -68,13 +47,12 @@ public class UpdateClientGUI
public async Task UpdateInteractive(Form parentForm)
{
this.parentForm = parentForm;
await UpdateClient.UpdateInteractive();
await updateClient.UpdateInteractive();
}
private void EndUpdating()
{
curProgressDialog?.Invoke(new Action(() => curProgressDialog.Close()));
UpdateClient = null;
}
private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus)
@@ -104,8 +82,9 @@ public class UpdateClientGUI
var dres = default(DialogResult);
parentForm.Invoke(new Action(() =>
{
var dialog = new UpdatesAvailableDialog(MyAppIcon, UpdateClient.CurrentVersion.Version.ToString(), UpdateClient.CurrentVersion.Channel.ToString(), Conversions.ToString(UpdateClient.CurrentVersion.Build), pkg.Version.Version.ToString(), pkg.Version.Channel.ToString(), Conversions.ToString(pkg.Version.Build), pkg.Notes, UpdateClient.InstallAsAdmin);
dres = dialog.ShowDialog(parentForm);
var dialog = new UpdatesAvailableDialog(MyAppIcon, updateClient.CurrentVersion.Version.ToString(), updateClient.CurrentVersion.Channel.ToString(), Conversions.ToString(updateClient.CurrentVersion.Build), pkg.Version.Version.ToString(), pkg.Version.Channel.ToString(), Conversions.ToString(pkg.Version.Build), pkg.Notes, updateClient.InstallAsAdmin);
var symbol = GlobalSymbolFactory.Instance.GetImage(GlobalSymbols.software_installer, UI.Telerik.SvgImageSize.Small).ToIcon();
dres = RadDialogBase.ShowDialog(dialog, parentForm, LangRes.Title_UpdatesAvailable, symbol).Result;
}));
if (dres != DialogResult.OK)
{
@@ -132,9 +111,8 @@ public class UpdateClientGUI
private void MyUpdateClient_NoUpdatesFound()
{
EndUpdating();
if (!UseHiddenSearch)
{
RadMessageBox.Show(UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound, UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound_Titel, MessageBoxButtons.OK, RadMessageIcon.Info);
}
}
}