Exemplo n.º 1
0
        /// <summary>
        /// 将类型转换成字符串
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns></returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string) && value != null)
            {
                CPoint point = value as CPoint;
                string str   = string.Format($"{point.X},{point.Y}");
                return(str);
            }

            if (destinationType == typeof(InstanceDescriptor) && value != null)
            {
                ConstructorInfo constructorInfo = typeof(CPoint).GetConstructor(new Type[] { typeof(int), typeof(int) });
                CPoint          point           = value as CPoint;
                return(new InstanceDescriptor(constructorInfo, new object[] { point.X, point.Y }));
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Exemplo n.º 2
0
 public LineSegmentBase(CPoint _startPoint, CPoint _endPoint)
 {
     startPoint = _startPoint;
     endPoint   = _endPoint;
 }
Exemplo n.º 3
0
 public LineSegment(CPoint _startPoint, CPoint _endPoint) : base(_startPoint, _endPoint)
 {
 }