internal NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags) { flags |= NativeMethods.FOS.FOS_PICKFOLDERS; // TODO: other flags return(flags); }
internal override NativeMethods.FOS GenerateNativeDialogOptions() { NativeMethods.FOS fos = (NativeMethods.FOS) 0; if (this.Multiselect) { fos |= NativeMethods.FOS.FOS_ALLOWMULTISELECT; } return(fos | base.GenerateNativeDialogOptions()); }
/// <summary> /// Resets all properties to their default values. /// </summary> public void Reset() { _description = string.Empty; UseDescriptionForTitle = false; _selectedPath = string.Empty; RootFolder = Environment.SpecialFolder.Desktop; ShowNewFolderButton = true; _selectedPaths = null; _options = 0; }
internal override NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags) { if (multiselect) { flags |= NativeMethods.FOS.FOS_ALLOWMULTISELECT; } // TODO: other flags return(flags); }
internal void SetOption(NativeMethods.FOS option, bool value) { if (value) { _options |= option; } else { _options &= ~option; } }
internal virtual NativeMethods.FOS GenerateNativeDialogOptions() { NativeMethods.FOS fos = NativeMethods.FOS.FOS_FORCEFILESYSTEM | NativeMethods.FOS.FOS_NOTESTFILECREATE; if (this.RestoreDirectory) { fos |= NativeMethods.FOS.FOS_NOCHANGEDIR; } if (this.PickFolders) { fos |= NativeMethods.FOS.FOS_PICKFOLDERS; } return(fos); }
private NativeMethods.FOS CalculateNativeDialogOptionFlags() { // We start with only a few flags set by default, then go from there based // on the current state of the managed dialog's property values NativeMethods.FOS flags = NativeMethods.FOS.FOS_NOTESTFILECREATE | NativeMethods.FOS.FOS_FORCEFILESYSTEM; // Call to derived (concrete) dialog to set dialog-specific flags flags = GetDerivedOptionFlags(flags); // Apply other optional flags if (checkFileExists) { flags |= NativeMethods.FOS.FOS_FILEMUSTEXIST; } if (checkPathExists) { flags |= NativeMethods.FOS.FOS_PATHMUSTEXIST; } if (!checkValidNames) { flags |= NativeMethods.FOS.FOS_NOVALIDATE; } if (!checkReadOnly) { flags |= NativeMethods.FOS.FOS_NOREADONLYRETURN; } if (restoreDirectory) { flags |= NativeMethods.FOS.FOS_NOCHANGEDIR; } if (!showPlacesList) { flags |= NativeMethods.FOS.FOS_HIDEPINNEDPLACES; } if (!addToMruList) { flags |= NativeMethods.FOS.FOS_DONTADDTORECENT; } if (showHiddenItems) { flags |= NativeMethods.FOS.FOS_FORCESHOWHIDDEN; } if (!dereferenceLinks) { flags |= NativeMethods.FOS.FOS_NODEREFERENCELINKS; } return(flags); }
private NativeMethods.FOS ApplyNativeDialogFlags() { NativeMethods.FOS flags = NativeMethods.FOS.NOTESTFILECREATE | NativeMethods.FOS.PICKFOLDERS; flags |= AllowNonFileSystem ? NativeMethods.FOS.ALLNONSTORAGEITEMS : NativeMethods.FOS.FORCEFILESYSTEM; if (Multiselect) { flags |= NativeMethods.FOS.ALLOWMULTISELECT; } if (EnsureFileExists) { flags |= NativeMethods.FOS.FILEMUSTEXIST; } if (EnsurePathExists) { flags |= NativeMethods.FOS.PATHMUSTEXIST; } if (!EnsureValidNames) { flags |= NativeMethods.FOS.NOVALIDATE; } if (!EnsureReadOnly) { flags |= NativeMethods.FOS.NOREADONLYRETURN; } if (RestoreDirectory) { flags |= NativeMethods.FOS.NOCHANGEDIR; } if (!ShowPlacesList) { flags |= NativeMethods.FOS.HIDEPINNEDPLACES; } if (!AddToMruList) { flags |= NativeMethods.FOS.DONTADDTORECENT; } if (ShowHiddenItems) { flags |= NativeMethods.FOS.FORCESHOWHIDDEN; } if (!NavigateToShortcut) { flags |= NativeMethods.FOS.NODEREFERENCELINKS; } return(flags); }
/// <summary> /// Resets all properties to their default values. /// </summary> public virtual void Reset() { if (DownlevelDialog != null) { DownlevelDialog.Reset(); } else { _fileNames = null; _filter = null; _filterIndex = 1; _addExtension = true; _defaultExt = null; _options = 0; _title = null; CheckPathExists = true; } }
/// <summary> /// Resets all properties to their default values. /// </summary> public override void Reset() { if (DownlevelDialog != null) { DownlevelDialog.Reset(); } else { _fileNames = null; _filter = null; _filterIndex = 1; _addExtension = true; _defaultExt = null; _options = 0; _showHelp = false; _title = null; _supportMultiDottedExtensions = false; CheckPathExists = true; } }
internal override NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags) { if (overwritePrompt) { flags |= NativeMethods.FOS.FOS_OVERWRITEPROMPT; } if (createPrompt) { flags |= NativeMethods.FOS.FOS_CREATEPROMPT; } if (!enableMiniMode) { flags |= NativeMethods.FOS.FOS_DEFAULTNOMINIMODE; } if (strictExtensions) { flags |= NativeMethods.FOS.FOS_STRICTFILETYPES; } return(flags); }
private void SetDialogProperties(Ookii.Dialogs.Interop.IFileDialog dialog) { // Description if (!string.IsNullOrEmpty(_description)) { if (_useDescriptionForTitle) { dialog.SetTitle(_description); } else { Ookii.Dialogs.Interop.IFileDialogCustomize customize = (Ookii.Dialogs.Interop.IFileDialogCustomize)dialog; customize.AddText(0, _description); } } NativeMethods.FOS options = NativeMethods.FOS.FOS_PICKFOLDERS | NativeMethods.FOS.FOS_FORCEFILESYSTEM | NativeMethods.FOS.FOS_FILEMUSTEXIST; if (Multiselect) { options |= NativeMethods.FOS.FOS_ALLOWMULTISELECT; } dialog.SetOptions(options); if (!string.IsNullOrEmpty(_selectedPaths[0])) { string parent = Path.GetDirectoryName(_selectedPaths[0]); if (parent == null || !Directory.Exists(parent)) { dialog.SetFileName(_selectedPaths[0]); } else { string folder = Path.GetFileName(_selectedPaths[0]); dialog.SetFolder(NativeMethods.CreateItemFromParsingName(parent)); dialog.SetFileName(folder); } } }
//--------------------------------------------------- // // Private Methods // //--------------------------------------------------- #region Private Methods private void ApplyNativeSettings(IFileDialog dialog) { dialog.SetTitle(Title); NativeMethods.FOS flags = ApplyNativeDialogFlags(); dialog.SetOptions(flags); string directory = string.IsNullOrEmpty(InitialDirectory) ? null : Path.GetDirectoryName(InitialDirectory); if (directory == null) { return; } try { NativeMethods.SHCreateItemFromParsingName(InitialDirectory, IntPtr.Zero, new Guid(IIDGuid.IShellItem), out IShellItem folder); if (folder != null) { dialog.SetFolder(folder); } } catch { } }
private bool IsOptionSet(IFileDialog dialog, NativeMethods.FOS flag) { NativeMethods.FOS currentFlags = GetCurrentOptionFlags(dialog); return((currentFlags & flag) == flag); }
internal void SetOption(NativeMethods.FOS option, bool value) { if( value ) _options |= option; else _options &= ~option; }
/// <summary> /// Resets all properties to their default values. /// </summary> public virtual void Reset() { if( DownlevelDialog != null ) DownlevelDialog.Reset(); else { _fileNames = null; _filter = null; _filterIndex = 1; _addExtension = true; _defaultExt = null; _options = 0; _title = null; CheckPathExists = true; } }
/// <summary> /// Resets all properties to their default values. /// </summary> public override void Reset() { if( DownlevelDialog != null ) DownlevelDialog.Reset(); else { _fileNames = null; _filter = null; _filterIndex = 1; _addExtension = true; _defaultExt = null; _options = 0; _showHelp = false; _title = null; _supportMultiDottedExtensions = false; CheckPathExists = true; } }
internal bool GetOption(NativeMethods.FOS option) { return((_options & option) != 0); }
private void SetBit(string name, NativeMethods.FOS bit, bool set) { ThrowIfDialogShowing(string.Format("{0} cannot be changed while dialog is showing.", name)); if (set) _flags |= bit; else _flags &= ~bit; }
internal abstract NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags);