private async void Button_Click(object sender, RoutedEventArgs e) //单个视频下载 { var sESSDATA = ApplicationData.Current.LocalSettings.Values["biliUserSESSDATA"] as string; var model = (sender as Button)?.DataContext as VideoInfo; this.needToClose = true; this.Hide(); try { var info = await BiliVideoHelper.GetSingleVideoInfoAsync(model.Info.Bv, model.Info.Cid, 64, sESSDATA); var dialog = await SingleVideoDialog.CreateAsync(info, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { this.needToClose = false; await this.ShowAsync(); } } catch (ParsingVideoException ex) { var dialog = new ErrorDialog(ex.Message, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { MainPage.NavView.SelectedItem = MainPage.NavViewItems[2]; MainPage.ContentFrame.Navigate(typeof(UserPage)); } } catch (NullReferenceException) { var dialog = new ContentDialog() { Title = "错误", Content = new TextBlock() { Text = "该视频不存在dash格式的视频文件", FontFamily = new FontFamily("Microsoft Yahei UI"), FontSize = 20 }, PrimaryButtonText = "知道了" }; await dialog.ShowAsync(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { var sESSDATA = ApplicationData.Current.LocalSettings.Values["biliUserSESSDATA"] as string; var model = (sender as Button)?.DataContext as VideoInfo; this.needToClose = true; this.Hide(); try { var info = await BiliVideoHelper.GetSingleVideoInfoAsync(model.Info.Bv, model.Info.Cid, 64, sESSDATA); var dialog = await SingleVideoDialog.CreateAsync(info, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { this.needToClose = false; await this.ShowAsync(); } } catch (DirectoryNotFoundException ex) { var dialog = new ExceptionDialog(ex.Message, XamlRoot); await dialog.ShowAsync(); } catch (ParsingVideoException ex) { var dialog = new ErrorDialog(ex.Message, XamlRoot); var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Primary) { MainPage.NavView.SelectedItem = MainPage.NavViewItems[2]; MainPage.ContentFrame.Navigate(typeof(UserPage)); } } catch (System.Exception ex) { var dialog = new ErrorDialog(ex.Message, XamlRoot); dialog.PrimaryButtonText = ""; await dialog.ShowAsync(); } }