Ejemplo n.º 1
0
        private void AddInput(Model.Entity.FormProperty formProperty, int y)
        {
            var label = new Label();

            label.Text     = formProperty.Name;
            label.Location = new Point(0, y);

            var textBox = new TextBox();

            textBox.Location = new Point(150, y);
            textBox.Size     = new System.Drawing.Size(319, 21);
            textBox.TabIndex = 2;

            textBox.TextChanged += new EventHandler(delegate(Object o, EventArgs a)
            {
                var value    = textBox.Text;
                var property = new Model.Entity.NewFormProperty()
                {
                    Id    = formProperty.Id,
                    Value = value
                };
                try
                {
                    var find   = this.newForm.Properties.Find(e => e.Id == property.Id);
                    find.Value = property.Value;
                }
                catch (Exception e)
                {
                    this.newForm.Properties.Add(property);
                }
            });
            this.panel1.Controls.Add(textBox);
            this.panel1.Controls.Add(label);
        }
Ejemplo n.º 2
0
        private void AddDropdown(Model.Entity.FormProperty formProperty, Model.Entity.Form form, int y)
        {
            var label = new Label();

            label.Text     = formProperty.Name;
            label.Location = new Point(0, y);

            var comboBox = new ComboBox();

            comboBox.Location = new Point(100, y);
            comboBox.Name     = formProperty.Id;
            comboBox.Size     = new System.Drawing.Size(200, 20);
            comboBox.TabIndex = 2;
            comboBox.Items.Clear();
            foreach (var p in formProperty.EnumValues)
            {
                if (p != null || p.Name != null)
                {
                    comboBox.Items.Add(p);
                }
            }
            comboBox.SelectedIndexChanged += new EventHandler(delegate(Object o, EventArgs a)
            {
                var selected = (Model.Entity.EnumValue)comboBox.SelectedItem;
                var property = new Model.Entity.NewFormProperty()
                {
                    Id    = formProperty.Id,
                    Value = selected.Name
                };
                try
                {
                    var find   = this.newForm.Properties.Find(e => e.Id == property.Id);
                    find.Value = property.Value;
                }
                catch (Exception e)
                {
                    this.newForm.Properties.Add(property);
                }
            });
            this.panel1.Controls.Add(comboBox);
            this.panel1.Controls.Add(label);
        }