コード例 #1
0
ファイル: DesignTextStyle.cs プロジェクト: vahmax/Samples14
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            {
                if (destinationType == typeof(string))
                {
                    if (!(value is DesignTextStyle))
                    {
                        return(string.Empty);
                    }

                    DesignTextStyle textStyle = (DesignTextStyle)value;
                    if (textStyle.IsNullable)
                    {
                        return(string.Empty);
                    }

                    if (culture == null)
                    {
                        culture = CultureInfo.CurrentUICulture;
                    }

                    StringExpressionInfoConverter stringConverter = new StringExpressionInfoConverter();
                    ColorExpressionInfoConverter  colorConverter  = new ColorExpressionInfoConverter();
                    LengthExpressionInfoConverter lengthConverter = new LengthExpressionInfoConverter();
                    EnumExpressionInfoConverter   enumConverter   = new EnumExpressionInfoConverter();
                    string separator = culture.TextInfo.ListSeparator + " ";

                    StringBuilder sb = new StringBuilder();
                    sb.Append(stringConverter.ConvertTo(context, culture, textStyle.Family, destinationType));
                    sb.Append(separator);
                    sb.Append(lengthConverter.ConvertTo(context, culture, textStyle.Size, destinationType));
                    sb.Append(separator);
                    sb.Append(enumConverter.ConvertTo(context, culture, textStyle.Style, destinationType));
                    sb.Append(separator);
                    sb.Append(enumConverter.ConvertTo(context, culture, textStyle.Weight, destinationType));
                    sb.Append(separator);
                    sb.Append(enumConverter.ConvertTo(context, culture, textStyle.Decoration, destinationType));
                    sb.Append(separator);
                    sb.Append(colorConverter.ConvertTo(context, culture, textStyle.Color, destinationType));

                    return(sb.ToString());
                }
                return(base.ConvertTo(context, culture, value, destinationType));
            }
コード例 #2
0
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            {
                if (destinationType == typeof(string))
                {
                    if (!(value is DesignLineStyle))
                    {
                        return(string.Empty);
                    }

                    DesignLineStyle lineStyle = (DesignLineStyle)value;
                    if (lineStyle.IsNullable)
                    {
                        return(string.Empty);
                    }

                    if (culture == null)
                    {
                        culture = CultureInfo.CurrentUICulture;
                    }

                    ColorExpressionInfoConverter  colorStyleConverter  = new ColorExpressionInfoConverter();
                    LengthExpressionInfoConverter widthStyleConverter  = new LengthExpressionInfoConverter();
                    EnumExpressionInfoConverter   borderStyleConverter = new EnumExpressionInfoConverter();
                    string separator = culture.TextInfo.ListSeparator + " ";

                    StringBuilder sb = new StringBuilder();
                    sb.Append(colorStyleConverter.ConvertTo(context, culture, lineStyle.LineColor, destinationType));
                    sb.Append(separator);
                    sb.Append(widthStyleConverter.ConvertTo(context, culture, lineStyle.LineWidth, destinationType));
                    sb.Append(separator);
                    sb.Append(borderStyleConverter.ConvertTo(context, culture, lineStyle.LineStyle, destinationType));

                    return(sb.ToString());
                }
                return(base.ConvertTo(context, culture, value, destinationType));
            }