2009-12-01 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.Design / System.Windows.Forms.Design / ControlBindingsConverter.cs
blobb5dbd6648ca1a40985cb04ccf59aa9cd93717602
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
22 // Authors:
23 // Peter Dennis Bartok (pbartok@novell.com)
24 // Ivan N. Zlatev (contact i-nz.net)
28 // NOT COMPLETE
29 using System.ComponentModel;
30 using System.Windows.Forms;
32 namespace System.Windows.Forms.Design
34 internal class ControlBindingsConverter : TypeConverter
36 public ControlBindingsConverter()
40 // TODO: Should create some sort of a special PropertyDescriptor and handle the data binding
42 [MonoTODO]
43 public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
44 object value, Attribute[] attributes)
46 PropertyDescriptorCollection properties = new PropertyDescriptorCollection (new PropertyDescriptor[0]);
47 ControlBindingsCollection collection = value as ControlBindingsCollection;
48 #if NET_2_0
49 object bindableComponent = collection.BindableComponent;
50 #else
51 object bindableComponent = collection.Control;
52 #endif
53 if (collection != null && bindableComponent != null) {
54 foreach (PropertyDescriptor property in
55 TypeDescriptor.GetProperties (bindableComponent, attributes)) {
56 if (((BindableAttribute) property.Attributes[typeof (BindableAttribute)]).Bindable)
57 properties.Add (new DataBindingPropertyDescriptor (property, attributes, true));
60 return properties;
63 public override bool GetPropertiesSupported (ITypeDescriptorContext context)
65 return true;
68 public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
70 if (destinationType == typeof (string))
71 return true;
72 return base.CanConvertTo (context, destinationType);
75 public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture,
76 object value, Type destinationType)
78 if (destinationType == typeof (string))
79 return String.Empty;
80 return base.ConvertTo (context, culture, value, destinationType);
84 [MonoTODO]
85 private class DataBindingPropertyDescriptor : PropertyDescriptor
87 bool _readOnly;
89 [MonoTODO]
90 public DataBindingPropertyDescriptor (PropertyDescriptor property, Attribute [] attrs, bool readOnly)
91 : base (property.Name, attrs)
93 _readOnly = readOnly;
96 [MonoTODO]
97 public override object GetValue (object component)
99 // throw new NotImplementedException ();
100 return null;
103 [MonoTODO]
104 public override void SetValue (object component, object value)
106 // throw new NotImplementedException ();
109 [MonoTODO]
110 public override void ResetValue (object component)
112 throw new NotImplementedException ();
115 [MonoTODO]
116 public override bool CanResetValue (object component)
118 // throw new NotImplementedException ();
119 return false;
122 public override bool ShouldSerializeValue (object component)
124 return false;
127 [MonoTODO]
128 public override Type PropertyType {
129 get {
130 // throw new NotImplementedException ();
131 return typeof (DataBindingPropertyDescriptor);
135 [MonoTODO]
136 public override TypeConverter Converter {
137 get {
138 // throw new NotImplementedException ();
139 return null;
143 public override Type ComponentType {
144 get { return typeof (ControlBindingsCollection); }
147 public override bool IsReadOnly {
148 get { return _readOnly; }