protected void OnButtonSaveClicked(object sender, EventArgs e) { TreePath sel = iconviewFiles.SelectedItems [0]; TreeIter iter; FilesStore.GetIter(out iter, sel); FileChooserDialog fc = new FileChooserDialog("Укажите путь для сохранения файла", (Gtk.Window) this.Toplevel, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fc.CurrentName = (string)FilesStore.GetValue(iter, (int)FilesCol.name); fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); logger.Info("Сохраняем файл на диск..."); byte[] file = (byte[])FilesStore.GetValue(iter, (int)FilesCol.file); if (file == null) { file = LoadFileFromDB((int)FilesStore.GetValue(iter, (int)FilesCol.id)); } System.IO.File.WriteAllBytes(fc.Filename, file); } fc.Destroy(); logger.Info("Ок"); }
protected void OnButtonOutputChooseClicked(object sender, EventArgs e) { FileChooserDialog fileChooserDialog; fileChooserDialog = new FileChooserDialog("Choose output file", this, FileChooserAction.Save, ("Cancel"), ResponseType.Cancel, ("Save"), ResponseType.Accept, null); try { if (File.Exists(entry_output_file_path.Text) || Directory.Exists(entry_output_file_path.Text)) { fileChooserDialog.SetFilename(entry_output_file_path.Text); } else if (Directory.Exists(System.IO.Path.GetDirectoryName(entry_output_file_path.Text))) { fileChooserDialog.SetFilename(System.IO.Path.GetDirectoryName(entry_output_file_path.Text)); } } catch (Exception ex) { } fileChooserDialog.Show(); if (fileChooserDialog.Run() == -3) { entry_output_file_path.Text = fileChooserDialog.Filename; checkbutton_output_copy_input_name.Active = false; } fileChooserDialog.Destroy(); }
protected void OnSaveAsActionActivated(object sender, EventArgs e) { if (DocTemplate == null) { return; } FileChooserDialog fc = new FileChooserDialog("Укажите файл для сохранения шаблона...", this, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); //FileFilter filter = new FileFilter(); fc.CurrentName = DocTemplate.Name + ".xml"; fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write); DocTemplate.SaveToStream(fs); fs.Close(); } fc.Destroy(); }
protected void OnImagePopupSave(object sender, EventArgs Arg) { FileChooserDialog fc = new FileChooserDialog("Укажите файл для сохранения картинки", this, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); //FileFilter filter = new FileFilter(); fc.CurrentName = DocInfo.Name + " " + entryNumber.Text + ".jpg"; fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); foreach (DocumentImage img in Images) { if (img.id == PopupImageId) { FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write); fs.Write(img.file, 0, (int)img.size); fs.Close(); } } } fc.Destroy(); }
public void Run() { _chooserDialog.Show(); var retVal = _chooserDialog.Run(); // If the user clicked Open, fire Activated ourselves // double click activation is will fire the callback itself, triggering dialog closure if (retVal == 0) { ChooserOnFileActivated(_chooserDialog, null); } }
protected void OnButtonInputChooseClicked(object sender, EventArgs e) { FileChooserDialog fileChooserDialog; fileChooserDialog = new FileChooserDialog("Choose input file", this, FileChooserAction.Open, ("Cancel"), ResponseType.Cancel, ("Open"), ResponseType.Accept, null); if (File.Exists(entry_input_file_path.Text) || Directory.Exists(entry_input_file_path.Text)) { fileChooserDialog.SetFilename(entry_input_file_path.Text); } fileChooserDialog.Show(); if (fileChooserDialog.Run() == -3) { entry_input_file_path.Text = fileChooserDialog.Filename; } fileChooserDialog.Destroy(); }
private String QueryUserForSearchFolder() { String result = null; FileChooserDialog dialog = new FileChooserDialog("Select a Folder to Search", this, FileChooserAction.SelectFolder, "Select", ResponseType.Ok, "Cancel", ResponseType.Cancel); dialog.Show(); if (dialog.Run() == (int)ResponseType.Ok) { result = dialog.Filename; } dialog.Destroy(); return(result); }
protected void OnButtonFileChooserClicked(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog("Укажите файл резервной копии", (Window)this.Toplevel, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fc.SetFilename(ViewModel.FileName); fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { ViewModel.FileName = fc.Filename; } fc.Destroy(); }
protected void OnButtonSavePhotoClicked(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog("Укажите файл для сохранения фотографии", (Gtk.Window) this.Toplevel, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fc.CurrentName = ViewModel.SuggestedPhotoName; fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); ViewModel.SavePhoto(fc.Filename); } fc.Destroy(); }
public DialogResult ShowDialog(IWin32Window owner) { var oldDirectory = Directory.GetCurrentDirectory(); try { m_dlg = CreateFileChooserDialog(); m_dlg.Show(); Gtk.Application.Run(); return(DialogResult); } finally { if (RestoreDirectory) { Directory.SetCurrentDirectory(oldDirectory); } } }
protected void OnButtonSavePhotoClicked(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog("Укажите файл для сохранения фотографии", (Window)this.Toplevel, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fc.CurrentName = (GetSaveFileName != null ? GetSaveFileName() : "фото") + ".jpg"; fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); FileStream fs = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write); fs.Write(ImageFile, 0, ImageFile.Length); fs.Close(); } fc.Destroy(); }
public void ShowFileChooser(object obj, EventArgs args) { FileChooserDialog fileChooser = new FileChooserDialog("Hola", this.ventana, FileChooserAction.Open, "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept); FileFilter file = new FileFilter(); file.AddPattern("*.mp3"); file.AddPattern("*.mp4"); file.AddPattern("*.aac"); fileChooser.AddFilter(file); fileChooser.Show(); if (fileChooser.Run() == (int)ResponseType.Accept) { byte[] cancionBytes = System.IO.File.ReadAllBytes(fileChooser.Filename); Console.Write(cancionBytes[cancionBytes.Length - 1]); } fileChooser.Destroy(); }
protected void OnButtonPDFClicked(object sender, EventArgs e) { FileChooserDialog fc = new FileChooserDialog("Укажите файл для сохранения документа", this, FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept); fc.CurrentName = DocInfo.Name + " " + entryNumber.Text + ".pdf"; fc.Show(); if (fc.Run() == (int)ResponseType.Accept) { fc.Hide(); iTextSharp.text.Document document = new iTextSharp.text.Document(); using (var stream = new FileStream(fc.Filename, FileMode.Create, FileAccess.Write, FileShare.None)) { iTextSharp.text.pdf.PdfWriter.GetInstance(document, stream); document.Open(); foreach (DocumentImage img in Images) { if (img.Image.Width > img.Image.Height) { document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); } else { document.SetPageSize(iTextSharp.text.PageSize.A4); } document.NewPage(); var image = iTextSharp.text.Image.GetInstance(img.file); image.SetAbsolutePosition(0, 0); image.ScaleToFit(document.PageSize.Width, document.PageSize.Height); document.Add(image); } document.Close(); } } fc.Destroy(); }