Bilibili-Evolved/extras/vld-windows/VideoLinkDownloader/VideoTask.cs
2019-05-30 20:15:19 +08:00

42 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VideoLinkDownloader.Core;
namespace VideoLinkDownloader
{
class VideoTask : NotificationObject
{
public VideoTask(Video video)
{
Downloader = new VideoDownloader(video);
Downloader.ProgressUpdate.Add(progress =>
{
Progress = progress;
});
}
public VideoDownloader Downloader { get; private set; }
private double progress = 0;
public double Progress
{
get => progress;
set
{
progress = value;
OnPropertyChanged(nameof(Progress));
OnPropertyChanged(nameof(SizeProgress));
}
}
public string Title => Downloader.Video.Title;
public string PercentProgress => $"{Math.Floor(Progress * 1000) / 10}%";
public string SizeProgress => $"{Downloader.DownloadedBytes.ToFileSize()} / {Downloader.Video.TotalSize.ToFileSize()}";
public async Task Download()
{
await Downloader.Download();
}
}
}