public override object EditValue(
     System.ComponentModel.ITypeDescriptorContext context,
     IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         IWindowsFormsEditorService edSvc
             = (IWindowsFormsEditorService)provider.GetService(
                 typeof(IWindowsFormsEditorService));
         if (edSvc == null)
         {
             return value;
         }
         SelectResourceDialog srd
             = new SelectResourceDialog(this.mMgr);
         if (edSvc.ShowDialog(srd) !=
             System.Windows.Forms.DialogResult.OK)
         {
             return value;
         }
         ResourceMgr.ResEntry res = srd.SelectedResource;
         if (res == null)
         {
             return value;
         }
         Type t = value.GetType();
         RK key = new RK(this.mTID, res.GID, res.IID);
         if (t.Equals(typeof(RK)))
         {
             return key;
         }
         if (t.IsInterface &&
             typeof(IResourceKey).IsAssignableFrom(t))
         {
             return key;
         }
         if (t.Equals(typeof(string)))
         {
             return key.ToString();
         }
     }
     return value;
 }
Beispiel #2
0
 public override object EditValue(
     System.ComponentModel.ITypeDescriptorContext context,
     IServiceProvider provider, object value)
 {
     if (provider != null)
     {
         IWindowsFormsEditorService edSvc
             = (IWindowsFormsEditorService)provider.GetService(
                   typeof(IWindowsFormsEditorService));
         if (edSvc == null)
         {
             return(value);
         }
         SelectResourceDialog srd
             = new SelectResourceDialog(this.mMgr);
         if (edSvc.ShowDialog(srd) !=
             System.Windows.Forms.DialogResult.OK)
         {
             return(value);
         }
         ResourceMgr.ResEntry res = srd.SelectedResource;
         if (res == null)
         {
             return(value);
         }
         Type t   = value.GetType();
         RK   key = new RK(this.mTID, res.GID, res.IID);
         if (t.Equals(typeof(RK)))
         {
             return(key);
         }
         if (t.IsInterface &&
             typeof(IResourceKey).IsAssignableFrom(t))
         {
             return(key);
         }
         if (t.Equals(typeof(string)))
         {
             return(key.ToString());
         }
     }
     return(value);
 }