2 // System.Windows.Forms.Design.FolderNameEditor.cs
5 // Gert Driesen (drieseng@users.sourceforge.net)
6 // (C) 2004 Ximian, Inc. http://www.ximian.com
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System
.ComponentModel
;
31 using System
.Drawing
.Design
;
33 namespace System
.Windows
.Forms
.Design
36 public class FolderNameEditor
: UITypeEditor
38 #region Public Instance Constructors
40 public FolderNameEditor ()
44 #endregion Public Instance Constructors
46 #region Override implementation of UITypeEditor
48 public override object EditValue (ITypeDescriptorContext context
, IServiceProvider provider
, object value)
50 if (folderBrowser
== null)
52 folderBrowser
= new FolderBrowser ();
53 InitializeDialog (folderBrowser
);
55 if (this.folderBrowser
.ShowDialog () != DialogResult
.OK
)
59 return folderBrowser
.DirectoryPath
;
62 public override UITypeEditorEditStyle
GetEditStyle (ITypeDescriptorContext context
)
64 return UITypeEditorEditStyle
.Modal
;
67 #endregion Override implementation of UITypeEditor
69 #region Protected Instance Methods
71 protected virtual void InitializeDialog (FolderBrowser folderBrowser
)
75 #endregion Protected Instance Methods
77 #region Private Instance Fields
79 private FolderBrowser folderBrowser
;
81 #endregion Private Instance Fields
83 protected enum FolderBrowserFolder
90 NetAndDialUpConnections
= 49,
91 NetworkNeighborhood
= 18,
100 protected enum FolderBrowserStyles
102 BrowseForComputer
= 4096,
103 BrowseForEverything
= 16384,
104 BrowseForPrinter
= 8192,
105 RestrictToDomain
= 2,
106 RestrictToFilesystem
= 1,
107 RestrictToSubfolders
= 8,
111 protected sealed class FolderBrowser
: Component
114 public FolderBrowser ()
116 startLocation
= FolderBrowserFolder
.Desktop
;
117 publicOptions
= FolderBrowserStyles
.RestrictToFilesystem
;
118 descriptionText
= string.Empty
;
119 directoryPath
= string.Empty
;
122 #region Public Instance Properties
124 public string Description
128 return descriptionText
;
132 descriptionText
= (value == null) ? string.Empty
: value;
135 public string DirectoryPath
139 return directoryPath
;
143 public FolderBrowserFolder StartLocation
147 return startLocation
;
151 startLocation
= value;
155 public FolderBrowserStyles Style
159 return publicOptions
;
164 publicOptions
= value;
168 #endregion Public Instance Properties
170 #region Public Instance Methods
173 public DialogResult
ShowDialog ()
175 return ShowDialog (null);
179 public DialogResult
ShowDialog (IWin32Window owner
)
181 throw new NotImplementedException ();
184 #endregion Public Instance Methods
186 #region Private Instance Fields
188 private string descriptionText
;
189 private string directoryPath
;
190 private FolderBrowserStyles publicOptions
;
191 private FolderBrowserFolder startLocation
;
193 #endregion Private Instance Fields