2 // System.Web.UI.WebControls.TreeNodeBinding.cs
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // (C) 2004 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
34 using System.Collections;
36 using System.ComponentModel;
38 namespace System.Web.UI.WebControls
40 [DefaultProperty ("TextField")]
41 public sealed class TreeNodeBinding: IStateManager, ICloneable, IDataSourceViewSchemaAccessor
43 StateBag ViewState = new StateBag ();
46 public string DataMember {
48 object o = ViewState ["DataMember"];
49 if (o != null) return (string) o;
53 ViewState ["DataMember"] = value;
60 object o = ViewState ["Depth"];
61 if (o != null) return (int) o;
65 ViewState ["Depth"] = value;
72 public string FormatString {
74 object o = ViewState ["FormatString"];
75 if (o != null) return (string) o;
79 ViewState ["FormatString"] = value;
85 public string ImageToolTip {
87 object o = ViewState ["ImageToolTip"];
88 if (o != null) return (string) o;
92 ViewState ["ImageToolTip"] = value;
97 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
98 public string ImageToolTipField {
100 object o = ViewState ["ImageToolTipField"];
101 if (o != null) return (string) o;
105 ViewState ["ImageToolTipField"] = value;
111 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
112 public string ImageUrl {
114 object o = ViewState ["ImageUrl"];
115 if (o != null) return (string) o;
119 ViewState ["ImageUrl"] = value;
124 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
125 public string ImageUrlField {
127 object o = ViewState ["ImageUrlField"];
128 if (o != null) return (string) o;
132 ViewState ["ImageUrlField"] = value;
138 [Editor ("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
139 public string NavigateUrl {
141 object o = ViewState ["NavigateUrl"];
142 if (o != null) return (string) o;
146 ViewState ["NavigateUrl"] = value;
151 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
152 public string NavigateUrlField {
154 object o = ViewState ["NavigateUrlField"];
155 if (o != null) return (string) o;
159 ViewState ["NavigateUrlField"] = value;
163 [DefaultValue (false)]
164 public bool PopulateOnDemand {
166 object o = ViewState ["PopulateOnDemand"];
167 if (o != null) return (bool) o;
171 ViewState ["PopulateOnDemand"] = value;
175 [DefaultValue (TreeNodeSelectAction.Select)]
176 public TreeNodeSelectAction SelectAction {
178 object o = ViewState ["SelectAction"];
179 if (o != null) return (TreeNodeSelectAction)o;
180 return TreeNodeSelectAction.Select;
183 ViewState ["SelectAction"] = value;
187 [DefaultValue (false)]
188 public Nullable<bool> ShowCheckBox {
190 return (Nullable<bool>) ViewState ["ShowCheckBox"];
193 ViewState ["ShowCheckBox"] = value;
198 public string Target {
200 object o = ViewState ["Target"];
201 if(o != null) return (string)o;
205 ViewState ["Target"] = value;
210 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
211 public string TargetField {
213 object o = ViewState ["TargetField"];
214 if (o != null) return (string) o;
218 ViewState ["TargetField"] = value;
224 [WebSysDescription ("The display text of the tree node.")]
227 object o = ViewState ["Text"];
228 if(o != null) return (string)o;
232 ViewState ["Text"] = value;
237 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
238 public string TextField {
240 object o = ViewState ["TextField"];
241 if(o != null) return (string)o;
245 ViewState ["TextField"] = value;
251 public string ToolTip {
253 object o = ViewState ["ToolTip"];
254 if(o != null) return (string)o;
258 ViewState ["ToolTip"] = value;
263 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
264 public string ToolTipField {
266 object o = ViewState ["ToolTipField"];
267 if(o != null) return (string)o;
271 ViewState ["ToolTipField"] = value;
277 public string Value {
279 object o = ViewState ["Value"];
280 if(o != null) return (string)o;
284 ViewState ["Value"] = value;
288 internal bool HasPropertyValue (string propName)
290 return ViewState [propName] != null;
294 [TypeConverter ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
295 public string ValueField {
297 object o = ViewState ["ValueField"];
298 if(o != null) return (string)o;
302 ViewState ["ValueField"] = value;
306 void IStateManager.LoadViewState (object savedState)
308 ViewState.LoadViewState (savedState);
311 object IStateManager.SaveViewState ()
313 return ViewState.SaveViewState();
316 void IStateManager.TrackViewState ()
318 ViewState.TrackViewState ();
321 bool IStateManager.IsTrackingViewState {
322 get { return ViewState.IsTrackingViewState; }
325 [MonoTODO ("Not implemented")]
326 object IDataSourceViewSchemaAccessor.DataSourceViewSchema {
327 get { throw new NotImplementedException (); }
328 set { throw new NotImplementedException (); }
331 object ICloneable.Clone ()
333 TreeNodeBinding bin = new TreeNodeBinding ();
334 foreach (DictionaryEntry e in ViewState)
335 bin.ViewState [(string)e.Key] = e.Value;
339 internal void SetDirty ()
341 foreach (string key in ViewState.Keys)
342 ViewState.SetItemDirty (key, true);
345 public override string ToString () {
346 return DataMember.Length > 0 ? DataMember : "(Empty)";