public bool Run(SelectFileDialogData data) { FileDialog dlg = null; if (data.Action == Gtk.FileChooserAction.Open) dlg = new OpenFileDialog(); else if (data.Action == Gtk.FileChooserAction.Save) dlg = new SaveFileDialog(); dlg.InitialDirectory = data.CurrentFolder; if (!string.IsNullOrEmpty (data.InitialFileName)) dlg.FileName = data.InitialFileName; bool result = false; try { WinFormsRoot root = new WinFormsRoot(); if (dlg.ShowDialog(root) == DialogResult.Cancel) result = false; else { FilePath[] paths = new FilePath [dlg.FileNames.Length]; for (int n=0; n<dlg.FileNames.Length; n++) paths [n] = dlg.FileNames [n]; data.SelectedFiles = paths; result = true; } } finally { dlg.Dispose(); } return result; }
public bool Run(SelectFileDialogData data) { CommonDialog dlg = null; if (data.Action == Gtk.FileChooserAction.Open) dlg = new OpenFileDialog(); else if (data.Action == Gtk.FileChooserAction.Save) dlg = new SaveFileDialog(); else if (data.Action == Gtk.FileChooserAction.SelectFolder) dlg = new FolderBrowserDialog (); if (dlg is FileDialog) SetCommonFormProperties (data, dlg as FileDialog); else SetFolderBrowserProperties (data, dlg as FolderBrowserDialog); using (dlg) { WinFormsRoot root = new WinFormsRoot(); if (dlg.ShowDialog(root) == DialogResult.Cancel) return false; if (dlg is FileDialog) { var fileDlg = dlg as OpenFileDialog; FilePath[] paths = new FilePath [fileDlg.FileNames.Length]; for (int n=0; n < fileDlg.FileNames.Length; n++) paths [n] = fileDlg.FileNames [n]; data.SelectedFiles = paths; } else { var folderDlg = dlg as FolderBrowserDialog; data.SelectedFiles = new [] { new FilePath (folderDlg.SelectedPath) }; } return true; } }
public bool Run (OpenFileDialogData data) { FileDialog fileDlg = null; if (data.Action == Gtk.FileChooserAction.Open) fileDlg = new OpenFileDialog (); else fileDlg = new SaveFileDialog (); var dlg = new CustomOpenFileDialog (fileDlg, data); SelectFileDialogHandler.SetCommonFormProperties (data, dlg.FileDialog); using (dlg) { WinFormsRoot root = new WinFormsRoot (); if (dlg.ShowDialog (root) == DialogResult.Cancel) return false; FilePath[] paths = new FilePath [fileDlg.FileNames.Length]; for (int n = 0; n < fileDlg.FileNames.Length; n++) paths [n] = fileDlg.FileNames [n]; data.SelectedFiles = paths; if (dlg.SelectedEncodingId != null) data.Encoding = dlg.SelectedEncodingId; if (dlg.SelectedViewer != null) { data.SelectedViewer = dlg.SelectedViewer; data.CloseCurrentWorkspace = dlg.CloseCurrentWorkspace; } } return true; }
public bool Run(AddFileDialogData data) { CustomAddFilesDialog adlg = new CustomAddFilesDialog(); adlg.StartLocation = AddonWindowLocation.Bottom; adlg.OpenDialog.InitialDirectory = data.CurrentFolder; adlg.OpenDialog.AddExtension = true; adlg.BuildActions = data.BuildActions; // adlg.OpenDialog.Filter = "Image Files(*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png"; WinFormsRunner runner = new WinFormsRunner(); bool result = false; Timer t = new Timer(); t.Interval = 20; try { t.Tick += delegate { // MonoDevelop.Core.Gui.DispatchService.RunPendingEvents(); }; //t.Enabled = true; WinFormsRoot root = new WinFormsRoot(); if (adlg.ShowDialog(root) == DialogResult.Cancel) { result = false; } else { FilePath[] paths = new FilePath [adlg.OpenDialog.FileNames.Length]; for (int n = 0; n < adlg.OpenDialog.FileNames.Length; n++) { paths [n] = adlg.OpenDialog.FileNames [n]; } data.SelectedFiles = paths; data.OverrideAction = adlg.OverrideAction; result = true; } } finally { t.Enabled = false; adlg.Dispose(); } return(result); }
public bool Run(SelectFileDialogData data) { FileDialog dlg = null; if (data.Action == Gtk.FileChooserAction.Open) { dlg = new OpenFileDialog(); } else if (data.Action == Gtk.FileChooserAction.Save) { dlg = new SaveFileDialog(); } dlg.InitialDirectory = data.CurrentFolder; if (!string.IsNullOrEmpty(data.InitialFileName)) { dlg.FileName = data.InitialFileName; } bool result = false; try { WinFormsRoot root = new WinFormsRoot(); if (dlg.ShowDialog(root) == DialogResult.Cancel) { result = false; } else { FilePath[] paths = new FilePath [dlg.FileNames.Length]; for (int n = 0; n < dlg.FileNames.Length; n++) { paths [n] = dlg.FileNames [n]; } data.SelectedFiles = paths; result = true; } } finally { dlg.Dispose(); } return(result); }
public bool Run (AddFileDialogData data) { CustomAddFilesDialog adlg = new CustomAddFilesDialog(); adlg.StartLocation = AddonWindowLocation.Bottom; adlg.OpenDialog.InitialDirectory = data.CurrentFolder; adlg.OpenDialog.AddExtension = true; adlg.BuildActions = data.BuildActions; // adlg.OpenDialog.Filter = "Image Files(*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png"; WinFormsRunner runner = new WinFormsRunner(); bool result = false; Timer t = new Timer(); t.Interval = 20; try { t.Tick += delegate { // MonoDevelop.Core.Gui.DispatchService.RunPendingEvents(); }; //t.Enabled = true; WinFormsRoot root = new WinFormsRoot(); if (adlg.ShowDialog(root) == DialogResult.Cancel) result = false; else { FilePath[] paths = new FilePath [adlg.OpenDialog.FileNames.Length]; for (int n=0; n<adlg.OpenDialog.FileNames.Length; n++) paths [n] = adlg.OpenDialog.FileNames [n]; data.SelectedFiles = paths; data.OverrideAction = adlg.OverrideAction; result = true; } } finally { t.Enabled = false; adlg.Dispose(); } return result; }
public bool Run(SelectFileDialogData data) { Application.EnableVisualStyles (); var parentWindow = data.TransientFor ?? MessageService.RootWindow; CommonDialog dlg = null; if (data.Action == Gtk.FileChooserAction.Open) dlg = new OpenFileDialog(); else if (data.Action == Gtk.FileChooserAction.Save) dlg = new SaveFileDialog(); else if (data.Action == Gtk.FileChooserAction.SelectFolder) dlg = new FolderBrowserDialog (); if (dlg is FileDialog) SetCommonFormProperties (data, dlg as FileDialog); else SetFolderBrowserProperties (data, dlg as FolderBrowserDialog); using (dlg) { WinFormsRoot root = new WinFormsRoot(); if (dlg.ShowDialog(root) == DialogResult.Cancel) { parentWindow.Present (); return false; } if (dlg is FileDialog) { var fileDlg = dlg as FileDialog; FilePath[] paths = new FilePath [fileDlg.FileNames.Length]; for (int n=0; n < fileDlg.FileNames.Length; n++) paths [n] = fileDlg.FileNames [n]; data.SelectedFiles = paths; } else { var folderDlg = dlg as FolderBrowserDialog; data.SelectedFiles = new [] { new FilePath (folderDlg.SelectedPath) }; } parentWindow.Present (); return true; } }
public bool Run (AddFileDialogData data) { CustomAddFilesDialog adlg = new CustomAddFilesDialog(); adlg.StartLocation = AddonWindowLocation.Bottom; adlg.BuildActions = data.BuildActions; WinFormsRunner runner = new WinFormsRunner(); bool result = false; SelectFileDialogHandler.SetCommonFormProperties (data, adlg.OpenDialog); Timer t = new Timer(); t.Interval = 20; try { t.Tick += delegate { // MonoDevelop.Core.Gui.DispatchService.RunPendingEvents(); }; //t.Enabled = true; WinFormsRoot root = new WinFormsRoot(); if (adlg.ShowDialog(root) == DialogResult.Cancel) result = false; else { FilePath[] paths = new FilePath [adlg.OpenDialog.FileNames.Length]; for (int n=0; n<adlg.OpenDialog.FileNames.Length; n++) paths [n] = adlg.OpenDialog.FileNames [n]; data.SelectedFiles = paths; data.OverrideAction = adlg.OverrideAction; result = true; } } finally { t.Enabled = false; adlg.Dispose(); } return result; }