/// <summary>
 /// Overrides the method used to provide basic behaviour for selecting editor.
 /// Shows our custom control for editing the value.
 /// </summary>
 /// <param name="context">The context of the editing control</param>
 /// <param name="provider">A valid service provider</param>
 /// <param name="value">The current value of the object to edit</param>
 /// <returns>The new value of the object</returns>
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context == null || context.Instance == null || provider == null)
     {
         return base.EditValue(context, provider, value);
     }
     GXProperty target = value as GXProperty;
     GXDataIOSourceDialog dlg = new GXDataIOSourceDialog(target, context.Instance as GXTable);            
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         return dlg.Target;                
     }
     return value;
 }          
 /// <summary>
 /// Overrides the method used to provide basic behaviour for selecting editor.
 /// Shows our custom control for editing the value.
 /// </summary>
 /// <param name="context">The context of the editing control</param>
 /// <param name="provider">A valid service provider</param>
 /// <param name="value">The current value of the object to edit</param>
 /// <returns>The new value of the object</returns>
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context == null || context.Instance == null || provider == null)
     {
         return base.EditValue(context, provider, value);
     }                        
     GXDataIOSource source = value as GXDataIOSource;            
     GXDataIOSourceAttribute comp = System.ComponentModel.TypeDescriptor.GetAttributes(source.Parent)[typeof(GXDataIOSourceAttribute)] as GXDataIOSourceAttribute;
     GXDevice device = source.Parent.Site.GetService(typeof(GXDevice)) as GXDevice;            
     GXDataIOSourceDialog dlg;
     if (device == null)
     {
         GXDeviceList list = source.Parent.Site.GetService(typeof(GXDeviceList)) as GXDeviceList;
         dlg = new GXDataIOSourceDialog((GXDataIOSource)value, comp, list);
     }
     else
     {
         dlg = new GXDataIOSourceDialog((GXDataIOSource)value, comp, device);
     }            
     if (dlg.ShowDialog() == DialogResult.OK)
     {
         object oldTarget = source.Target;
         source.Target = dlg.Target;
         source.Action = dlg.TargetType;
         string name = "Target";
         if (source.Parent.Site != null)
         {
             System.ComponentModel.Design.IComponentChangeService ccsChanger = (System.ComponentModel.Design.IComponentChangeService)source.Parent.Site.GetService(typeof(System.ComponentModel.Design.IComponentChangeService));
             if (ccsChanger != null)
             {
                 MemberDescriptor md = TypeDescriptor.GetProperties(source).Find(name, true);
                 if (md == null)
                 {
                     System.Diagnostics.Debug.WriteLine(string.Format("GXSite NotifyChange failed. Propertys '{0}' name '{1}' is unknown", source.Parent.Site.Name, name));
                 }
                 ccsChanger.OnComponentChanging(source.Parent.Site.Component, md);
                 ccsChanger.OnComponentChanged(source.Parent.Site.Component, md, oldTarget, dlg.Target);
             }
         }
     }
     return value;
 }