Mark van Renswoude
785ddbd5b2
- Check required fields before publishing - Allow cancelling of package downloading - Check for JsonConverter attribute - Improved read/unread message separator
44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace PettingZoo.Tapeti.UI.PackageProgress
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for PackageProgressWindow.xaml
|
|
/// </summary>
|
|
public partial class PackageProgressWindow : IProgress<int>
|
|
{
|
|
private readonly CancellationTokenSource cancellationTokenSource = new();
|
|
|
|
public CancellationToken CancellationToken => cancellationTokenSource.Token;
|
|
|
|
|
|
public PackageProgressWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Closed += (_, _) =>
|
|
{
|
|
cancellationTokenSource.Cancel();
|
|
};
|
|
}
|
|
|
|
|
|
public void Report(int value)
|
|
{
|
|
Dispatcher.BeginInvoke(() =>
|
|
{
|
|
Progress.Value = value;
|
|
});
|
|
}
|
|
|
|
private void CancelButton_OnClick(object sender, RoutedEventArgs e)
|
|
{
|
|
cancellationTokenSource.Cancel();
|
|
((Button)sender).IsEnabled = false;
|
|
}
|
|
}
|
|
}
|