-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathDownloadProgressDialog.xaml.cs
More file actions
36 lines (32 loc) · 1.1 KB
/
DownloadProgressDialog.xaml.cs
File metadata and controls
36 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.ComponentModel;
using System.Windows;
using Updatum;
namespace BabySmash
{
public partial class DownloadProgressDialog : Window
{
private readonly UpdatumManager _updater;
public DownloadProgressDialog(UpdatumManager updater)
{
InitializeComponent();
_updater = updater;
_updater.PropertyChanged += UpdaterOnPropertyChanged;
}
private void UpdaterOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(UpdatumManager.DownloadedPercentage))
{
Dispatcher.Invoke(() =>
{
ProgressBar.Value = _updater.DownloadedPercentage;
ProgressText.Text = $"{_updater.DownloadedMegabytes:F2} MB / {_updater.DownloadSizeMegabytes:F2} MB ({_updater.DownloadedPercentage:F1}%)";
});
}
}
protected override void OnClosing(CancelEventArgs e)
{
_updater.PropertyChanged -= UpdaterOnPropertyChanged;
base.OnClosing(e);
}
}
}