public async Task DisplayAsync(StorageFile file) { FileGrid.Columns.Clear(); Table table = await ParquetUwp.LoadAsync(file); int i = 0; foreach (Field f in table.Schema.Fields) { FileGrid.Columns.Add(new DataGridTextColumn { Header = f.Name, Width = DataGridLength.SizeToCells, Binding = new Binding { Path = new PropertyPath("[" + i++ + "]") } }); } FileGrid.ItemsSource = table.Select(r => new TableRowView(r)).ToList(); StatusText.Text = $"showing first {table.Count} records."; }
private async void OpenFileButton_Click(object sender, RoutedEventArgs e) { StorageFile file = await ParquetUwp.GetFromFilePickerAsync(); if (file != null && FileDragged != null) { await FileDragged(file); } }
private async void Grid_Drop(object sender, DragEventArgs e) { StorageFile file = await ParquetUwp.GetFirstParquetFileAsync(e); if (file != null && FileDragged != null) { await FileDragged(file); } }
private async Task LoadAndDisplay(StorageFile file) { HamburgerMenu.IsPaneOpen = false; if (file == null) { return; } LoadingControl.IsLoading = true; try { DataSet ds = await ParquetUwp.LoadAsync(file); Display(ds); } finally { LoadingControl.IsLoading = false; } }
private async void HamburgerMenu_ItemClick(object sender, ItemClickEventArgs e) { MenuItem mi = e.ClickedItem as MenuItem; if (mi == null) { return; } if (mi.Action == "open") { await LoadAndDisplay(await ParquetUwp.GetFromFilePickerAsync()); } else if (mi.Action == "issue") { await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/aloneguid/parquet-viewer-uwp/issues/new")); } else if (mi.Action == "about") { await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/aloneguid/parquet-viewer-uwp")); } HamburgerMenu.SelectedItem = null; }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); await LoadAndDisplay(ParquetUwp.GetFromFileAssociationAsync(e)); }