Ejemplo n.º 1
0
		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;
		}
Ejemplo n.º 2
0
		public DynamicLayout(Padding? padding, Size? spacing = null, Generator generator = null)
			: base(generator)
		{
			topTable = new DynamicTable
			{ 
				Padding = padding, 
				Spacing = spacing
			};
			currentItem = topTable;
		}
Ejemplo n.º 3
0
		public void EndVertical()
		{
			currentItem = currentItem.Parent ?? topTable;
		}
Ejemplo n.º 4
0
		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;
		}
Ejemplo n.º 5
0
 /// <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;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class.
 /// </summary>
 public DynamicLayout()
 {
     topTable        = new DynamicTable();
     topTable.layout = this;
     currentItem     = topTable;
 }
Ejemplo n.º 7
0
		public void EndVertical()
		{
			if (Generated)
				throw new AlreadyGeneratedException();
			currentItem = currentItem.Parent ?? topTable;
		}
Ejemplo n.º 8
0
 internal override void SetParent(DynamicTable table)
 {
     Parent = table;
     SetLayout(table != null ? table.layout : null);
 }
Ejemplo n.º 9
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class.
		/// </summary>
		public DynamicLayout()
		{
			topTable = new DynamicTable();
			currentItem = topTable;
		}
Ejemplo n.º 10
0
		/// <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;
		}
Ejemplo n.º 11
0
 public DynamicRowCollection(DynamicTable parent)
 {
     this.parent = parent;
 }
Ejemplo n.º 12
0
		/// <summary>
		/// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class.
		/// </summary>
		public DynamicLayout()
		{
			topTable = new DynamicTable();
			topTable.layout = this;
			currentItem = topTable;
		}
Ejemplo n.º 13
0
		internal abstract void SetParent(DynamicTable table);
Ejemplo n.º 14
0
 internal abstract void SetParent(DynamicTable table);
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class.
 /// </summary>
 public DynamicLayout()
 {
     currentItem = topTable;
 }
Ejemplo n.º 16
0
		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;
		}
Ejemplo n.º 17
0
 /// <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;
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Eto.Forms.DynamicLayout"/> class.
 /// </summary>
 public DynamicLayout()
 {
     topTable    = new DynamicTable();
     currentItem = topTable;
 }