Ejemplo n.º 1
0
 public override object ConvertTo
     (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         if (value == null)
         {
             return(null);
         }
         if (value is IconInfo)
         {
             IconInfo icon = (IconInfo)value;
             if (context == null) // Requried to circumvent the Designer
             {
                 if (IconInfo.ShouldSerialize(icon))
                 {
                     StringBuilder serializedValue = new StringBuilder();
                     serializedValue.Append(icon.Url).Append("\0");
                     serializedValue.Append(icon.Width.ToString()).Append("\0");
                     serializedValue.Append(icon.Height.ToString()).Append("\0");
                     serializedValue.Append(icon.AlternateText).Append("\0");
                     serializedValue.Append(icon.ToolTip);
                     return(serializedValue.ToString());
                 }
                 else
                 {
                     return(string.Empty);
                 }
             }
             else
             {
                 return(icon.Url);
             }
         }
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Ejemplo n.º 2
0
 private bool ShouldSerializeIcon()
 {
     return(IconInfo.ShouldSerialize(_icon));
 }
Ejemplo n.º 3
0
 private bool ShouldSerializeDisabledIcon()
 {
     return(IconInfo.ShouldSerialize(_disabledIcon));
 }