private void OnFileClicked(CloudFileLabel label) { FileClicked?.Invoke(label); }
public async Task RefreshContent() { PBmain.IsRunning = PBmain.IsVisible = true; BTNrefresh.IsEnabled = false; BTNrefresh.Text = "↻ (Refreshing...)"; StopRequest = false; IsRunning = true; await FoldersGetter.ResetAsync(); var list = await FoldersGetter.GetNextPageAsync(); //Clearing children when the view is removed from screen is much faster GDmain.Children.Remove(SPcontent); SPcontent.Children.Clear(); GDmain.Children.Add(SPcontent, 0, 1); int folderCount = 0, fileCount = 0; while (list != null) { foreach (var subFolder in list) { if (StopRequest) { break; } var lb = new CloudFileLabel(subFolder); lb.FileClicked += delegate { LBselected?.Deselect(); (LBselected = lb).Select(); OnFileClicked(lb); }; SPcontent.Children.Add(lb); folderCount++; } BTNrefresh.Text = $"↻ (Refreshing...){(folderCount > 0 ? $" | {folderCount} folders" : "")}{(fileCount > 0 ? $" | {fileCount} files" : "")}"; list = await FoldersGetter.GetNextPageAsync(); } await FilesGetter.ResetAsync(); list = await FilesGetter.GetNextPageAsync(); while (list != null) { foreach (var file in list) { if (StopRequest) { IsRunning = false; return; } var lb = new CloudFileLabel(file); lb.FileClicked += delegate { LBselected?.Deselect(); (LBselected = lb).Select(); OnFileClicked(lb); }; SPcontent.Children.Add(lb); fileCount++; } BTNrefresh.Text = $"↻ (Refreshing...){(folderCount > 0 ? $" | {folderCount} folders" : "")}{(fileCount > 0 ? $" | {fileCount} files" : "")}"; list = await FilesGetter.GetNextPageAsync(); } PBmain.IsRunning = PBmain.IsVisible = false; MyLogger.Log("Folders loaded"); IsRunning = false; await Task.Delay(500); BTNrefresh.Text = $"↻{(folderCount>0?$" | {folderCount} folders":"")}{(fileCount>0?$" | {fileCount} files":"")}{(StopRequest?" (Incomplete)":"")}"; if (folderCount == 0 && fileCount == 0) { BTNrefresh.Text += " (Empty)"; } BTNrefresh.IsEnabled = true; }