100 lines
3.2 KiB
C#
100 lines
3.2 KiB
C#
using Pilz.UI.Telerik;
|
|
using Pilz.Updating.Client.Gui.LangRes;
|
|
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(string applicationName)
|
|
{
|
|
// Init Form
|
|
InitializeComponent();
|
|
|
|
// Events
|
|
Shown += Main_Shown;
|
|
FormClosed += Main_FormClosed;
|
|
FormClosing += Main_FormClosing;
|
|
|
|
// Init Application Header Text
|
|
string header;
|
|
if (!string.IsNullOrEmpty(applicationName))
|
|
header = string.Format(UpdateInstallerLangRes.String_UpdatingApplicationX, applicationName);
|
|
else
|
|
header = UpdateInstallerLangRes.String_UpdateIsRunning;
|
|
|
|
radLabel_Header.Text = $"<html><span style=\"font-size: 18pt; color: #b7472a\"><b>{header}</b></span></html>";
|
|
}
|
|
|
|
// F e a t u r e s
|
|
|
|
public void SetStatus(UpdateStatus status)
|
|
{
|
|
var newStatusText = string.Empty;
|
|
RadSvgImage newStatusImage = null;
|
|
|
|
switch (status)
|
|
{
|
|
case UpdateStatus.Copying:
|
|
newStatusText = UpdateInstallerLangRes.Status_CopyingFiles;
|
|
break;
|
|
case UpdateStatus.Done:
|
|
newStatusText = UpdateInstallerLangRes.Status_Done;
|
|
break;
|
|
case UpdateStatus.Extracting:
|
|
newStatusText = UpdateInstallerLangRes.Status_Extracting;
|
|
break;
|
|
case UpdateStatus.Cleanup:
|
|
newStatusText = UpdateInstallerLangRes.Status_RemovingFiles;
|
|
break;
|
|
case UpdateStatus.Waiting:
|
|
newStatusText = UpdateInstallerLangRes.Status_Waiting;
|
|
break;
|
|
}
|
|
|
|
switch (status)
|
|
{
|
|
case UpdateStatus.Copying:
|
|
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.copy, SvgImageSize.Small);
|
|
break;
|
|
case UpdateStatus.Extracting:
|
|
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.open_archive, SvgImageSize.Small);
|
|
break;
|
|
case UpdateStatus.Cleanup:
|
|
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.recycle_bin, SvgImageSize.Small);
|
|
break;
|
|
case UpdateStatus.Waiting:
|
|
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.timer, SvgImageSize.Small);
|
|
break;
|
|
case UpdateStatus.Done:
|
|
newStatusImage = GlobalSymbolFactory.Instance.GetSvgImage(GlobalSymbols.done, SvgImageSize.Small);
|
|
break;
|
|
}
|
|
|
|
radLabel_Status.Text = newStatusText;
|
|
radLabel_Status.SvgImage = newStatusImage;
|
|
}
|
|
|
|
private void Main_Shown(object sender, EventArgs e)
|
|
{
|
|
radWaitingBar1.StartWaiting();
|
|
}
|
|
|
|
private void Main_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
radWaitingBar1.StopWaiting();
|
|
}
|
|
|
|
private void Main_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
if (!AllowClose)
|
|
e.Cancel = true;
|
|
}
|
|
} |