rework client and remove separated update installer (gui not finished yet)
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using Pilz.UI;
|
||||
using Pilz.UI;
|
||||
using Pilz.UI.Telerik.Dialogs;
|
||||
using Pilz.Updating.Client.Gui.LangRes;
|
||||
using Pilz.Updating.Client.GUI;
|
||||
using Pilz.Updating.GUIBase;
|
||||
using System.ComponentModel;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace Pilz.Updating.Client.GUI;
|
||||
namespace Pilz.Updating.Client.Gui;
|
||||
|
||||
public class UpdateClientGUI
|
||||
public class UpdateClientGui
|
||||
{
|
||||
// F i e l d s
|
||||
|
||||
private Form parentForm;
|
||||
private SimpleActionDialog curProgressDialog;
|
||||
private UpdateWindow curProgressDialog;
|
||||
private readonly UpdateClient updateClient;
|
||||
|
||||
// P r o p e r t i e s
|
||||
@@ -23,23 +24,15 @@ public class UpdateClientGUI
|
||||
|
||||
// C o n s t r u c t o r s
|
||||
|
||||
public UpdateClientGUI(UpdateClient updateClient)
|
||||
public UpdateClientGui(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;
|
||||
updateClient.OnStatusChanged += UpdateClient_OnStatusChanged;
|
||||
}
|
||||
|
||||
~UpdateClientGUI()
|
||||
~UpdateClientGui()
|
||||
{
|
||||
updateClient.UpdateStatusChanged -= MyUpdateClient_UpdateStatusChanged;
|
||||
updateClient.DownloadingUpdate -= MyUpdateClient_DownloadingUpdate;
|
||||
updateClient.InstallingUpdate -= MyUpdateClient_InstallingUpdate;
|
||||
updateClient.UpdateInstallerStarted -= MyUpdateClient_FinishWork;
|
||||
updateClient.NoUpdatesFound -= MyUpdateClient_NoUpdatesFound;
|
||||
updateClient.OnStatusChanged -= UpdateClient_OnStatusChanged;
|
||||
}
|
||||
|
||||
// F e a t u r e s
|
||||
@@ -52,33 +45,81 @@ public class UpdateClientGUI
|
||||
|
||||
private void EndUpdating()
|
||||
{
|
||||
curProgressDialog?.Invoke(new Action(() => curProgressDialog.Close()));
|
||||
curProgressDialog?.Invoke(curProgressDialog.Close);
|
||||
}
|
||||
|
||||
private void MyUpdateClient_UpdateStatusChanged(UpdateStatus newStatus)
|
||||
// E v e n t s
|
||||
|
||||
private void UpdateClient_OnStatusChanged(object sender, UpdateStatusEventArgs e)
|
||||
{
|
||||
bool useGui = false;
|
||||
if (!(newStatus == UpdateStatus.Searching && UseHiddenSearch))
|
||||
void setStatus()
|
||||
{
|
||||
if (e.Event == UpdateStatusEvent.PreEvent)
|
||||
SetStatus(e.Status);
|
||||
}
|
||||
|
||||
switch (e.Status)
|
||||
{
|
||||
case UpdateStatus.Downloading:
|
||||
setStatus();
|
||||
if (e.Event == UpdateStatusEvent.PostEvent)
|
||||
{
|
||||
if (e.Client.UpdatePackageInfo == null && !UseHiddenSearch)
|
||||
RadMessageBox.Show(UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound, UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound_Titel, MessageBoxButtons.OK, RadMessageIcon.Info);
|
||||
|
||||
if (e.Client.UpdatePackageInfo != null && !ShowUpdatesAvailable(e.Client.UpdatePackageInfo))
|
||||
e.Cancel = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (e.Status)
|
||||
{
|
||||
case UpdateStatus.Downloading:
|
||||
case UpdateStatus.Extracting:
|
||||
case UpdateStatus.Copying:
|
||||
case UpdateStatus.Cleanup:
|
||||
case UpdateStatus.Waiting:
|
||||
setStatus();
|
||||
break;
|
||||
}
|
||||
|
||||
switch (e.Status)
|
||||
{
|
||||
case UpdateStatus.Done:
|
||||
case UpdateStatus.Failed:
|
||||
case UpdateStatus.Canceled:
|
||||
EndUpdating();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetStatus(UpdateStatus status)
|
||||
{
|
||||
var useGui = false;
|
||||
|
||||
if (!(status == UpdateStatus.Searching && UseHiddenSearch))
|
||||
{
|
||||
useGui = true;
|
||||
}
|
||||
|
||||
if (useGui && curProgressDialog is null)
|
||||
{
|
||||
parentForm.Invoke(new Action(() =>
|
||||
parentForm.Invoke(() =>
|
||||
{
|
||||
curProgressDialog = new SimpleActionDialog();
|
||||
curProgressDialog.SetCurrentState(UpdateStatus.Waiting);
|
||||
curProgressDialog = new UpdateWindow();
|
||||
curProgressDialog.SetStatus(UpdateStatus.Waiting);
|
||||
curProgressDialog.Show(parentForm);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
curProgressDialog?.Invoke(new Action(() => curProgressDialog.SetCurrentState(newStatus)));
|
||||
curProgressDialog?.Invoke(() => curProgressDialog.SetStatus(status));
|
||||
}
|
||||
|
||||
private void MyUpdateClient_DownloadingUpdate(UpdatePackageInfo pkg, CancelEventArgs e)
|
||||
private bool ShowUpdatesAvailable(UpdatePackageInfo pkg)
|
||||
{
|
||||
var dres = default(DialogResult);
|
||||
bool cancel;
|
||||
|
||||
// Hide progress dialog
|
||||
curProgressDialog?.Invoke(new Action(curProgressDialog.Hide));
|
||||
@@ -97,38 +138,22 @@ public class UpdateClientGUI
|
||||
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;
|
||||
dres = RadDialogBase.ShowDialog(dialog, parentForm, GeneralLangRes.Title_UpdatesAvailable, symbol).Result;
|
||||
});
|
||||
|
||||
if (dres != DialogResult.OK)
|
||||
{
|
||||
// Finish updating
|
||||
e.Cancel = true;
|
||||
// Cancel
|
||||
cancel = true;
|
||||
EndUpdating();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cancel
|
||||
e.Cancel = false;
|
||||
// Continue
|
||||
cancel = false;
|
||||
curProgressDialog?.Invoke(new Action(curProgressDialog.Show));
|
||||
}
|
||||
}
|
||||
|
||||
private void MyUpdateClient_InstallingUpdate(UpdatePackageInfo pkg, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = false;
|
||||
}
|
||||
|
||||
private void MyUpdateClient_FinishWork()
|
||||
{
|
||||
EndUpdating();
|
||||
}
|
||||
|
||||
private void MyUpdateClient_NoUpdatesFound()
|
||||
{
|
||||
EndUpdating();
|
||||
|
||||
if (!UseHiddenSearch)
|
||||
RadMessageBox.Show(UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound, UpdatingClientGuiLangRes.MsgBox_NoUpdatesFound_Titel, MessageBoxButtons.OK, RadMessageIcon.Info);
|
||||
return cancel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user