Fixed Issue 387. The new implementation does not try to start a ring 0 driver that already exists, but could not be opened. It tries to delete the driver and install it new. The driver is now stored temporarily in the application folder. The driver is not correctly removed on system shutdown.
2 using System.Collections.Generic;
4 using System.Reflection;
5 using System.ComponentModel;
7 namespace Aga.Controls.Tree.NodeControls
9 public abstract class BindableControl : NodeControl
11 private struct MemberAdapter
14 private PropertyInfo _pi;
15 private FieldInfo _fi;
17 public static readonly MemberAdapter Empty = new MemberAdapter();
19 public Type MemberType
24 return _pi.PropertyType;
36 if (_pi != null && _pi.CanRead)
37 return _pi.GetValue(_obj, null);
39 return _fi.GetValue(_obj);
45 if (_pi != null && _pi.CanWrite)
46 _pi.SetValue(_obj, value, null);
48 _fi.SetValue(_obj, value);
52 public MemberAdapter(object obj, PropertyInfo pi)
59 public MemberAdapter(object obj, FieldInfo fi)
69 private bool _virtualMode = false;
70 [DefaultValue(false), Category("Data")]
71 public bool VirtualMode
73 get { return _virtualMode; }
74 set { _virtualMode = value; }
77 private string _propertyName = "";
78 [DefaultValue(""), Category("Data")]
79 public string DataPropertyName
81 get { return _propertyName; }
84 if (_propertyName == null)
85 _propertyName = string.Empty;
86 _propertyName = value;
90 private bool _incrementalSearchEnabled = false;
92 public bool IncrementalSearchEnabled
94 get { return _incrementalSearchEnabled; }
95 set { _incrementalSearchEnabled = value; }
100 public virtual object GetValue(TreeNodeAdv node)
104 NodeControlValueEventArgs args = new NodeControlValueEventArgs(node);
112 return GetMemberAdapter(node).Value;
114 catch (TargetInvocationException ex)
116 if (ex.InnerException != null)
117 throw new ArgumentException(ex.InnerException.Message, ex.InnerException);
119 throw new ArgumentException(ex.Message);
124 public virtual void SetValue(TreeNodeAdv node, object value)
128 NodeControlValueEventArgs args = new NodeControlValueEventArgs(node);
136 MemberAdapter ma = GetMemberAdapter(node);
139 catch (TargetInvocationException ex)
141 if (ex.InnerException != null)
142 throw new ArgumentException(ex.InnerException.Message, ex.InnerException);
144 throw new ArgumentException(ex.Message);
149 public Type GetPropertyType(TreeNodeAdv node)
151 return GetMemberAdapter(node).MemberType;
154 private MemberAdapter GetMemberAdapter(TreeNodeAdv node)
156 if (node.Tag != null && !string.IsNullOrEmpty(DataPropertyName))
158 Type type = node.Tag.GetType();
159 PropertyInfo pi = type.GetProperty(DataPropertyName);
161 return new MemberAdapter(node.Tag, pi);
164 FieldInfo fi = type.GetField(DataPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
166 return new MemberAdapter(node.Tag, fi);
169 return MemberAdapter.Empty;
172 public override string ToString()
174 if (string.IsNullOrEmpty(DataPropertyName))
175 return GetType().Name;
177 return string.Format("{0} ({1})", GetType().Name, DataPropertyName);
180 public event EventHandler<NodeControlValueEventArgs> ValueNeeded;
181 private void OnValueNeeded(NodeControlValueEventArgs args)
183 if (ValueNeeded != null)
184 ValueNeeded(this, args);
187 public event EventHandler<NodeControlValueEventArgs> ValuePushed;
188 private void OnValuePushed(NodeControlValueEventArgs args)
190 if (ValuePushed != null)
191 ValuePushed(this, args);