blob: d062f923d7f8eb19efc240ddd182be1134539f2c (
plain) (
blame)
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
|
using System.Diagnostics;
using System.IO;
using System.Linq;
using ArcaneLibs.Extensions;
using Avalonia.Controls;
using Avalonia.Interactivity;
using BatchBeatmapDownloader.ViewModels;
using LibBeatmapDownload;
namespace BatchBeatmapDownloader.Views;
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
}
protected override async void OnLoaded(RoutedEventArgs e) {
base.OnLoaded(e);
var ctx = DataContext as MainWindowViewModel;
Resized += (_, args) => ctx.WindowWidth = (int)args.ClientSize.Width;
var lines = File.ReadLinesAsync("/home/root@Rory/Downloads/maps.tsv");
await foreach (var line in lines) {
var parts = line.Split('\t');
var downloadTask = new DownloadTask(int.Parse(parts[0]), parts.Length > 1 ? parts[1] : null);
ctx?.DownloadTasks.Tasks.Add(downloadTask);
if (ctx!.DownloadTasks.Tasks.Count > 100) break;
}
var tasks = ctx.DownloadTasks.Tasks.Select(x => x.Download()).ToAsyncEnumerable();
await foreach (var result in tasks) {
Debug.WriteLine($"Downloaded {result}");
}
}
}
|