Ejemplo n.º 1
0
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         try
         {
             string s     = (string)value;
             int    colon = s.IndexOf(':');
             int    comma = s.IndexOf("cm,");
             if (colon != -1 && comma != -1)
             {
                 string top = s.Substring(colon + 1, (comma - colon - 1));
                 colon = s.IndexOf(':', comma + 1);
                 comma = s.IndexOf("cm,", comma + 1);
                 string bottom = s.Substring(colon + 1, (comma - colon - 1));
                 colon = s.IndexOf(':', comma + 1);
                 comma = s.IndexOf("cm,", comma + 1);
                 string left = s.Substring(colon + 1, (comma - colon - 1));
                 colon = s.IndexOf(':', comma + 1);
                 comma = s.IndexOf("cm", comma + 1);
                 string  right = s.Substring(colon + 1, (comma - colon - 1));
                 Margins so    = new Margins();
                 so.Top    = float.Parse(top);
                 so.Bottom = float.Parse(bottom);
                 so.Left   = float.Parse(left);
                 so.Right  = float.Parse(right);
                 return(so);
             }
         }
         catch
         {
             throw new ArgumentException("Can not convert\"" + (string)value + "\"to type Margins");
         }
     }
     return(base.ConvertFrom(context, culture, value));
 }
Ejemplo n.º 2
0
        public object Clone()
        {
            Margins copy = new Margins(this.Left, this.Right, this.Top, this.Bottom);

            return(copy);
        }