Exemplo n.º 1
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));
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the value of this class as a system color.
        /// </summary>
        /// <param name="xls">Excel file containing the themes and palettes for the color indexes.</param>
        /// <param name="automaticColor">Color to be returned if this structure has an automatic color.</param>
        /// <returns></returns>
        public Color ToColor(IFlexCelPalette xls, Color automaticColor)
        {
            if (automaticColor != ColorUtil.Empty && IsAutomatic)
            {
                return(ApplyTint(automaticColor));
            }

            if (xls == null)
            {
                xls = TDummyFlexCelPalette.Instance;
            }
            Color Result = automaticColor;

            switch (ColorType)
            {
            case TColorType.RGB:
                unchecked
                {
                    Result = ColorUtil.FromArgb((int)((uint)(0xFF000000 | FRGB)));
                }
                break;

            case TColorType.Automatic:
                Result = GetAutomaticRGB();
                break;

            case TColorType.Theme:
                Result = xls.GetColorTheme(FTheme).ToColor(xls);
                break;

            case TColorType.Indexed:
                Result = xls.GetColorPalette(Index);
                break;
            }

            return(ApplyTint(Result));
        }