public static FolderBrowserDialogEx ComputerBrowser() { FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.BecomeComputerBrowser(); return(ex); }
public bool ShowDialog(IntPtr hWndOwner) { if ((Environment.OSVersion.Version.Major >= 6) && !this.UseOldDialog) { Reflector reflector = new Reflector("System.Windows.Forms"); uint num = 0; Type type = reflector.GetType("FileDialogNative.IFileDialog"); object obj2 = reflector.Call(this.ofd, "CreateVistaDialog", new object[0]); reflector.Call(this.ofd, "OnBeforeVistaDialog", new object[] { obj2 }); uint num2 = (uint)reflector.CallAs(typeof(FileDialog), this.ofd, "GetOptions", new object[0]); num2 |= (uint)reflector.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); reflector.CallAs(type, obj2, "SetOptions", new object[] { num2 }); object obj3 = reflector.New("FileDialog.VistaDialogEvents", new object[] { this.ofd }); object[] parameters = new object[] { obj3, num }; reflector.CallAs2(type, obj2, "Advise", parameters); num = (uint)parameters[1]; try { int num3 = (int)reflector.CallAs(type, obj2, "Show", new object[] { hWndOwner }); return(0 == num3); } finally { reflector.CallAs(type, obj2, "Unadvise", new object[] { num }); GC.KeepAlive(obj3); } } FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.Description = this.Title; ex.SelectedPath = this.InitialDirectory; ex.ShowNewFolderButton = true; ex.ShowEditBox = true; ex.ShowFullPathInEditBox = true; if (ex.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) { return(false); } this.ofd.FileName = ex.SelectedPath; return(true); }
public bool ShowDialog(IntPtr hWndOwner) { if ((Environment.OSVersion.Version.Major >= 6) && !this.UseOldDialog) { Reflector reflector = new Reflector("System.Windows.Forms"); uint num = 0; Type type = reflector.GetType("FileDialogNative.IFileDialog"); object obj2 = reflector.Call(this.ofd, "CreateVistaDialog", new object[0]); reflector.Call(this.ofd, "OnBeforeVistaDialog", new object[] {obj2}); uint num2 = (uint) reflector.CallAs(typeof (FileDialog), this.ofd, "GetOptions", new object[0]); num2 |= (uint) reflector.GetEnum("FileDialogNative.FOS", "FOS_PICKFOLDERS"); reflector.CallAs(type, obj2, "SetOptions", new object[] {num2}); object obj3 = reflector.New("FileDialog.VistaDialogEvents", new object[] {this.ofd}); object[] parameters = new object[] {obj3, num}; reflector.CallAs2(type, obj2, "Advise", parameters); num = (uint) parameters[1]; try { int num3 = (int) reflector.CallAs(type, obj2, "Show", new object[] {hWndOwner}); return (0 == num3); } finally { reflector.CallAs(type, obj2, "Unadvise", new object[] {num}); GC.KeepAlive(obj3); } } FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.Description = this.Title; ex.SelectedPath = this.InitialDirectory; ex.ShowNewFolderButton = true; ex.ShowEditBox = true; ex.ShowFullPathInEditBox = true; if (ex.ShowDialog(new WindowWrapper(hWndOwner)) != DialogResult.OK) { return false; } this.ofd.FileName = ex.SelectedPath; return true; }
public static FolderBrowserDialogEx ComputerBrowser() { FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.BecomeComputerBrowser(); return ex; }
public static FolderBrowserDialogEx PrinterBrowser() { FolderBrowserDialogEx ex = new FolderBrowserDialogEx(); ex.BecomePrinterBrowser(); return ex; }