public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         string[] strArray = ((string) value).Split(new char[] { ',' });
         LineStyle component = new LineStyle();
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(LineStyle));
         PropertyDescriptor descriptor = properties["Alignment"];
         descriptor.SetValue(component, descriptor.Converter.ConvertFromInvariantString(strArray[0].Trim()));
         descriptor = properties["Color"];
         descriptor.SetValue(component, descriptor.Converter.ConvertFromInvariantString(strArray[1].Trim()));
         descriptor = properties["DashStyle"];
         descriptor.SetValue(component, descriptor.Converter.ConvertFromInvariantString(strArray[2].Trim()));
         descriptor = properties["Width"];
         descriptor.SetValue(component, descriptor.Converter.ConvertFromInvariantString(strArray[3].Trim()));
         return component;
     }
     return base.ConvertFrom(context, culture, value);
 }
Example #2
0
 private Pen getPenAttribute(XmlNode source)
 {
     Pen pen = new Pen(Color.Black) {
         Alignment = PenAlignment.Center
     };
     string text = XmlFunc.getStringAttribute(source, "LineStyle");
     if (text.Length > 0)
     {
         LineStyle component = new LineStyle();
         component = (LineStyle) TypeDescriptor.GetConverter(component).ConvertFromInvariantString(text);
         pen.Alignment = component.Alignment;
         pen.Color = component.Color;
         pen.DashStyle = component.DashStyle;
         pen.Width = component.Width;
     }
     return pen;
 }