private int GetAutomaticColorIndex(TAutomaticColor autoType) { if (FAutomaticType != TAutomaticColor.None) { autoType = FAutomaticType; //if we have something stored here, we will use that better. } switch (autoType) { case TAutomaticColor.DefaultForeground: return(0x040); case TAutomaticColor.DefaultBackground: return(0x041); case TAutomaticColor.DefaultChartForeground: return(0x04d); case TAutomaticColor.DefaultChartBackground: return(0x04e); case TAutomaticColor.ChartNeutralColor: return(0x04f); case TAutomaticColor.TooltipTextColor: return(0x051); case TAutomaticColor.SheetTab: return(0x07F); default: return(0x7FFF); } }
internal int GetBiff8ColorIndex(IFlexCelPalette xls, TAutomaticColor autoType) { if (xls == null) { xls = TDummyFlexCelPalette.Instance; } switch (ColorType) { case TColorType.RGB: unchecked { Color cRGB = ColorUtil.FromArgb((int)((uint)(0xFF000000 | FRGB))); return(xls.NearestColorIndex(ApplyTint(cRGB)) - 1 + 8); // nearestcolorindex returns 1-based } case TColorType.Automatic: return(GetAutomaticColorIndex(autoType)); case TColorType.Theme: return(xls.NearestColorIndex(ApplyTint(xls.GetColorTheme(FTheme).ToColor(xls))) - 1 + 8); case TColorType.Indexed: return(FIndex - 1 + 8); //findex is 1-based too. } return(1); }
private TExcelColor(TColorType aColorType, TAutomaticColor aAutomatic, long aRGB, TThemeColor aTheme, int aIndex, double aTint, bool AllowBiff8Indexed) { FColorType = aColorType; FTint = aTint < -1 ? -1 : aTint > 1 ? 1 : aTint; //if (aColorType == TColorType.Automatic && (!Enum.IsDefined(typeof(TAutomaticColor), aAutomatic) || aAutomatic == TAutomaticColor.None)) // FlxMessages.ThrowException(FlxErr.ErrInvalidColorEnum, "Automatic"); FAutomaticType = aAutomatic; FRGB = aRGB & 0xFFFFFFFF; if (aColorType == TColorType.Theme && (!Enum.IsDefined(typeof(TThemeColor), aTheme) || aTheme == TThemeColor.None)) { FlxMessages.ThrowException(FlxErr.ErrInvalidColorEnum, "Theme"); } FTheme = aTheme; if (!AllowBiff8Indexed && aColorType == TColorType.Indexed && (aIndex < 1 || aIndex > 56)) { FColorType = TColorType.Automatic; FAutomaticType = TAutomaticColor.None; //we won't raise an exception here, to avoid issues with old code. FIndex = -9; return; } FIndex = aIndex; }
internal int GetBiff8ColorIndex(IFlexCelPalette xls, TAutomaticColor autoType, ref TColorIndexCache IndexCache) { if (xls == null) { xls = TDummyFlexCelPalette.Instance; } if (IndexCache.ColorIsValid(this, xls)) { return(IndexCache.Index - 1 + 8); } int ColorIndex = GetBiff8ColorIndex(xls, autoType); IndexCache.LastColorStored = this; IndexCache.LastColorInPalette = ToColor(xls).ToArgb(); IndexCache.Index = ColorIndex + 1 - 8; //IndexCache is the same base as index. if (ColorType == TColorType.Theme) { IndexCache.LastColorInTheme = xls.GetColorTheme(Theme); } return(ColorIndex); }
private static TExcelColor FromAutomatic(TAutomaticColor AutColor) { return(new TExcelColor(TColorType.Automatic, AutColor, -1, TThemeColor.None, -9, 0)); }
private TExcelColor(TColorType aColorType, TAutomaticColor aAutomatic, long aRGB, TThemeColor aTheme, int aIndex, double aTint) : this(aColorType, aAutomatic, aRGB, aTheme, aIndex, aTint, false) { }