public IColor AddColor(string color) { if (m_colorLookup.ContainsKey(color)) { return(m_colorLookup[color]); } Color color2 = LayoutConvert.ToColor(color); BIFF8Color bIFF8Color = null; for (int i = 0; i < m_colors.Count; i++) { if (m_colors[i].Equals(color2)) { bIFF8Color = m_colors[i]; } } if (bIFF8Color == null) { if (m_colors.Count >= 56) { return(m_colors[0]); } bIFF8Color = new BIFF8Color(color2, m_colors.Count + 8); m_colors.Add(bIFF8Color); } m_colorLookup[color] = bIFF8Color; return(bIFF8Color); }
public IColor AddColor(string colorString) { System.Drawing.Color color = LayoutConvert.ToColor(colorString); if (this._nextPaletteIndex < 56) { int colorIndex = this._workbook.Palette.GetColorIndex(color.R, color.G, color.B); if (colorIndex == -1) { this._workbook.Palette.SetColorAt(this._nextPaletteIndex, color.R, color.G, color.B); this._nextPaletteIndex++; } else if (colorIndex >= this._nextPaletteIndex) { if (colorIndex == this._nextPaletteIndex) { this._nextPaletteIndex++; } else { Color colorAt = this._workbook.Palette.GetColorAt(colorIndex); Color colorAt2 = this._workbook.Palette.GetColorAt(this._nextPaletteIndex); this._workbook.Palette.SetColorAt(colorIndex, colorAt2.Red, colorAt2.Green, colorAt2.Blue); this._workbook.Palette.SetColorAt(this._nextPaletteIndex, colorAt.Red, colorAt.Green, colorAt.Blue); this._nextPaletteIndex++; } } } return(this._workbook.Palette.GetColor(color)); }