private async void ImportFiles(IReadOnlyList <StorageFile> files, bool appendFiles = false) { try { if (files == null) { return; } if (files.Count > 0) { if (!appendFiles) { //UploadUcList.Clear(); UploadUcListX.Clear(); CurrentLocation = null; NextButton.IsEnabled = true; NextButton.Visibility = Visibility.Visible; UploadButton.Visibility = Visibility.Collapsed; } else { var plusItem = UploadUcListX.FirstOrDefault(x => x.PlusVisibility == Visibility.Visible); if (plusItem != null) { UploadUcListX.Remove(plusItem); } } LoadingUc.Start(); foreach (var file in files) { var item = new UploadUcItem { CloseVisibility = Visibility.Visible }; var uc = new UploadUc { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; uc.SetNewFile(file); item.UploadUc = uc; UploadUcListX.Add(item); //item.SetThumbIfExists(); //UploadUcList.Add(uc); } await Task.Delay(500); var tasks = new List <Task>(); foreach (var item in UploadUcListX) { try { if (item.Loadings != null && !item.Started) { item.Started = true; item.Loadings.Start(); //tasks.Add(item.UploadUc.InitFileAsync()); } } catch { } } await Task.Delay(3000); if (UploadUcListX.Count < 9) { var item = new UploadUcItem { VideoVisibility = Visibility.Collapsed, PlusVisibility = Visibility.Visible }; UploadUcListX.Add(item); } if (!appendFiles && UploadUcListX.Count > 0) { CPresenter.Content = UploadUcListX[0].UploadUc; } //await Task.WhenAll(tasks); int ix = 0; foreach (var item in UploadUcListX) { CPresenter.Content = UploadUcListX[ix].UploadUc; if (item.PlusVisibility == Visibility.Collapsed) { await item.UploadUc.InitFile(); } item.SetThumbIfExists(); ix++; } LoadingUc.Stop(); } } catch (Exception ex) { ex.PrintException("ImportFiles(IReadOnlyList<StorageFile>"); } }
private async void ImportFiles(bool appendFiles = false) { try { FileOpenPicker openPicker = new FileOpenPicker { ViewMode = PickerViewMode.Thumbnail, SuggestedStartLocation = PickerLocationId.PicturesLibrary }; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpeg"); openPicker.FileTypeFilter.Add(".bmp"); //openPicker.FileTypeFilter.Add(".gif"); openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".mp4"); //openPicker.FileTypeFilter.Add(".mkv"); var files = await openPicker.PickMultipleFilesAsync(); if (files == null) { return; } if (files.Count > 0) { if (!appendFiles) { UploadUcList.Clear(); UploadUcListX.Clear(); } else { UploadUcListX.RemoveAt(UploadUcListX.Count - 1); } foreach (var file in files) { //var item = new UploadUcItem(); var uc = new UploadUc { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; await uc.SetFileAsync(file); //item.UploadUc = uc; //UploadUcListX.Add(item); //item.SetThumbIfExists(); UploadUcList.Add(uc); } if (files.Count < 9) { var item = new UploadUcItem { VideoVisibility = Visibility.Collapsed, PlusVisibility = Visibility.Visible }; UploadUcListX.Add(item); } } } catch (Exception ex) { ex.PrintException("ImportButtonClick"); } }