diff options
author | David Karlaš <david.karlas@xamarin.com> | 2015-02-14 23:36:30 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2015-03-02 23:17:25 +0300 |
commit | 0725c0eb7aad1f62f33dd7726f4b63852f8453d9 (patch) | |
tree | 02a5500c98d116ab69562f2e21f6673d86400284 /main/src/addins/WindowsPlatform | |
parent | c545cf9d61d8f5af9a27aab94af4480992afc1b1 (diff) |
[WindowsPlatform] Added support for selecting files when using "Open containing folder"
Diffstat (limited to 'main/src/addins/WindowsPlatform')
-rw-r--r-- | main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs index 798ff15326..3e119d6290 100644 --- a/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs +++ b/main/src/addins/WindowsPlatform/WindowsPlatform/WindowsPlatform.cs @@ -401,6 +401,39 @@ namespace MonoDevelop.Platform return null; } + #region OpenFolder + + [DllImport ("shell32.dll", ExactSpelling = true)] + static extern int SHOpenFolderAndSelectItems ( + IntPtr pidlFolder, + uint cidl, + [In, MarshalAs (UnmanagedType.LPArray)] IntPtr[] apidl, + uint dwFlags); + + [DllImport ("shell32.dll", CharSet = CharSet.Auto)] + static extern IntPtr ILCreateFromPath ([MarshalAs (UnmanagedType.LPTStr)] string pszPath); + + [DllImport ("shell32.dll", CharSet = CharSet.None)] + static extern void ILFree (IntPtr pidl); + + public override void OpenFolder (FilePath folderPath, FilePath[] selectFiles) + { + if (selectFiles.Length == 0) { + Process.Start (folderPath); + } else { + var dir = ILCreateFromPath (folderPath); + var files = selectFiles.Select ((f) => ILCreateFromPath (f)).ToArray (); + try { + SHOpenFolderAndSelectItems (dir, (uint)files.Length, files, 0); + } finally { + ILFree (dir); + files.ToList ().ForEach (ILFree); + } + } + } + + #endregion + class WindowsDesktopApplication : DesktopApplication { public WindowsDesktopApplication (string id, string displayName, string exePath, bool isDefault) : base (id, displayName, isDefault) |