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}"); } } }