private void ModelSaberApi_DownloadStarted(object sender, ModelSaber.Events.DownloadStartedEventArgs e) { ModelSaberDownloadingUserControl downloadingUserControl = new ModelSaberDownloadingUserControl(e.Model); userControl.stackPanelDownloading.Children.Insert(0, downloadingUserControl); DownloadingCount++; }
private void ModelSaberApi_DownloadProgressed(object sender, ModelSaber.Events.DownloadProgressedEventArgs e) { ModelSaberDownloadingUserControl downloadingUserControl = GetDownloadingModelSaber(e.Model); 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 ModelSaberApi_DownloadCompleted(object sender, ModelSaber.Events.DownloadCompletedEventArgs e) { ModelSaberDownloadingUserControl downloadingUserControl = GetDownloadingModelSaber(e.Model); if (downloadingUserControl is null) { return; } ModelSaberCompletedUserControl completedUserControl = new ModelSaberCompletedUserControl(e.Model, downloadingUserControl.ViewModel.ToDownload); userControl.stackPanelDownloading.Children.Remove(downloadingUserControl); DownloadingCount--; userControl.stackPanelCompleted.Children.Insert(0, completedUserControl); CompletedCount++; }
private ModelSaberDownloadingUserControl GetDownloadingModelSaber(OnlineModel model) { ModelSaberDownloadingUserControl downloadingUserControl = null; foreach (object obj in userControl.stackPanelDownloading.Children) { if (obj is ModelSaberDownloadingUserControl control) { if (control.ViewModel.Model == model) { downloadingUserControl = control; break; } } } return(downloadingUserControl); }
private void ModelSaberApi_DownloadFailed(object sender, ModelSaber.Events.DownloadFailedEventArgs e) { ModelSaberDownloadingUserControl downloadingUserControl = GetDownloadingModelSaber(e.Model); ModelSaberCompletedUserControl completedUserControl = GetCompletedModelSaber(e.Model); ModelSaberFailedUserControl failedUserControl = new ModelSaberFailedUserControl(e.Model, 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--; } }