Example #1
0
 /// <summary>
 /// Initializes a new instance of the CellStyle class with default settings
 /// </summary>
 public CellStyle()
 {
     this.backColor = Color.Empty;
     this.foreColor = Color.Empty;
     this.font      = null;
     this.padding   = CellPadding.Empty;
     this.wordWrap  = false;
 }
Example #2
0
        /// <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 CellPadding))
            {
                CellPadding p = (CellPadding)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 CellPadding))
            {
                CellPadding p = (CellPadding)value;

                Type[] t = new Type[4];
                t[0] = t[1] = t[2] = t[3] = typeof(int);

                ConstructorInfo info = typeof(CellPadding).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));
        }
Example #3
0
        /// <summary>
        /// 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 CellPadding))
            {
                return(false);
            }

            CellPadding padding = (CellPadding)obj;

            if (((padding.Left == this.Left) && (padding.Top == this.Top)) && (padding.Right == this.Right))
            {
                return(padding.Bottom == this.Bottom);
            }

            return(false);
        }