public override object ReadJson (Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { object instance; JContainer container; if (reader.TokenType == JsonToken.Null) { return null; } if (reader.TokenType == JsonToken.StartArray) { container = JArray.Load (reader); if (objectType == typeof(DynamicRow)) { var dynamicRow = new DynamicRow (); instance = dynamicRow; serializer.Populate (container.CreateReader (), dynamicRow.Items); } else if (objectType == typeof(DynamicItem)) { var dynamicTable = new DynamicTable (); instance = dynamicTable; serializer.Populate (container.CreateReader (), dynamicTable.Rows); } else throw new EtoException("Invalid object graph"); } else { container = JObject.Load (reader); if (container["$type"] == null) { if (container["Rows"] != null) instance = new DynamicTable (); else if (container["Control"] != null) instance = new DynamicControl (); else throw new EtoException("Could not infer the type of object to create"); serializer.Populate(container.CreateReader(), instance); } else { var type = Type.GetType ((string)container ["$type"]); if (!typeof(DynamicItem).IsAssignableFrom (type)) { var dynamicControl = new DynamicControl (); dynamicControl.Control = serializer.Deserialize (container.CreateReader ()) as Control; instance = dynamicControl; } else { instance = serializer.Deserialize (container.CreateReader ()); } } } if (objectType == typeof(DynamicRow) && instance.GetType () != typeof(DynamicRow)) { var row = new DynamicRow(); row.Items.Add (instance as DynamicItem); return row; } return instance; }
public DynamicLayout(Padding? padding, Size? spacing = null, Generator generator = null) : base(generator) { topTable = new DynamicTable { Padding = padding, Spacing = spacing }; currentItem = topTable; }
public void EndVertical() { currentItem = currentItem.Parent ?? topTable; }
public DynamicTable BeginVertical(Padding? padding = null, Size? spacing = null, bool? xscale = null, bool? yscale = null) { var newItem = new DynamicTable { Parent = currentItem ?? topTable, Padding = padding, Spacing = spacing, XScale = xscale, YScale = yscale }; currentItem.Add(newItem); currentItem = newItem; return newItem; }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class with the specified rows /// </summary> /// <param name="rows">Rows to populate the layout.</param> public DynamicLayout(IEnumerable <DynamicRow> rows) { topTable = new DynamicTable(rows); topTable.layout = this; currentItem = topTable; }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class. /// </summary> public DynamicLayout() { topTable = new DynamicTable(); topTable.layout = this; currentItem = topTable; }
public void EndVertical() { if (Generated) throw new AlreadyGeneratedException(); currentItem = currentItem.Parent ?? topTable; }
internal override void SetParent(DynamicTable table) { Parent = table; SetLayout(table != null ? table.layout : null); }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class. /// </summary> public DynamicLayout() { topTable = new DynamicTable(); currentItem = topTable; }
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class with the specified rows /// </summary> /// <param name="rows">Rows to populate the layout.</param> public DynamicLayout(IEnumerable<DynamicRow> rows) { topTable = new DynamicTable(rows); topTable.layout = this; currentItem = topTable; }
public DynamicRowCollection(DynamicTable parent) { this.parent = parent; }
internal abstract void SetParent(DynamicTable table);
/// <summary> /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class. /// </summary> public DynamicLayout() { currentItem = topTable; }
public DynamicTable BeginVertical(Padding? padding = null, Size? spacing = null, bool? xscale = null, bool? yscale = null) { if (Generated) throw new AlreadyGeneratedException(); var newItem = new DynamicTable { Parent = currentItem ?? topTable, Padding = padding, Spacing = spacing, XScale = xscale, YScale = yscale }; currentItem.Add(newItem); currentItem = newItem; return newItem; }
/// <summary> /// Ends the current vertical section /// </summary> /// <remarks> /// This should be balanced with every call to <see cref="BeginVertical(Padding?,Size?,bool?,bool?)"/>. /// Alternatively, you can call <see cref="EndBeginVertical"/> to end the current vertical section and start a new one. /// </remarks> public void EndVertical() { currentItem = currentItem.Parent ?? topTable; }