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