/// <summary> /// 空构造,背景色、前景色、字体、边距 都为空 /// Initializes a new instance of the CellStyle class with default settings /// </summary> public I3CellStyle() { this.backColor = Color.Empty; this.foreColor = Color.Empty; this.font = null; this.padding = I3CellPadding.Empty; }
/// <summary> /// Converts the given value object to the specified type, using /// the specified context and culture information /// </summary> /// <param name="context">An ITypeDescriptorContext that provides /// a format context</param> /// <param name="culture">A CultureInfo object. If a null reference /// is passed, the current culture is assumed</param> /// <param name="value">The Object to convert</param> /// <param name="destinationType">The Type to convert the value /// parameter to</param> /// <returns>An Object that represents the converted value</returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if ((destinationType == typeof(string)) && (value is I3CellPadding)) { I3CellPadding p = (I3CellPadding)value; if (culture == null) { culture = CultureInfo.CurrentCulture; } string separator = culture.TextInfo.ListSeparator + " "; TypeConverter converter = TypeDescriptor.GetConverter(typeof(int)); string[] s = new string[4]; s[0] = converter.ConvertToString(context, culture, p.Left); s[1] = converter.ConvertToString(context, culture, p.Top); s[2] = converter.ConvertToString(context, culture, p.Right); s[3] = converter.ConvertToString(context, culture, p.Bottom); return(string.Join(separator, s)); } if ((destinationType == typeof(InstanceDescriptor)) && (value is I3CellPadding)) { I3CellPadding p = (I3CellPadding)value; Type[] t = new Type[4]; t[0] = t[1] = t[2] = t[3] = typeof(int); ConstructorInfo info = typeof(I3CellPadding).GetConstructor(t); if (info != null) { object[] o = new object[4]; o[0] = p.Left; o[1] = p.Top; o[2] = p.Right; o[3] = p.Bottom; return(new InstanceDescriptor(info, o)); } } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// 判断是否与另一个CellPadding的值相等 /// Tests whether obj is a CellPadding structure with the same values as /// this Padding structure /// </summary> /// <param name="obj">The Object to test</param> /// <returns>This method returns true if obj is a CellPadding structure /// and its Left, Top, Right, and Bottom properties are equal to /// the corresponding properties of this CellPadding structure; /// otherwise, false</returns> public override bool Equals(object obj) { if (!(obj is I3CellPadding)) { return(false); } I3CellPadding padding = (I3CellPadding)obj; if (((padding.Left == this.Left) && (padding.Top == this.Top)) && (padding.Right == this.Right)) { return(padding.Bottom == this.Bottom); } return(false); }