public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var o = default(Object);

            var json = serializer.Deserialize <JObject>(reader);
            var type = json.Value <string>("type");

            if (type != null)
            {
                type = type.ToLower();
            }

            switch (type)
            {
            case "text":

                var value = json.Value <string>("value");
                o = value;

                break;

            case "image":

                var source = json.Value <string>("source");
                var bitmap = GetBitmap(source);

                var colorize = json.Value <string>("colorize");
                if (colorize != null)
                {
                    if (!BrushJsonConverter.TryGetColor(colorize, out var color))
                    {
                        App.Instance.Config.LoadLayoutErrors.Add(string.Format("Colorize input '{0}': Invalid format", color));
                        return(o);
                    }

                    bitmap = Designer.ColorizeImage(bitmap, color);
                }

                var img = new Image {
                    Source = bitmap
                };

                if (json.TryGetValue("opacity", out var jsonOpacity))
                {
                    img.Opacity = jsonOpacity.Value <double>();
                }

                if (json.TryGetValue("stretch", out var jsonStretch))
                {
                    img.Stretch = GetStretch(jsonStretch.Value <string>());
                }

                if (json.TryGetValue("margin", out var jsonMargin))
                {
                    img.Margin = ThicknessJsonConverter.FromString(jsonMargin.Value <string>());
                }

                o = img;

                break;
            }

            return(o);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var o = default(Brush);

            var json = serializer.Deserialize <JObject>(reader);
            var type = json.Value <string>("type");

            if (type != null)
            {
                type = type.ToLower();
            }

            switch (type)
            {
            case "image": {
                var stretch = json.Value <string>("stretch");
                var tile    = json.Value <string>("tile");
                var source  = json.Value <string>("source");

                var bitmap = ContentJsonConverter.GetBitmap(source);

                var colorize = json.Value <string>("colorize");
                if (colorize != null)
                {
                    if (!TryGetColor(colorize, out var color))
                    {
                        App.Instance.Config.LoadLayoutErrors.Add(string.Format("Colorize input '{0}': Invalid format", color));
                        return(o);
                    }

                    bitmap = Designer.ColorizeImage(bitmap, color);
                }

                o = new ImageBrush {
                    Stretch     = ContentJsonConverter.GetStretch(stretch),
                    TileMode    = GetTileMode(tile),
                    ImageSource = bitmap,
                };
                break;
            }

            case "solid": {
                var value = json.Value <string>("value");
                if (!TryGetColor(value, out var color))
                {
                    App.Instance.Config.LoadLayoutErrors.Add(string.Format("Solid color input '{0}': Invalid format", value));
                    return(o);
                }

                o = new SolidColorBrush {
                    Color = color
                };
                break;
            }

            case "gradient": {
                var angle  = json.Value <double>("angle");
                var points = ConvertAngleToPoints(angle);

                var brush = new LinearGradientBrush {
                    StartPoint = points.Item1,
                    EndPoint   = points.Item2,
                };

                var values = json.Value <JToken>("values").Values <string>();
                foreach (var v in values)
                {
                    var errMsg = AttemptGetGradientStop(v, out var gs);
                    if (errMsg != null)
                    {
                        App.Instance.Config.LoadLayoutErrors.Add(string.Format("Gradient color input '{0}': {1}", v, errMsg));
                        continue;
                    }

                    brush.GradientStops.Add(gs);
                }

                o = brush;
                break;
            }
            }

            return(o);
        }