/// <summary> /// Produce a style for the given context. /// </summary> /// <param name="ic2sc">Context.</param> /// <returns>Style or NULL.</returns> public override Style For(ICategory2StyleContext ic2sc) { if (BasedOn == null) { return(null); } var match = Entries.SingleOrDefault(xx => xx.Compare(ic2sc.Values[0])); if (match == null) { return(null); } var style = BasedOn.Override(Path.FillProperty, match.Color); return(style); }
/// <summary> /// Create a style or NULL. /// </summary> /// <param name="ic2sc">Item context.</param> /// <returns>Style or NULL.</returns> public override Style For(ICategory2StyleContext ic2sc) { if (BasedOn == null) { return(null); } InfoFor(ic2sc.ValueExtents.Minimum, ic2sc.ValueExtents.Maximum, ic2sc.Values[0], out int red, out int green, out int blue); string skey = $"r{red}_g{green}_b{blue}"; if (StyleMap.TryGetValue(skey, out Style stx)) { return(stx); } var brush = BrushFor(red, green, blue); var style = BasedOn.Override(Path.FillProperty, brush); StyleMap.Add(skey, style); return(style); }