Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-06-13 03:25:10 +0400
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>2011-06-15 21:13:45 +0400
commit8e991baa7057533c24b9300a3273ffec232fd2a6 (patch)
tree6a74810c5fca1655ec7b4ddc9a82a9d550c08f32 /main/src/addins/WindowsPlatform
parent965d0768d31bd63af0b64520c6c2472570f9722c (diff)
[Windows] Use FolderBrowserDialog instead of FileDialog if needed.
Diffstat (limited to 'main/src/addins/WindowsPlatform')
-rw-r--r--main/src/addins/WindowsPlatform/SelectFileDialogHandler.cs53
1 files changed, 32 insertions, 21 deletions
diff --git a/main/src/addins/WindowsPlatform/SelectFileDialogHandler.cs b/main/src/addins/WindowsPlatform/SelectFileDialogHandler.cs
index d9905dcc62..c5ba648abb 100644
--- a/main/src/addins/WindowsPlatform/SelectFileDialogHandler.cs
+++ b/main/src/addins/WindowsPlatform/SelectFileDialogHandler.cs
@@ -11,35 +11,38 @@ namespace MonoDevelop.Platform
{
public bool Run(SelectFileDialogData data)
{
- FileDialog dlg = null;
+ CommonDialog dlg = null;
if (data.Action == Gtk.FileChooserAction.Open)
dlg = new OpenFileDialog();
else if (data.Action == Gtk.FileChooserAction.Save)
- dlg = new SaveFileDialog();
+ dlg = new SaveFileDialog();
+ else if (data.Action == Gtk.FileChooserAction.SelectFolder)
+ dlg = new FolderBrowserDialog ();
- SetCommonFormProperties (data, dlg);
+ if (dlg is FileDialog)
+ SetCommonFormProperties (data, dlg as FileDialog);
+ else
+ SetFolderBrowserProperties (data, dlg as FolderBrowserDialog);
- bool result = false;
- try
- {
+
+ using (dlg) {
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 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 result;
+ return true;
+ }
}
internal static void SetCommonFormProperties (SelectFileDialogData data, FileDialog dialog)
@@ -59,6 +62,14 @@ namespace MonoDevelop.Platform
if (openDialog != null)
openDialog.Multiselect = data.SelectMultiple;
}
+
+ static void SetFolderBrowserProperties (SelectFileDialogData data, FolderBrowserDialog dialog)
+ {
+ if (!string.IsNullOrEmpty (data.Title))
+ dialog.Description = data.Title;
+
+ dialog.SelectedPath = data.CurrentFolder;
+ }
static string GetFilterFromData (IList<SelectFileDialogFilter> filters)
{