/// <summary> /// Makes sure that <c>loggerA</c> and <c>loggerB</c> have different colors assigned for their outputs to the Console buffer. /// </summary> /// <param name="loggerA">The logger a.</param> /// <param name="loggerB">The logger b.</param> /// <returns>true if the loggers have different colors, false if one of loggers is not in the current output or if otherwise failed to update color of <c>loggerB</c></returns> public virtual Boolean makeSureHaveDifferentColors(IConsoleControl loggerA, IConsoleControl loggerB) { if (!colorRegistar.ContainsKey(loggerA)) { return(false); } if (!colorRegistar.ContainsKey(loggerB)) { return(false); } if (colorRegistar[loggerA] != colorRegistar[loggerB]) { return(true); } Int32 limit = 10; while (colorRegistar[loggerA] == colorRegistar[loggerB]) { limit--; colorRegistar[loggerB] = colorSelector.next(1); if (limit < 0) { return(false); } } return(true); }
public String buildOneDimensionalChart <T>(chartTypeEnum chartType, String title, List <T> source, Func <T, String> label, Func <T, String> value, Func <T, String> color = null) { var fields = GetDefaultValues(); fields.Add("title", title); //List<String> color_set = new List<string>() { "69D2E7", "#E0E4CC", "#F38630", "#96CE7F", "#CEBC17", "#CE4264" }; circularSelector <String> color_selector = new circularSelector <String>("69D2E7", "#E0E4CC", "#F38630", "#96CE7F", "#CEBC17", "#CE4264"); foreach (T item in source) { String label_str = label(item); String value_str = value(item); String color_str = ""; if (color == null) { color_str = color_selector.next(); } else { color_str = color(item); } fields["colors"] = fields["colors"].add(color_str, ","); fields["data"] = fields["data"].add(value_str, ","); fields["labels"] = fields["labels"].add(label_str, ","); } stringTemplate template = new stringTemplate(chartTemplate[chartType]); return(template.applyToContent(fields)); }
public String buildTwoDimensionalChart <T>(chartTypeEnum chartType, String title, List <T> source, Func <T, String> label, Func <T, String> color = null, params Func <T, String>[] value) { var fields = GetDefaultValues(); fields.Add("title", title); //List<String> color_set = new List<string>() { "69D2E7", "#E0E4CC", "#F38630", "#96CE7F", "#CEBC17", "#CE4264" }; List <String> value_str = new List <string>(); foreach (var f in value) { value_str.Add("");//.Add(f(item)); } foreach (T item in source) { String label_str = label(item); for (int i = 0; i < value.Length; i++) { value_str[i] = value_str[i].add(value[i](item), ","); } //String value_str = value(item); String color_str = ""; if (color == null) { color_str = color_selector.next(); } else { color_str = color(item); } fields["colors"] = fields["colors"].add(color_str, ","); fields["labels"] = fields["labels"].add(label_str, ","); } foreach (var f in value_str) { fields["data"] = fields["data"].add(f, " next "); } stringTemplate template = new stringTemplate(chartTemplate[chartType]); return(template.applyToContent(fields)); }