コード例 #1
0
        /// <summary>
        /// Compares this object to another <see cref="DesignLineStyle"/>.
        /// </summary>
        public int CompareTo(DesignLineStyle other)
        {
            int delta = this.LineColor == null ? -1 : this.LineColor.CompareTo(other.LineColor);

            if (delta == 0)
            {
                delta = this.LineWidth == null ? -1 : this.LineWidth.CompareTo(other.LineWidth);
            }
            if (delta == 0)
            {
                delta = this.LineStyle == null ? -1 : this.LineStyle.CompareTo(other.LineStyle);
            }
            return(delta);
        }
コード例 #2
0
            public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
            {
                DesignLineStyle lineStyle = (DesignLineStyle)value;
                const int       N         = 3;

                PropertyDescriptor[] properties = new PropertyDescriptor[N];
                properties[0] = new ShadowProperty(LineColorDisplayName,
                                                   TypeDescriptor.CreateProperty(
                                                       typeof(DesignLineStyle),
                                                       LineColorPropertyName,
                                                       typeof(ExpressionInfo),
                                                       new TypeConverterAttribute(lineStyle.IsNullable
                                                ? typeof(NullableColorExpressionInfoConverter)
                                                : typeof(ColorExpressionInfoConverter))
                                                       ));
                properties[1] = new ShadowProperty(LineWidthDisplayName,
                                                   TypeDescriptor.CreateProperty(
                                                       typeof(DesignLineStyle),
                                                       LineWidthPropertyName,
                                                       typeof(ExpressionInfo),
                                                       new TypeConverterAttribute(lineStyle.IsNullable
                                                ? typeof(NullableLengthExpressionInfoConverter)
                                                : typeof(LengthExpressionInfoConverter))
                                                       ));
                properties[2] = new ShadowProperty(LineStyleDisplayName,
                                                   TypeDescriptor.CreateProperty(
                                                       typeof(DesignLineStyle),
                                                       LineStylePropertyName,
                                                       typeof(ExpressionInfo),
                                                       new TypeConverterAttribute(lineStyle.IsNullable
                                                ? typeof(NullableEnumExpressionInfoConverter)
                                                : typeof(EnumExpressionInfoConverter))
                                                       ));

                PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(properties);

                return(pdc.Sort(PropertySortOrder));
            }
コード例 #3
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));
            }