Example #1
0
        private string GetPaletteString(Color color, string name, bool increasing = false, float?saturation = null, float?value = null)
        {
            var          drawingColor = color.ToDrawing();
            var          hue          = drawingColor.GetHue();
            var          sat          = drawingColor.GetSaturation();
            var          val          = drawingColor.GetValue();
            const string template     = "<Color x:Key=\"{{themes:ColorThemeKey {0}{1:000}}}\">{2}</Color>";
            var          result       = new StringBuilder();
            const int    count        = 10;

            for (var i = 0; i < count; i++)
            {
                var satStep = sat / count * i;
                var valStep = val / count * i;
                if (!increasing)
                {
                    satStep = sat - satStep;
                    valStep = val - valStep;
                }

                var iColor = ColorExtensions.FromAhsv(color.A, hue, saturation ?? satStep, value ?? valStep);
                result.AppendFormat(template, name, 100 - i * 10, iColor.ToWpf().ToString());
                result.AppendLine();
            }

            return(result.ToString());
        }