private void on_ExportButton_clicked(object o, EventArgs args) { if (this.image != null) { string folderPath; if (SelectExportPathDialog.SelectPath(out folderPath)) { string fromPath = this.image.Details.Path; string toPath = folderPath + "/" + System.IO.Path.GetFileName(fromPath); try { System.IO.File.Copy(fromPath, toPath); } catch (Exception ex) { BooruApp.BooruApplication.Log.Log(BooruLog.Category.Files, ex, "Caught exception trying to copy " + fromPath + " to " + toPath); } } } }
void on_ExportButton_clicked(object sender, EventArgs args) { if (this.exporter != null) { var messageDlg = new Gtk.MessageDialog( BooruApp.BooruApplication.MainWindow, Gtk.DialogFlags.Modal, Gtk.MessageType.Question, Gtk.ButtonsType.YesNo, "Cancel export?" ); messageDlg.SecondaryText = "Do you want to cancel the currently running export?"; int result = messageDlg.Run(); messageDlg.Destroy(); if (result == (int)Gtk.ResponseType.Yes) { this.exporter.Abort(); this.exporter = null; this.ExportProgress.Visible = false; } return; } string folderPath; if (SelectExportPathDialog.SelectPath(out folderPath)) { int exportedCount = 0; this.exporter = new ImageExporter(this.store, folderPath); this.exporter.Exported += () => { exportedCount++; BooruApp.BooruApplication.TaskRunner.StartTaskMainThread("Update export progress bar", () => { this.ExportProgress.Fraction = exportedCount / (float)this.foundImageCount; }); }; this.exporter.Finished += () => { this.exporter = null; }; this.exporter.Start(); } }
public static bool SelectPath(out string folderPath) { var dlg = new SelectExportPathDialog(); if (dlg.Run() != (int)Gtk.ResponseType.Ok) { dlg.Destroy(); folderPath = null; return(false); } if (!System.IO.Directory.Exists(dlg.Filename)) { dlg.Destroy(); folderPath = null; return(false); } BooruApp.BooruApplication.Database.Config.SetString("export.lastpath", dlg.CurrentFolder); folderPath = dlg.CurrentFolder; dlg.Destroy(); return(true); }