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:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
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) 2005 Novell, Inc.
23 // Jackson Harper jackson@ximian.com
26 using System.Collections;
27 using System.ComponentModel;
29 namespace System.Windows.Forms {
31 public class PropertyManager : BindingManagerBase {
33 private object data_source;
34 private string property_name;
35 private PropertyDescriptor prop_desc;
36 private bool binding_suspended;
38 public PropertyManager() {
41 internal PropertyManager (object data_source, string property_name)
43 this.data_source = data_source;
44 this.property_name = property_name;
46 prop_desc = TypeDescriptor.GetProperties (data_source).Find (property_name, true);
48 if (prop_desc == null)
51 prop_desc.AddValueChanged (data_source, new EventHandler (PropertyChangedHandler));
54 public override object Current {
55 get { return data_source; }
58 public override int Position {
60 set { /* Doesn't do anything on MS" */ }
63 public override int Count {
67 public override void AddNew ()
69 throw new NotSupportedException ("AddNew is not supported for property to property binding");
72 public override void CancelCurrentEdit ()
74 IEditableObject editable = data_source as IEditableObject;
77 editable.CancelEdit ();
82 public override void EndCurrentEdit ()
86 IEditableObject editable = data_source as IEditableObject;
92 public override PropertyDescriptorCollection GetItemProperties ()
94 return TypeDescriptor.GetProperties (data_source);
97 public override void RemoveAt (int idx)
99 throw new NotSupportedException ("RemoveAt is not supported for property to property binding");
102 public override void ResumeBinding ()
104 binding_suspended = false;
107 public override void SuspendBinding ()
109 binding_suspended = true;
112 internal override bool IsSuspended {
113 get { return binding_suspended; }
116 protected internal override string GetListName (ArrayList list)
122 protected override void UpdateIsBinding ()
126 protected internal override void OnCurrentChanged (EventArgs e)
130 if (onCurrentChangedHandler != null) {
131 onCurrentChangedHandler (this, e);
135 private void PropertyChangedHandler (object sender, EventArgs e)
137 OnCurrentChanged (EventArgs.Empty);