Example #1
0
        private void PrintHeuriticComparisonsColorsToHtml(ColorScheme colorScheme)
        {
            string path = this.GetOutputFolder("AllSchemes", colorScheme.Name + ".html");

            using (var tw = new StreamWriter(path))
            {
                tw.WriteLine("<html><body>");

                // print header
                int index = 0;
                tw.WriteLine($"<html><body><h3>Scheme:&nbsp;{colorScheme.Name}</h3><table><tr>");
                foreach (uint ci in colorScheme.GetAll())
                {
                    Color c = Color.FromArgb((int)ci);
                    tw.Write($"<td bgcolor=\"{c.ToRgbHex()}\">{((ConsoleColor)index++)}</td>");
                }
                tw.WriteLine("</tr><tr>");
                foreach (uint ci in colorScheme.GetAll())
                {
                    Color c = Color.FromArgb((int)ci);
                    tw.Write($"<td bgcolor=\"{c.ToRgbHex()}\">{c.Name}</td>");
                }
                tw.WriteLine("</tr></table></br>");

                var balancers = this._heuristics.Select(h => new ColorBalancer(colorScheme, h)).ToArray();

                // print colors
                tw.WriteLine("<table><tr><th>ColorName</th><th>Sys Color</th>");
                foreach (var h in this._heuristics)
                {
                    tw.Write($"<th>{h.Name}</th>");
                }
                tw.WriteLine("</tr>");

                foreach (var propertyInfo in this._props)
                {
                    tw.WriteLine("<tr>");

                    Color c = (Color)propertyInfo.GetValue(null);


                    tw.Write($"<td>{propertyInfo.Name}</td><td bgcolor=\"{c.ToRgbHex()}\">{c.Name}</td>");

                    foreach (var balancer in balancers)
                    {
                        ConsoleColor cc = balancer.FindClosestColor(c);

                        Color cCol   = balancer.GetCurrentConsoleColor(cc);
                        var   ccName = Enum.GetName(typeof(ConsoleColor), cc);

                        tw.Write($"<td bgcolor=\"{cCol.ToRgbHex()}\">{ccName}</td>");
                    }

                    tw.WriteLine("</tr>");
                }


                tw.WriteLine("</table>");


                tw.WriteLine("</body></html>");
                tw.Close();
            }
        }