private Swatch GetMaxScoredSwatchForTarget(Target target) { float maxScore = 0; Swatch maxScoreSwatch = null; for (int i = 0, count = _swatches.Count; i < count; i++) { Swatch swatch = _swatches.ElementAt(i); if (ShouldBeScoredForTarget(swatch, target)) { float score = GenerateScore(swatch, target); if (maxScoreSwatch == null || score > maxScore) { maxScoreSwatch = swatch; maxScore = score; } } } return(maxScoreSwatch); }
/** * Returns the selected color for the given target from the palette as an RGB packed int. * * @param defaultColor value to return if the swatch isn't available */ private Color GetColorForTarget(Target target, Color defaultColor) { Swatch swatch = GetSwatchForTarget(target); return(swatch?.GetArgb() ?? defaultColor); }