summary refs log tree commit diff
path: root/BatchBeatmapDownloader/ViewModels/MainWindowViewModel.cs
blob: 1e5d23a2e433f594b72c37005be22610841a33be (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
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using LibBeatmapDownload;
using ReactiveUI;

namespace BatchBeatmapDownloader.ViewModels;

public class MainWindowViewModel : ViewModelBase {
	// public List<DownloadTask> DownloadTasks { get; set; } = new();
	public DownloadTaskList DownloadTasks { get; set; } = new();

	private int _windowWidth = 800;

	public int WindowWidth {
		set {
			_windowWidth = value;
			Debug.WriteLine($"Window width: {_windowWidth}");
			DomainStatsChunked = DownloadTask.MirrorStats.Select(x => x.Value).ToList().Chunk(value/300)
				.Select(x => new ObjectCollectionWrapper<DomainStats>(x)).ToList();
			this.RaisePropertyChanged(nameof(DomainStatsChunked));
		}
	}

	public List<ObjectCollectionWrapper<DomainStats>> DomainStatsChunked { get; set; } = DownloadTask.MirrorStats.Select(x => x.Value).ToList().Chunk(2)
		.Select(x => new ObjectCollectionWrapper<DomainStats>(x)).ToList();

	public void RaiseDownloadListChanged() {
		this.RaisePropertyChanged(nameof(DownloadTasks));
	}
}