2 files changed, 127 insertions, 0 deletions
| diff --git a/BatchBeatmapDownloader/Views/MainWindow.axaml b/BatchBeatmapDownloader/Views/MainWindow.axaml
new file mode 100644
index 0000000..d6ed94f
--- /dev/null
+++ b/BatchBeatmapDownloader/Views/MainWindow.axaml
@@ -0,0 +1,93 @@
+<Window xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:vm="using:BatchBeatmapDownloader.ViewModels"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:batchBeatmapDownloader="clr-namespace:BatchBeatmapDownloader"
+        xmlns:generic="clr-namespace:System.Collections.Generic;assembly=System.Collections"
+        xmlns:libBeatmapDownload="clr-namespace:LibBeatmapDownload;assembly=LibBeatmapDownload"
+        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+        x:Class="BatchBeatmapDownloader.Views.MainWindow"
+        x:DataType="vm:MainWindowViewModel"
+        Icon="/Assets/avalonia-logo.ico"
+        Title="BatchBeatmapDownloader">
+
+    <Design.DataContext>
+        <!-- This only sets the DataContext for the previewer in an IDE,
+             to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
+        <vm:MainWindowViewModel/>
+    </Design.DataContext>
+    <StackPanel Orientation="Vertical">
+        <!-- horizontal listbox with progress bars -->
+        <ListBox ItemsSource="{Binding DomainStatsChunked}">
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <UniformGrid Rows="{Binding DomainStatsChunked.Count}"/>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <ListBox ItemsSource="{Binding Items}">
+                        <ListBox.ItemsPanel>
+                            <ItemsPanelTemplate>
+                                <UniformGrid Columns="{Binding Items.Count}"/>
+                            </ItemsPanelTemplate>
+                        </ListBox.ItemsPanel>
+                        <ListBox.ItemTemplate>
+                            <DataTemplate DataType="libBeatmapDownload:DomainStats">
+                                <Grid>
+                                    <Grid.RowDefinitions>
+                                        <RowDefinition Height="Auto"/>
+                                        <RowDefinition Height="Auto"/>
+                                    </Grid.RowDefinitions>
+                                    <ProgressBar Value="{Binding Progress, Mode=OneWay}" />
+                                    <TextBlock Grid.Row="1" Text="{Binding ProgressString, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                                </Grid>
+                            </DataTemplate>
+                        </ListBox.ItemTemplate>
+                    </ListBox>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        <!--
+        <ListBox ItemsSource="{Binding DomainStats}">
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <UniformGrid Columns="{Binding DomainStats.Count}"/>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="batchBeatmapDownloader:DomainStats">
+                    <Grid>
+                        <Grid.RowDefinitions>
+                            <RowDefinition Height="Auto"/>
+                            <RowDefinition Height="Auto"/>
+                        </Grid.RowDefinitions>
+                        <ProgressBar Value="{Binding Progress, Mode=OneWay}" />
+                        <TextBlock Grid.Row="1" Text="{Binding ProgressString, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                    </Grid>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+        -->
+
+        <ListBox ItemsSource="{Binding DownloadTasks.Tasks}">
+            <ListBox.ItemsPanel>
+                <ItemsPanelTemplate>
+                    <VirtualizingStackPanel></VirtualizingStackPanel>
+                </ItemsPanelTemplate>
+            </ListBox.ItemsPanel>
+            <ListBox.ItemTemplate>
+                <DataTemplate DataType="libBeatmapDownload:DownloadTask">
+                    <!-- Progress bar with text overlayed -->
+                    <Grid>
+                        <ProgressBar Value="{Binding Progress, Mode=OneWay}" />
+                        <TextBlock Text="{Binding ProgressString, Mode=OneWay}" HorizontalAlignment="Center" VerticalAlignment="Center" />
+                    </Grid>
+
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+    </StackPanel>
+
+</Window>
diff --git a/BatchBeatmapDownloader/Views/MainWindow.axaml.cs b/BatchBeatmapDownloader/Views/MainWindow.axaml.cs
new file mode 100644
 index 0000000..d062f92
--- /dev/null
+++ b/BatchBeatmapDownloader/Views/MainWindow.axaml.cs
@@ -0,0 +1,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}");
+		}
+	}
+}
 |