protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); tbInfo.Text = $" ... "; try { _state = JsonHelper.FromJson <AppState>((string)AppSettingsHelper.ReadVal(typeof(AppState).Name)); var args = e.Parameter as Windows.ApplicationModel.Activation.IActivatedEventArgs; if (args?.Kind == Windows.ApplicationModel.Activation.ActivationKind.File) { var fileArgs = args as Windows.ApplicationModel.Activation.FileActivatedEventArgs; var strFilePath = fileArgs?.Files[0].Path; if (strFilePath != null) { me_Xm.AutoPlay = _state.AutoPlay; var sf = await StorageFile.GetFileFromPathAsync(strFilePath); await loadPlay(sf); return; } } if (_state.LastLocalMedia != null) { me_Xm.AutoPlay = _state.AutoPlay; var sf = await StorageFile.GetFileFromPathAsync(_state.LastLocalMedia); await loadPlay(sf); return; } var rv = await IsoStorePoc.LoadFromLibFolder(KnownFolderId.VideosLibrary); foreach (var storageFile in rv) { await loadPlay(storageFile); break; } } catch (Exception ex) { Debug.WriteLine($"$#~>{ex.Message}"); if (Debugger.IsAttached) { Debugger.Break(); } /*else throw;*/ } }
async Task libLoad(KnownFolderId library) { IsReady = false; try { var max = 200; var sfs = await IsoStorePoc.LoadFromLibFolder(library); MediaInfos.Clear(); sfs.Take(max).ToList().ForEach(sf => MediaInfos.Add(new MediaInfo(sf))); ApplicationView.GetForCurrentView().Title = Info = $@"Ttl {sfs.Count} in {library}, taking first {max}"; } finally { IsReady = true; } }
async Task onLoadLib_Task(KnownFolderId library) { try { CanLoadLibs = false; if (library == KnownFolderId.AllAppMods) { await onLoadLib_Task(KnownFolderId.MusicLibrary); await onLoadLib_Task(KnownFolderId.VideosLibrary); return; } var max = 1000; var sfs = await IsoStorePoc.LoadFromLibFolder(library); var ll = sfs.Take(max).OrderBy(r => r.Path).ThenBy(r => r.Name); foreach (var sf in ll) { await addNewOrFromMru(sf); //async ruins the order by: ll.ToList().ForEach(async sf => await add(sf)); } if (SlctMru != null) { SlctLib = selectFromList(SlctMru.PathFile, LibLst); } ApplicationView.GetForCurrentView().Title = $@"{library}: {LibLst.Count} / {sfs.Count} "; TbInfo += $@"\r\n{ApplicationView.GetForCurrentView().Title} "; } catch (Exception ex) { Debug.WriteLine($"$#~>{ex.Message}"); if (Debugger.IsAttached) { Debugger.Break(); } else { await popEx(ex, GetType().FullName); } } finally { CanLoadLibs = true; } }