Exemplo n.º 1
0
 void ExpandAll(GridItem gridItem)
 {
     foreach (GridItem g in gridItem.GridItems)
     {
         if (g.Label == "AsBytes")
         {
             continue;
         }
         if (g.GridItemType != GridItemType.Property)
         {
             continue;
         }
         if (g.Expandable && !g.Expanded)
         {
             PropertyDescriptor pd = g.PropertyDescriptor;
             if (pd.PropertyType == typeof(ArrayCTD))
             {
                 ArrayCTD ctd = g.Value as ArrayCTD;
                 if (ctd == null || ctd.Value == null || ctd.Value.Length > 64)
                 {
                     continue;
                 }
                 g.Expanded = true;
                 ExpandAll(g);
             }
             else
             {
                 g.Expanded = true;
                 ExpandAll(g);
             }
         }
     }
 }
Exemplo n.º 2
0
            public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
            {
                ArrayCTD ctd = value as ArrayCTD;
                Array    ary = ctd.owner[ctd.field].Value as Array;

                if (typeof(string).Equals(destinationType))
                {
                    return(ary == null ? "(null)" : "(Array: 0x" + ary.Length.ToString("X") + ")");
                }
                return(base.ConvertTo(context, culture, value, destinationType));
            }
Exemplo n.º 3
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                ArrayCTD            ctd   = value as ArrayCTD;
                AApiVersionedFields owner = new ArrayOwner(ctd.owner, ctd.field);
                Array  ary  = ctd.Value;
                Type   type = ary.GetType().GetElementType();
                string fmt  = type.Name + " [{0:X" + ary.Length.ToString("X").Length + "}]";

                AApiVersionedFieldsCTD.TypedValuePropertyDescriptor[] pds = new AApiVersionedFieldsCTD.TypedValuePropertyDescriptor[ary.Length];
                for (int i = 0; i < ary.Length; i++)
                {
                    try
                    {
                        pds[i] = new AApiVersionedFieldsCTD.TypedValuePropertyDescriptor(owner, String.Format(fmt, i), new Attribute[] { });
                    }
                    catch (Exception ex) { throw ex; }
                }
                return(new PropertyDescriptorCollection(pds));
            }