Esempio n. 1
0
		public BrushSection()
		{
			var layout = new DynamicLayout();
			brush = solidBrush = Brushes.LightSkyBlue;
			gradientBrush = new LinearGradientBrush(Colors.AliceBlue, Colors.Black, new PointF(0, 0), new PointF(100f, 100f));
			//gradientBrush = new LinearGradientBrush (new RectangleF (0, 0, 50, 50), Colors.AliceBlue, Colors.Black, 10);
			gradientBrush.Wrap = GradientWrapMode.Repeat;
			textureBrush = new TextureBrush(image, 0.5f);
			brush = textureBrush;

			ScaleX = 100f;
			ScaleY = 100f;

			drawable = new Drawable { Size = new Size(300, 200) };

			drawable.Paint += (sender, pe) => Draw(pe.Graphics);

			layout.AddSeparateRow(null, BrushControl(), UseBackgroundColorControl(), null);
			if (Platform.Supports<NumericUpDown>())
			{
				matrixRow = layout.AddSeparateRow(null, new Label { Text = "Rot" }, RotationControl(), new Label { Text = "Sx" }, ScaleXControl(), new Label { Text = "Sy" }, ScaleYControl(), new Label { Text = "Ox" }, OffsetXControl(), new Label { Text = "Oy" }, OffsetYControl(), null);
				matrixRow.Table.Visible = false;
			}
			gradientRow = layout.AddSeparateRow(null, GradientWrapControl(), null);
			gradientRow.Table.Visible = false;
			layout.AddSeparateRow(null, drawable, null);
			layout.Add(null);

			this.Content = layout;
		}
Esempio n. 2
0
		public BrushSection()
		{
			var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) };

			// defaults
			ScaleX = 100f;
			ScaleY = 100f;
			Center = new PointF(100, 50);
			GradientOrigin = new PointF(150, 80);
			Radius = new SizeF(100f, 50f);
			StartPoint = new PointF(50, 50);
			EndPoint = new PointF(100, 100);

			drawable = new Drawable { Size = new Size(450, 400) };

			drawable.Paint += (sender, pe) => Draw(pe.Graphics);

			layout.AddSeparateRow(null, BrushControl(), UseBackgroundColorControl(), null);
			if (Platform.Supports<NumericUpDown>())
			{
				matrixRow = layout.AddSeparateRow(null, new Label { Text = "Rot" }, RotationControl(), new Label { Text = "Sx" }, ScaleXControl(), new Label { Text = "Sy" }, ScaleYControl(), new Label { Text = "Ox" }, OffsetXControl(), new Label { Text = "Oy" }, OffsetYControl(), null);
				matrixRow.Table.Visible = false;
			}
			gradientRow = layout.AddSeparateRow(null, GradientWrapControl(), null);
			gradientRow.Table.Visible = false;
			radialRow = layout.AddSeparateRow(null, "Center:", CenterControl(), "GradientOrigin:", GradientOriginControl(), null);
			radiusRow = layout.AddSeparateRow(null, "Radius:", RadiusControl(), null);
			linearRow = layout.AddSeparateRow(null, "Start:", StartPointControl(), "End:", EndPointControl(), null);
			layout.AddSeparateRow(null, drawable, null);
			layout.Add(null);

			this.Content = layout;
		}
Esempio n. 3
0
        /// <summary>
        /// Adds the specified item to a new row
        /// </summary>
        /// <param name="item">Item to add to a new row</param>
        public void AddRow(DynamicItem item)
        {
            var row = new DynamicRow();

            row.Add(item);
            Rows.Add(row);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the specified item to a new row
        /// </summary>
        /// <param name="item">Item to add to a new row</param>
        public void AddRow(DynamicItem item)
        {
            var row = new DynamicRow();

            row.Table = this;
            row.Items.Add(item);
            Rows.Add(row);
        }
Esempio n. 5
0
        public override object ConvertFrom(sc.ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var dynamicRow = new DynamicRow();

            dynamicRow.Add(new DynamicControl {
                Control = value as Control
            });
            return(dynamicRow);
        }
Esempio n. 6
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;
		}
Esempio n. 7
0
        /// <summary>
        /// Adds a new row of controls to the current vertical section
        /// </summary>
        /// <returns>A new instance of the row that was added</returns>
        /// <param name="controls">Controls to add to the row</param>
        public DynamicRow AddRow(params Control[] controls)
        {
            if (controls == null)
            {
                controls = new Control[] { null }
            }
            ;

            var row = new DynamicRow(controls);

            currentItem.AddRow(row);
            currentItem.CurrentRow = null;
            return(row);
        }
