finish migration
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
namespace Pilz.Updating.Client.Gui;
|
||||
using Pilz.UI.Telerik;
|
||||
using Pilz.Updating.UpdateInstaller.My.Resources;
|
||||
using Telerik.WinControls;
|
||||
|
||||
namespace Pilz.Updating.Client.Gui;
|
||||
|
||||
public partial class UpdateWindow : Telerik.WinControls.UI.RadForm
|
||||
{
|
||||
// P r o p e r t i e s
|
||||
|
||||
public bool AllowClose { get; set; }
|
||||
|
||||
// C o n s t r u c t o r s
|
||||
|
||||
public UpdateWindow()
|
||||
public UpdateWindow(string applicationName)
|
||||
{
|
||||
// Init Form
|
||||
InitializeComponent();
|
||||
@@ -16,100 +24,76 @@ public partial class UpdateWindow : Telerik.WinControls.UI.RadForm
|
||||
|
||||
// Init Application Header Text
|
||||
string header;
|
||||
if (!string.IsNullOrEmpty(installer.Configuration.ApplicationName))
|
||||
header = string.Format(My.Resources.UpdateInstallerGuiLangRes.String_UpdatingApplicationX, installer.Configuration.ApplicationName);
|
||||
if (!string.IsNullOrEmpty(applicationName))
|
||||
header = string.Format(UpdateInstallerLangRes.String_UpdatingApplicationX, applicationName);
|
||||
else
|
||||
header = My.Resources.UpdateInstallerGuiLangRes.String_UpdateIsRunning;
|
||||
header = UpdateInstallerLangRes.String_UpdateIsRunning;
|
||||
|
||||
radLabel_Header.Text = $"<html><span style=\"font-size: 18pt; color: #b7472a\"><b>{header}</b></span></html>";
|
||||
}
|
||||
|
||||
// F i e l d s
|
||||
|
||||
private bool allowClose = false;
|
||||
|
||||
// F e a t u r e s
|
||||
|
||||
public void SetStatus(UpdateStatus status)
|
||||
{
|
||||
string newStatusText = string.Empty;
|
||||
Image newStatusImage = null;
|
||||
var newStatusText = string.Empty;
|
||||
RadSvgImage newStatusImage = null;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case UpdateStatus.Copying:
|
||||
newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_CopyingFiles;
|
||||
newStatusText = UpdateInstallerLangRes.Status_CopyingFiles;
|
||||
break;
|
||||
case UpdateStatus.Done:
|
||||
newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Done;
|
||||
newStatusText = UpdateInstallerLangRes.Status_Done;
|
||||
break;
|
||||
case UpdateStatus.Extracting:
|
||||
newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Extracting;
|
||||
newStatusText = UpdateInstallerLangRes.Status_Extracting;
|
||||
break;
|
||||
case UpdateStatus.Cleanup:
|
||||
newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_RemovingFiles;
|
||||
newStatusText = UpdateInstallerLangRes.Status_RemovingFiles;
|
||||
break;
|
||||
case UpdateStatus.Waiting:
|
||||
newStatusText = My.Resources.UpdateInstallerGuiLangRes.Status_Waiting;
|
||||
newStatusText = UpdateInstallerLangRes.Status_Waiting;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case UpdateStatus.Copying:
|
||||
newStatusImage = MyIcons.icons8_copy_16px;
|
||||
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.copy, SvgImageSize.Small);
|
||||
break;
|
||||
case UpdateStatus.Extracting:
|
||||
newStatusImage = MyIcons.icons8_open_archive_16px;
|
||||
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.open_archive, SvgImageSize.Small);
|
||||
break;
|
||||
case UpdateStatus.Cleanup:
|
||||
newStatusImage = MyIcons.icons8_recycle_bin_16px;
|
||||
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.recycle_bin, SvgImageSize.Small);
|
||||
break;
|
||||
case UpdateStatus.Waiting:
|
||||
newStatusImage = MyIcons.icons8_sand_timer_16px;
|
||||
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.timer, SvgImageSize.Small);
|
||||
break;
|
||||
case UpdateStatus.Done:
|
||||
newStatusImage = MyIcons.icons8_checkmark_16px;
|
||||
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.done, SvgImageSize.Small);
|
||||
break;
|
||||
}
|
||||
|
||||
radLabel_Status.Text = newStatusText;
|
||||
radLabel_Status.Image = newStatusImage;
|
||||
radLabel_Status.SvgImage = newStatusImage;
|
||||
}
|
||||
|
||||
private async Task WaitforHostApp()
|
||||
{
|
||||
SetStatus(UpdateStatus.Waiting);
|
||||
await Task.Run(installer.WaitForHostApplication);
|
||||
}
|
||||
|
||||
private async void ExecuteUpdate()
|
||||
{
|
||||
await Task.Run(installer.InstallUpdate);
|
||||
allowClose = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private async void Main_Shown(object sender, EventArgs e)
|
||||
private void Main_Shown(object sender, EventArgs e)
|
||||
{
|
||||
radWaitingBar1.StartWaiting();
|
||||
await WaitforHostApp();
|
||||
ExecuteUpdate();
|
||||
}
|
||||
|
||||
private void Main_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
installer.StartHostApplication();
|
||||
radWaitingBar1.StopWaiting();
|
||||
}
|
||||
|
||||
private void Main_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
radWaitingBar1.StopWaiting();
|
||||
e.Cancel = !allowClose;
|
||||
}
|
||||
|
||||
private void Installer_StatusChanges(object sender, UpdateClientStatusChangedEventArgs e)
|
||||
{
|
||||
Invoke(new Action(() => SetStatus(e.NewStatus)));
|
||||
if (!AllowClose)
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user