Beispiel #1
0
        /// <summary>
        /// Returns -1 if obj is more than color, 0 if both colors are the same, and 1 if obj is less than color.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(object obj)
        {
            if (!(obj is TExcelColor))
            {
                return(-1);
            }
            TExcelColor Color2 = (TExcelColor)obj;

#if (COMPACTFRAMEWORK && !FRAMEWORK20)
            int Result = ((int)ColorType).CompareTo((int)Color2.ColorType);
#else
            int Result = ColorType.CompareTo(Color2.ColorType);
#endif
            if (Result != 0)
            {
                return(Result);
            }

            int TintCompare = Tint.CompareTo(Color2.Tint);
            if (TintCompare != 0 && Math.Abs(Tint - Color2.Tint) > 1e-6)
            {
                return(TintCompare);
            }

            switch (ColorType)
            {
            case TColorType.RGB:
                return(RGB.CompareTo(Color2.RGB));

            case TColorType.Automatic:
#if (COMPACTFRAMEWORK && !FRAMEWORK20)
                return(((int)FAutomaticType).CompareTo((int)Color2.FAutomaticType));
#else
                return(FAutomaticType.CompareTo(Color2.FAutomaticType));
#endif
            case TColorType.Theme:
#if (COMPACTFRAMEWORK && !FRAMEWORK20)
                return(((int)Theme).CompareTo((int)Color2.Theme));
#else
                return(Theme.CompareTo(Color2.Theme));
#endif
            case TColorType.Indexed:
                return(FIndex.CompareTo(Color2.FIndex));
            }

            return(0);
        }