Esempio n. 8
0
        public DynamicRow AddRow(params Control[] controls)
        {
            if (Generated)
            {
                throw new AlreadyGeneratedException();
            }
            if (controls == null)
            {
                controls = new Control[] { null }
            }
            ;

            var row = new DynamicRow(controls);

            currentItem.AddRow(row);
            currentItem.CurrentRow = null;
            return(row);
        }
Esempio n. 9
0
        /// <summary>
        /// Creates the content for this item
        /// </summary>
        /// <param name="layout">Top level layout the item is being created for</param>
        public override Control Create(DynamicLayout layout)
        {
            if (Rows.Count == 0)
            {
                return(null);
            }
            int cols = Rows.Where(r => r != null).Max(r => r.Count);

            var table = Table = new TableLayout(cols, Rows.Count);

            table.IsVisualControl = true;
            var padding = Padding ?? layout.DefaultPadding;

            if (padding != null)
            {
                table.Padding = padding.Value;
            }

            var spacing = Spacing ?? layout.DefaultSpacing;

            if (spacing != null)
            {
                table.Spacing = spacing.Value;
            }

            var scalingRow = new DynamicRow();

            scalingRow.Add(new DynamicControl {
                YScale = true
            });
            for (int cy = 0; cy < Rows.Count; cy++)
            {
                var row = Rows[cy] ?? scalingRow;
                for (int cx = 0; cx < row.Count; cx++)
                {
                    var item = row[cx] ?? new DynamicControl {
                        XScale = true
                    };
                    item.Create(layout, table, cx, cy);
                }
            }
            return(table);
        }
Esempio n. 10
0
		public DynamicRow AddRow(params Control[] controls)
		{
			if (controls == null)
				controls = new Control[] { null };
			
			var row = new DynamicRow(controls);
			currentItem.AddRow(row);
			currentItem.CurrentRow = null;
			return row;
		}
Esempio n. 11
0
 public void AddRow(DynamicRow row)
 {
     rows.Add(row);
 }
Esempio n. 12
0
 /// <summary>
 /// Adds the specified row to the table
 /// </summary>
 /// <param name="row">Row to add</param>
 public void AddRow(DynamicRow row)
 {
     row.Table = this;
     Rows.Add(row);
 }
Esempio n. 13
0
        public override Control Generate(DynamicLayout layout)
        {
            if (rows.Count == 0)
            {
                return(null);
            }
            int cols = rows.Where(r => r != null).Max(r => r.Items.Count);

            if (Container == null)
            {
                Container   = new Panel();
                this.Layout = new TableLayout(Container, cols, rows.Count);
            }
            else
            {
                this.Layout = new TableLayout(null, cols, rows.Count);
                layout.SetBaseInnerLayout();
            }
            var tableLayout = this.Layout;
            var padding     = this.Padding ?? layout.DefaultPadding;

            if (padding != null)
            {
                tableLayout.Padding = padding.Value;
            }

            var spacing = this.Spacing ?? layout.DefaultSpacing;

            if (spacing != null)
            {
                tableLayout.Spacing = spacing.Value;
            }

            var scalingRow = new DynamicRow();

            scalingRow.Items.Add(new DynamicControl {
                YScale = true
            });
            for (int cy = 0; cy < rows.Count; cy++)
            {
                var row = rows[cy];
                if (row == null)
                {
                    row = scalingRow;
                }
                for (int cx = 0; cx < row.Items.Count; cx++)
                {
                    var item = row.Items[cx];
                    if (item == null)
                    {
                        item = new DynamicControl {
                            XScale = true
                        }
                    }
                    ;
                    item.Generate(layout, tableLayout, cx, cy);
                }
            }
            return(Container);
        }
    }
