Exemple #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jo   = JObject.Load(reader);
            string  type = (string)jo["Type"];
            SerializableViewElement item;

            switch (type)
            {
            case "StackLayout":
                item = new SerializableStackLayout();
                break;

            case "Label":
                item = new SerializableLabel();
                break;

            default:
                item = new SerializableViewElement();
                break;
            }

            serializer.Populate(jo.CreateReader(), item);

            return(item);
        }
        private static Label BuildLabel(SerializableLabel element)
        {
            Label label = new Label();

            label.Text = element.Text;
            label.HorizontalOptions = GetLayoutOptions(element.HorizontalOptions);
            label.VerticalOptions   = GetLayoutOptions(element.VerticalOptions);
            if (element.TextColor != null && element.TextColor != "")
            {
                label.TextColor = GetColor(element.TextColor);
            }
            label.FontSize       = element.FontSize;
            label.FontAttributes = GetFontAttributes(element.FontAttributes);
            return(label);
        }