Example #1
0
        private void SetDialogProperties(IFileDialog dialog)
        {
            // Description
            if (!string.IsNullOrEmpty(_description))
            {
                if (UseDescriptionForTitle)
                {
                    dialog.SetTitle(_description);
                }
                else
                {
                    IFileDialogCustomize customize = (IFileDialogCustomize)dialog;
                    customize.AddText(0, _description);
                }
            }

            dialog.SetOptions(NativeMethods.FOS.FOS_PICKFOLDERS | NativeMethods.FOS.FOS_FORCEFILESYSTEM | NativeMethods.FOS.FOS_FILEMUSTEXIST);

            if (!string.IsNullOrEmpty(_selectedPath))
            {
                string parent = Path.GetDirectoryName(_selectedPath);
                if (parent == null || !Directory.Exists(parent))
                {
                    dialog.SetFileName(_selectedPath);
                }
                else
                {
                    string folder = Path.GetFileName(_selectedPath);
                    dialog.SetFolder(NativeMethods.CreateItemFromParsingName(parent));
                    dialog.SetFileName(folder);
                }
            }
        }
		/// <summary>
		/// Attach this control to the dialog object
		/// </summary>
		/// <param name="dialog">Target dialog</param>
		internal override void Attach(IFileDialogCustomize dialog) {
			Debug.Assert(dialog != null, "CommonFileDialog.Attach: dialog parameter can not be null");

			// Add a text control
			dialog.AddText(this.Id, this.Text);

			// Sync unmanaged properties with managed properties
			SyncUnmanagedProperties();
		}
Example #3
0
        /// <summary>
        /// Attach this control to the dialog object
        /// </summary>
        /// <param name="dialog">Target dialog</param>
        public override void Attach(IFileDialogCustomize dialog)
        {
            Debug.Assert(dialog != null, "CommonFileDialog.Attach: dialog parameter can not be null");

            // Add a text control
            dialog.AddText(this.Id, this.Text);

            // Sync unmanaged properties with managed properties
            SyncUnmanagedProperties();
        }