Ejemplo n.º 1
0
        internal NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags)
        {
            flags |= NativeMethods.FOS.FOS_PICKFOLDERS;
            // TODO: other flags

            return(flags);
        }
Ejemplo n.º 2
0
 internal override NativeMethods.FOS GenerateNativeDialogOptions()
 {
     NativeMethods.FOS fos = (NativeMethods.FOS) 0;
     if (this.Multiselect)
     {
         fos |= NativeMethods.FOS.FOS_ALLOWMULTISELECT;
     }
     return(fos | base.GenerateNativeDialogOptions());
 }
Ejemplo n.º 3
0
 /// <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;
 }
Ejemplo n.º 4
0
        internal override NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags)
        {
            if (multiselect)
            {
                flags |= NativeMethods.FOS.FOS_ALLOWMULTISELECT;
            }
            // TODO: other flags

            return(flags);
        }
Ejemplo n.º 5
0
 internal void SetOption(NativeMethods.FOS option, bool value)
 {
     if (value)
     {
         _options |= option;
     }
     else
     {
         _options &= ~option;
     }
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
 /// <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;
     }
 }
Ejemplo n.º 10
0
 /// <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;
     }
 }
Ejemplo n.º 11
0
 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);
                }
            }
        }
Ejemplo n.º 13
0
        //---------------------------------------------------
        //
        // 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
            { }
        }
Ejemplo n.º 14
0
        private bool IsOptionSet(IFileDialog dialog, NativeMethods.FOS flag)
        {
            NativeMethods.FOS currentFlags = GetCurrentOptionFlags(dialog);

            return((currentFlags & flag) == flag);
        }
Ejemplo n.º 15
0
 internal void SetOption(NativeMethods.FOS option, bool value)
 {
     if( value )
         _options |= option;
     else
         _options &= ~option;
 }
Ejemplo n.º 16
0
 /// <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;
     }
 }
Ejemplo n.º 17
0
 /// <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;
     }
 }
Ejemplo n.º 18
0
 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;
 }
Ejemplo n.º 20
0
 internal abstract NativeMethods.FOS GetDerivedOptionFlags(NativeMethods.FOS flags);