LitDev.LDChart.ColourMap C# (CSharp) Method

ColourMap() public static method

Set colour mapping for the chart.
public static ColourMap ( Primitive chartName, Primitive hue, Primitive saturation, Primitive lightness, Primitive hsl, Primitive start, Primitive end, Primitive centralColour ) : void
chartName Primitive The chart name.
hue Primitive A hue (colour 0 to 360), default 0 (red).
saturation Primitive A saturation (intensity 0 to 1), default 0.5.
lightness Primitive A lightness (brightness 0 to 1), default 0.5.
hsl Primitive The parameter to change for different segments, options are: /// "Hue" (default) rainbow colours /// "Saturation" increasing intensity of colour /// "Lightness" increasing brightness
start Primitive Starting value for colour variation in the range [0 to 1], default 0.
end Primitive Ending value for colour variation in the range [0 to 1], default 1.
centralColour Primitive An optional circular gradient color centered on chart, default "".
return void
        public static void ColourMap(Primitive chartName, Primitive hue, Primitive saturation, Primitive lightness, Primitive hsl, Primitive start, Primitive end, Primitive centralColour)
        {
            Type GraphicsWindowType = typeof(GraphicsWindow);
            Dictionary<string, UIElement> _objectsMap;
            UIElement obj;

            try
            {
                _objectsMap = (Dictionary<string, UIElement>)GraphicsWindowType.GetField("_objectsMap", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                if (_objectsMap.TryGetValue((string)chartName, out obj))
                {
                    InvokeHelper ret = new InvokeHelper(delegate
                    {
                        try
                        {
                            if (obj.GetType() == typeof(Chart))
                            {
                                Chart chart = (Chart)obj;
                                chart.hue = hue;
                                chart.saturation = saturation;
                                chart.lightness = lightness;
                                chart.startColor = start;
                                chart.endColor = end;
                                chart.centralColour = centralColour;
                                switch (((string)hsl).ToLower())
                                {
                                    case "hue":
                                        chart.eHSL = Chart.HSL.HUE;
                                        break;
                                    case "saturation":
                                        chart.eHSL = Chart.HSL.SATURATION;
                                        break;
                                    case "lightness":
                                        chart.eHSL = Chart.HSL.LIGHTNESS;
                                        break;
                                }
                                chart.Update();
                            }
                        }
                        catch (Exception ex)
                        {
                            Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                        }
                    });
                    FastThread.Invoke(ret);
                }
                else
                {
                    Utilities.OnShapeError(Utilities.GetCurrentMethod(), chartName);
                }
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }