private void UpdateCellState(Cell cell, IntPtr hdc) { foreach (var kvp in CellStateDeterminationList) { Color color; var cacheKey = kvp.Key.XPointGetter(cell.Col) * 100 + kvp.Key.YPointGetter(cell.Row); if (!_colorsCache.TryGetValue(cacheKey, out color)) { color = WinApiHelper.GetColor(hdc, kvp.Key.XPointGetter(cell.Col), kvp.Key.YPointGetter(cell.Row)); _colorsCache[cacheKey] = color; } if (color != kvp.Key.Color) { continue; } cell.UpdateState(kvp.Value); break; } }