Exemplo n.º 1
0
 public ImageCircleRevolver()
 {
     Circles         = new List <ImageCircle>();
     CircleParameter = new ImageCircleParameter()
     {
         Alpha               = 0.0F,
         MaxCircleCapacity   = 10,
         MaxCapacityInCircle = 360,
         Radius              = new Point(480, 120),
         MaxImageLength      = 120,
         DestinationSize     = new Size(80, 120),
     };
 }
        /// <summary>
        /// Converts a specified value (which must be a <see cref="ImageCircleParameter"/>) into a given
        /// type un the specified context.
        /// </summary>
        /// <param name="context">The formatting context.</param>
        /// <param name="info">The culture under which the conversion should be performed.</param>
        /// <param name="value">Value to convert.</param>
        /// <param name="destType">The type the conversion should result into.</param>
        /// <returns>The converted value.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo info, object value, Type destType)
        {
            ImageCircleParameter para = (ImageCircleParameter)value;

            if (destType == typeof(InstanceDescriptor))
            {
                Type[] ctorTypes = new Type[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(float),
                                                typeof(Color), typeof(Point), typeof(Point) };
                object[] ctorParams = new object[] { para.MaxCircleCapacity, para.MaxCapacityInCircle, para.CircleVerInterval, para.MaxImageLength,
                                                     para.Alpha, para.BackgroundColor, para.OrginalCenter, para.Radius };
                return(new InstanceDescriptor(typeof(ImageCircleParameter).GetConstructor(ctorTypes), ctorParams, true));
            }

            return(base.ConvertTo(context, info, value, destType));
        }