private async void ForceGetButton_Click(object sender, RoutedEventArgs e) { MainWindow.progressDialog.Show(); try { byte[] content = await HtmlGetter.GetResponseBinaryAsync(Item); MainWindow.progressDialog.Close(); if (Item.Response_Type == ResponseType.Binary) { bool yes = await MainWindow.dialog.ShowYesNoAsync(FindResource("label_binaryTypePreview") as string, FindResource("label_binaryTypePreviewTitle") as string); if (yes) { string defaultName = ""; string url = Item.Url.TrimEnd('/'); int index = url.LastIndexOf('/') + 1; if (index > 0 && index < Item.Url.Length) { defaultName = url.Substring(index); } string path = FzLib.UI.Dialog.FileSystemDialog.GetSaveFile(null, false, false, defaultName); if (path != null) { File.WriteAllBytes(path, content); } } return; } if (content.Length == 0) { await MainWindow.dialog.ShowInfomationAsync(FindResource("label_responseIsEmpty") as string, FindResource("error_forceGet") as string); } else { PreviewWindow win = new PreviewWindow(content.ToEncodedString(), Item.Response_Type) { Owner = MainWindow }; win.ShowDialog(); } } catch (Exception ex) { MainWindow.progressDialog.Close(); await MainWindow.dialog.ShowErrorAsync(ex.ToString(), FindResource("error_forceGet") as string); } }
private async void ViewLatestButton_Click(object sender, RoutedEventArgs e) { var dialog = MainWindow.dialog; byte[] content = await Item.GetLatestContentAsync(); if (content == null) { await dialog.ShowErrorAsync(FindResource("error_notGetYet") as string); return; } PreviewWindow win = new PreviewWindow(content.ToEncodedString(), Item.Response_Type) { Owner = Window.GetWindow(this) }; win.ShowDialog(); }