Example #1
0
        internal int           Index; //stores at 1 the first entry, that is biff8 entry 8.

        internal bool ColorIsValid(TExcelColor aColor, IFlexCelPalette xls)
        {
            int RealIndex = Index < 1 ? Index + 8 : Index;

            if (RealIndex <= 0 || RealIndex > 56)
            {
                return(false);
            }
            if (LastColorStored != aColor)
            {
                return(false);
            }
            Color c = xls.GetColorPalette(RealIndex);

            //If the color is Theme, it could have changed if the theme palette changed.
            if (aColor.ColorType == TColorType.Theme)
            {
                if (xls.GetColorTheme(aColor.Theme) != LastColorInTheme)
                {
                    return(false);
                }
            }

            return(c.ToArgb() == LastColorInPalette);
        }
Example #2
0
        /// <summary>
        /// Creates a new Gradient stop.
        /// </summary>
        /// <param name="aPosition">Position for the stop.</param>
        /// <param name="aColor">Color for the stop.</param>
        public TGradientStop(double aPosition, TExcelColor aColor)
        {
            FPosition = 0;
            FColor    = aColor;   // to compile

            Position = aPosition; //to set the real values
            Color    = aColor;
        }
Example #3
0
 internal static TExcelColor Copy(TExcelColor aColor, IFlexCelPalette Source, IFlexCelPalette Dest)
 {
     if (aColor.ColorType != TColorType.Indexed)
     {
         return(aColor);                                        //Themed colors are not converted when copying. Color Acc1 in source will be Color Acc2 in Dest, no matter if Acc and Dest are different.
     }
     if (Source.GetColorPalette(aColor.Index).ToArgb() == Dest.GetColorPalette(aColor.Index).ToArgb())
     {
         return(aColor);                                                                                              //Most common case, palettes are the same.
     }
     return(Source.GetColorPalette(aColor.Index));
 }
Example #4
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);
        }
Example #5
0
        internal static TExcelColor FromBiff8(byte[] Data, int CTypePos, int TintPos, int DataPos, bool TintIsInt)
        {
            int    ct = BitConverter.ToUInt16(Data, CTypePos);
            double Tint;

            if (TintIsInt)
            {
                int nTint = BitConverter.ToInt16(Data, TintPos);
                Tint = nTint / (double)Int16.MaxValue;
            }
            else
            {
                Tint = BitConverter.ToDouble(Data, TintPos);
            }

            if (Tint < -1)
            {
                Tint = -1;            // Just in case nTint was Int16.MinValue. Int16.MinValue < -Int16.MaxValue
            }
            switch (ct)
            {
            case 0:     //Automatic
                return(TExcelColor.Automatic);

            case 1:     //Indexed
                return(TExcelColor.FromBiff8ColorIndex(BitConverter.ToUInt32(Data, DataPos)));

            case 2:     // RGB
                unchecked
                {
                    UInt32 BGR = BitConverter.ToUInt32(Data, DataPos);
                    return(TExcelColor.FromArgb((byte)(BGR), (byte)(BGR >> 8), (byte)(BGR >> 16), Tint));
                }

            case 3:     //Theme
                return(TExcelColor.FromTheme((TThemeColor)(BitConverter.ToUInt32(Data, DataPos)), Tint));
            }

            return(TExcelColor.Automatic);
        }
Example #6
0
 public bool PaletteContainsColor(TExcelColor value)
 {
     return(false);
 }