示例#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
文件: DynamicLayout.cs 项目: Exe0/Eto
		public DynamicLayout(Padding? padding, Size? spacing = null, Generator generator = null)
			: base(generator)
		{
			topTable = new DynamicTable
			{ 
				Padding = padding, 
				Spacing = spacing
			};
			currentItem = topTable;
		}
示例#3
0
文件: DynamicLayout.cs 项目: Exe0/Eto
		public void EndVertical()
		{
			currentItem = currentItem.Parent ?? topTable;
		}
示例#4
0
文件: DynamicLayout.cs 项目: Exe0/Eto
		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
文件: DynamicItem.cs 项目: mhusen/Eto
		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;
 }