コード例 #1
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((context != null) && (provider != null))
     {
         // Access the Property Browser's UI display service
         IWindowsFormsEditorService editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (editorService != null)
         {
             // Create an instance of the UI editor control
             IPeditorForm ipe = new IPeditorForm();
             // Pass the UI editor control the current property value
             Ras.RASIPADDR i = (Ras.RASIPADDR)value;
             ipe.A = i.a;
             ipe.B = i.b;
             ipe.C = i.c;
             ipe.D = i.d;
             // Display the UI editor control
             if (editorService.ShowDialog(ipe) == DialogResult.OK)
             {
                 i.a = ipe.A;
                 i.b = ipe.B;
                 i.c = ipe.C;
                 i.d = ipe.D;
                 return(i);
             }
         }
     }
     return(base.EditValue(context, provider, value));
 }
コード例 #2
0
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (value is Ras.RASIPADDR && (destinationType == typeof(string)))
     {
         Ras.RASIPADDR i = (Ras.RASIPADDR)value;
         return(string.Format("{0}.{1}.{2}.{3}", i.a.ToString(), i.b.ToString(), i.c.ToString(), i.d.ToString()));
     }
     else if (value is Ras.RASIPADDR && (destinationType == typeof(InstanceDescriptor)))
     {
         Ras.RASIPADDR i      = (Ras.RASIPADDR)value;
         byte[]        values = new byte[4];
         Type[]        types  = new Type[4];
         types[0]  = types[1] = types[2] = types[3] = typeof(byte);
         values[0] = i.a; values[1] = i.b; values[2] = i.c; values[3] = i.d;
         ConstructorInfo ci = typeof(Ras.RASIPADDR).GetConstructor(types);
         return(new InstanceDescriptor(ci, values));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }