Unify upgrade process and add update progress bar
This commit is contained in:
parent
ded58f687d
commit
d787843fd2
20 changed files with 264 additions and 247 deletions
34
Source/LibationWinForms/Form1.Upgrade.cs
Normal file
34
Source/LibationWinForms/Form1.Upgrade.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
using LibationUiBase;
|
||||
using LibationWinForms.Dialogs;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
public partial class Form1
|
||||
{
|
||||
private void Configure_Update()
|
||||
{
|
||||
setProgressVisible(false);
|
||||
#if !DEBUG
|
||||
var upgrader = new Upgrader();
|
||||
upgrader.DownloadProgress += (_, e) => Invoke(() => upgradePb.Value = int.Max(0, int.Min(100, (int)(e.ProgressPercentage ?? 0))));
|
||||
upgrader.DownloadBegin += (_, _) => Invoke(() => setProgressVisible(true));
|
||||
upgrader.DownloadCompleted += (_, _) => Invoke(() => setProgressVisible(false));
|
||||
|
||||
Shown += async (_, _) => await upgrader.CheForUpgradeAsync(UpgradeAvailable);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void setProgressVisible(bool visible) => upgradeLbl.Visible = upgradePb.Visible = visible;
|
||||
|
||||
private Task UpgradeAvailable(UpgradeEventArgs e)
|
||||
{
|
||||
var notificationResult = new UpgradeNotificationDialog(e.UpgradeProperties).ShowDialog(this);
|
||||
|
||||
e.Ignore = notificationResult == System.Windows.Forms.DialogResult.Ignore;
|
||||
e.InstallUpdate = notificationResult == System.Windows.Forms.DialogResult.Yes;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue