Exemple #1
0
        public override Object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture,
                                         Object value,
                                         Type destinationType)
        {
            if (destinationType.Equals(Type.GetType("System.String")) &&
                value.GetType().Equals(Type.GetType("DMS.DMS_Graphics.CFillOptions")))
            {
                CFillOptions FillOptions = (CFillOptions)(value);
                String       Desstr      = "填充类型:";
                switch (FillOptions.BrushType)
                {
                case LCBrushType.Blank: Desstr += "空心"; break;

                case LCBrushType.Solid: Desstr += "实填充"; break;

                case LCBrushType.Hatch: Desstr += "网格填充"; break;

                case LCBrushType.LinearGradient: Desstr += "渐变填充"; break;

                case LCBrushType.Texture: Desstr += "图案填充"; break;

                default: Desstr += "未知"; break;
                }
                //Desstr += ";填充色:" + FillOptions.BackColor.ToString();
                return(Desstr);
            }
            ExpandableObjectConverter sEx = new ExpandableObjectConverter();

            return(sEx.ConvertTo(context, culture, value, destinationType));
        }
Exemple #2
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo&lt;int&gt;(context, culture, value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this ExpandableObjectConverter typeconverter, ITypeDescriptorContext context, System.Globalization.CultureInfo culture, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(context, culture, value, typeof(T)));
        }
Exemple #3
0
        /// <summary>
        /// Extends ConvertTo so that methods that return a specific type object given a Type parameter can be
        /// used as generic method and casting is not required.
        /// <example>
        /// typeconverter.ConvertTo&lt;int&gt;(value);
        /// </example>
        /// </summary>
        public static T ConvertTo <T>(this ExpandableObjectConverter typeconverter, Object value)
        {
            if (typeconverter == null)
            {
                throw new ArgumentNullException("typeconverter");
            }

            return((T)typeconverter.ConvertTo(value, typeof(T)));
        }