Esempio n. 14
0
		/// <summary>
		/// Creates the content for this item
		/// </summary>
		/// <param name="layout">Top level layout the item is being created for</param>
		public override Control Create(DynamicLayout layout)
		{
			if (Rows.Count == 0)
				return null;
			int cols = Rows.Where(r => r != null).Max(r => r.Items.Count);

			Table = new TableLayout(cols, Rows.Count);
			var tableLayout = Table;
			var padding = Padding ?? layout.DefaultPadding;
			if (padding != null)
				tableLayout.Padding = padding.Value;

			var spacing = Spacing ?? layout.DefaultSpacing;
			if (spacing != null)
				tableLayout.Spacing = spacing.Value;

			var scalingRow = new DynamicRow();
			scalingRow.Items.Add(new DynamicControl { YScale = true });
			for (int cy = 0; cy < Rows.Count; cy++)
			{
				var row = Rows[cy] ?? scalingRow;
				for (int cx = 0; cx < row.Items.Count; cx++)
				{
					var item = row.Items[cx] ?? new DynamicControl { XScale = true };
					item.Create(layout, tableLayout, cx, cy);
				}
			}
			return Table;
		}
Esempio n. 15
0
		/// <summary>
		/// Adds the specified row to the table
		/// </summary>
		/// <param name="row">Row to add</param>
		public void AddRow(DynamicRow row)
		{
			row.Table = this;
			Rows.Add(row);
		}
Esempio n. 16
0
        public override Control Generate(DynamicLayout layout)
        {
            if (rows.Count == 0)
            {
                return(null);
            }
            int cols = rows.Where(r => r != null).Max(r => r.Items.Count);

            this.Table = new TableLayout(cols, rows.Count);
            var tableLayout = this.Table;
            var padding     = this.Padding ?? layout.DefaultPadding;

            if (padding != null)
            {
                tableLayout.Padding = padding.Value;
            }

            var spacing = this.Spacing ?? layout.DefaultSpacing;

            if (spacing != null)
            {
                tableLayout.Spacing = spacing.Value;
            }

            var scalingRow = new DynamicRow();

            scalingRow.Items.Add(new DynamicControl {
                YScale = true
            });
            for (int cy = 0; cy < rows.Count; cy++)
            {
                var row = rows[cy];
                if (row == null)
                {
                    row = scalingRow;
                }
                for (int cx = 0; cx < row.Items.Count; cx++)
                {
                    var item = row.Items[cx];
                    if (item == null)
                    {
                        item = new DynamicControl {
                            XScale = true
                        }
                    }
                    ;
                    item.Generate(layout, tableLayout, cx, cy);
                }
            }
            return(Table);
        }

        void ISupportInitialize.BeginInit()
        {
        }

        void ISupportInitialize.EndInit()
        {
            foreach (var row in rows)
            {
                row.Table = this;
            }
        }
    }
Esempio n. 17
0
 public void AddRow(DynamicItem item)
 {
     var row = new DynamicRow ();
     row.Items.Add (item);
     rows.Add (row);
 }
Esempio n. 18
0
 public void AddRow(DynamicRow row)
 {
     rows.Add (row);
 }
Esempio n. 19
0
		public DynamicRow AddRow(params Control[] controls)
		{
			if (Generated)
				throw new AlreadyGeneratedException();
			if (controls == null)
				controls = new Control[] { null };
			
			var row = new DynamicRow(controls);
			currentItem.AddRow(row);
			currentItem.CurrentRow = null;
			return row;
		}
Esempio n. 20
0
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			var dynamicRow = new DynamicRow();
			dynamicRow.Items.Add(new DynamicControl { Control = value as Control });
			return dynamicRow;
		}
Esempio n. 21
0
		public override Control Generate (DynamicLayout layout)
		{
			if (rows.Count == 0)
				return null;
			int cols = rows.Where (r => r != null).Max (r => r.Items.Count);

			if (Container == null) {
				Container = new Panel ();
				this.Layout = new TableLayout (Container, cols, rows.Count);
			}
			else {
				this.Layout = new TableLayout (null, cols, rows.Count);
				layout.SetBaseInnerLayout();
			}
			var tableLayout = this.Layout;
			var padding = this.Padding ?? layout.DefaultPadding;
			if (padding != null)
				tableLayout.Padding = padding.Value;

			var spacing = this.Spacing ?? layout.DefaultSpacing;
			if (spacing != null)
				tableLayout.Spacing = spacing.Value;

			var scalingRow = new DynamicRow ();
			scalingRow.Items.Add (new DynamicControl{ YScale = true });
			for (int cy = 0; cy < rows.Count; cy++) {
				var row = rows[cy];
				if (row == null) row = scalingRow;
				for (int cx = 0; cx < row.Items.Count; cx++) {
					var item = row.Items[cx];
					if (item == null) item = new DynamicControl { XScale = true };
					item.Generate (layout, tableLayout, cx, cy);
				}
			}
			return Container;
		}