private void Image_Tapped(object sender, TappedRoutedEventArgs e) { Image im = sender as Image; bool isBegin = false; if (im.Name == "ImageStart") { this.ImageStart.Visibility = Visibility.Collapsed; this.ImagePauset.Visibility = Visibility.Visible; isBegin = true; } else { this.ImageStart.Visibility = Visibility.Visible; this.ImagePauset.Visibility = Visibility.Collapsed; } if (!isBegin) { _download.PauseAll(); } else { if (_download == null) { string url = CommonString.URL; _download = new BackgroundDownload(); _download.GetPercent += (current, total) => { PBarDownload.Value = current; TextBlockPercent.Text = current + "%"; if (current >= 100) { TextBlockState.Text = "下载完成"; _download = null; MyToast.ShowToast(" ", Global.Current.Globalization.Video_DownloadMessage); } }; _download.ErrorException += (o, s) => { TextBlockState.Text = "下载错误 " + s; }; TextBlockState.Text = "下载进度"; TextBlockPercent.Text = 0 + "%"; PBarDownload.Value = 0; _download.StartDownload(url); } else { TextBlockState.Text = Global.Current.Globalization.Video_Downloading; _download.ResumeAll(); } } }
private void DownloadFile(bool isBegin) { SetButtonVisable(isBegin); if (!isBegin) { StateTextBlock.Text = Global.Current.Globalization.Video_Pause; _download.PauseAll(); } else { if (_download == null) { var url = CommonString.URL; _download = new BackgroundDownload(); _download.GetPercent += (current, total) => { PBar.Value = current; PercentTextBlock.Text = current + "%"; if (current >= 100) { SetButtonVisable(false); StateTextBlock.Text = Global.Current.Globalization.Video_DownloadMessage; _download = null; StartButton.IsEnabled = false; } }; _download.ErrorException += (sender, s) => { StateTextBlock.Text = Global.Current.Globalization.Video_DownloadError + ":" + s; }; StateTextBlock.Text = Global.Current.Globalization.Video_Downloading; PercentTextBlock.Text = 0 + "%"; PBar.Value = 0; _download.StartDownload(url); } else { StateTextBlock.Text = Global.Current.Globalization.Video_Downloading; _download.ResumeAll(); } } }