private void BeatSaverApi_DownloadStarted(object sender, BeatSaver.Events.DownloadStartedEventArgs e)
        {
            BeatmapDownloadingUserControl downloadingUserControl = new BeatmapDownloadingUserControl(e.Beatmap);

            userControl.stackPanelDownloading.Children.Insert(0, downloadingUserControl);
            DownloadingCount++;
        }
        private void BeatSaverApi_DownloadProgressed(object sender, BeatSaver.Events.DownloadProgressedEventArgs e)
        {
            BeatmapDownloadingUserControl downloadingUserControl = GetDownloadingBeatmap(e.Beatmap);

            if (downloadingUserControl is null)
            {
                return;
            }

            downloadingUserControl.ViewModel.ToDownload        = e.ToDownload;
            downloadingUserControl.ViewModel.DownloadTimeLeft  = $"Estimated time left: {e.TimeLeft} ({e.Downloaded} of {e.ToDownload} downloaded)";
            downloadingUserControl.ViewModel.DownloadTimeSpent = $"Time spent: {e.TimeSpent}";
            downloadingUserControl.ViewModel.ProgressPercent   = e.ProgressPercent;
        }
        private void BeatSaverApi_DownloadCompleted(object sender, BeatSaver.Events.DownloadCompletedEventArgs e)
        {
            BeatmapDownloadingUserControl downloadingUserControl = GetDownloadingBeatmap(e.Beatmap);

            if (downloadingUserControl is null)
            {
                return;
            }

            BeatmapCompletedUserControl completedUserControl = new BeatmapCompletedUserControl(e.Beatmap, downloadingUserControl.ViewModel.ToDownload);

            userControl.stackPanelDownloading.Children.Remove(downloadingUserControl);
            DownloadingCount--;
            userControl.stackPanelCompleted.Children.Insert(0, completedUserControl);
            CompletedCount++;
        }
        private BeatmapDownloadingUserControl GetDownloadingBeatmap(OnlineBeatmap beatmap)
        {
            BeatmapDownloadingUserControl downloadingUserControl = null;

            foreach (object obj in userControl.stackPanelDownloading.Children)
            {
                if (obj is BeatmapDownloadingUserControl control)
                {
                    if (control.ViewModel.Beatmap == beatmap)
                    {
                        downloadingUserControl = control;
                        break;
                    }
                }
            }

            return(downloadingUserControl);
        }
        private void BeatSaverApi_DownloadFailed(object sender, BeatSaver.Events.DownloadFailedEventArgs e)
        {
            BeatmapDownloadingUserControl downloadingUserControl = GetDownloadingBeatmap(e.Beatmap);
            BeatmapCompletedUserControl   completedUserControl   = GetCompletedBeatmap(e.Beatmap);
            BeatmapFailedUserControl      failedUserControl      = new BeatmapFailedUserControl(e.Beatmap, e.Exception);

            userControl.stackPanelFailed.Children.Insert(0, failedUserControl);
            FailedCount++;

            if (downloadingUserControl != null)
            {
                userControl.stackPanelDownloading.Children.Remove(downloadingUserControl);
                DownloadingCount--;
            }
            else if (completedUserControl != null)
            {
                userControl.stackPanelCompleted.Children.Remove(completedUserControl);
                CompletedCount--;
            }
        }