Пример #1
0
 public FromSourceControl(LibFromSourceField[] sourceFields)
     : this()
 {
     foreach (LibFromSourceField item in sourceFields)
     {
         this.listBox1.Items.Add(item);
         FromSourceProperty sourceProperty = new FromSourceProperty(item.ID);
         sourceProperty.Dock = DockStyle.Fill;
         this.splitContainer1.Panel2.Controls.Add(sourceProperty);
         sourceProperty.SetPropertyValue(item, null);
         ModelDesignProject.SetControlVisible(sourceProperty, this.splitContainer1.Panel2.Controls);
     }
 }
Пример #2
0
        /// <summary>
        /// 新增按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button1_Click(object sender, EventArgs e)
        {
            LibFromSourceField fromSourceField = new LibFromSourceField();

            fromSourceField.ID = Guid.NewGuid().ToString();
            this.listBox1.Items.Add(fromSourceField);
            FromSourceProperty sourceProperty = new FromSourceProperty(fromSourceField.ID);

            sourceProperty.Dock = DockStyle.Fill;
            this.splitContainer1.Panel2.Controls.Add(sourceProperty);
            sourceProperty.SetPropertyValue(fromSourceField, null);
            ModelDesignProject.SetControlVisible(sourceProperty, this.splitContainer1.Panel2.Controls);
            //SetPanel2ControlsVisible(sourceProperty);
        }
Пример #3
0
        public override void TextAndBotton_Click(object sender, EventArgs e)
        {
            Control ctl   = sender as Control;
            string  ctrNm = ctl.Name.Replace(SysConstManage.BtnCtrlNmPrefix, "");
            Panel   p     = new Panel();

            p.AutoScroll = true;
            if (string.Compare(ctrNm, "fd_SourceField") == 0)//来源字段集
            {
                p.Name = "fromsourceProperty";

                FromSourceControl fromSourceControl = null;

                if (this.entity.SourceField == null)
                {
                    this.entity.SourceField = new LibCollection <LibFromSourceField>();
                    fromSourceControl       = new FromSourceControl();
                }
                else
                {
                    fromSourceControl = new FromSourceControl(this.entity.SourceField.ToArray());
                }
                fromSourceControl.Dock = DockStyle.Fill;
                p.Controls.Add(fromSourceControl);


                DialogForm dialogForm = new DialogForm(p);

                DialogResult dialog = dialogForm.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    SplitContainer ctr = fromSourceControl.Controls["splitContainer1"] as SplitContainer;
                    foreach (Control c in ctr.Panel2.Controls)
                    {
                        FromSourceProperty prop = c as FromSourceProperty;
                        prop.GetControlsValue();
                    }
                    ListBox box = ctr.Panel1.Controls["listBox1"] as ListBox;
                    foreach (LibFromSourceField sfield in box.Items)
                    {
                        if (this.entity.SourceField.FindFirst("ID", sfield.ID) == null)
                        {
                            this.entity.SourceField.Add(sfield);
                        }
                    }
                }
                #region 控件赋值
                this.Controls[ctrNm].Text = string.Empty;
                foreach (LibFromSourceField item in this.entity.SourceField)
                {
                    if (!string.IsNullOrEmpty(this.Controls[ctrNm].Text))
                    {
                        this.Controls[ctrNm].Text += SysConstManage.Comma;
                    }
                    this.Controls[ctrNm].Text += item.ToString();
                }
                //this.Controls[ctrNm].Text = this.entity.SourceField.ToString();
                #endregion
            }
            else if (string.Compare(ctrNm, "fd_Items") == 0)//键值对集
            {
                p.Name = "keyvalueitems";
                Panel p2 = new Panel();
                p2.Name   = "btnpanel";
                p2.Dock   = DockStyle.Top;
                p2.Height = 50;
                Button addbtn = new Button();
                addbtn.Name     = "_addkeyvalu";
                addbtn.Width    = 70;
                addbtn.Height   = 25;
                addbtn.Location = new System.Drawing.Point(20, 15);
                addbtn.Text     = "添加项";
                addbtn.Click   += Addbtn_Click;
                p2.Controls.Add(addbtn);

                Button deletbtn = new Button();
                deletbtn.Name     = "deletkeyvalu";
                deletbtn.Width    = 70;
                deletbtn.Height   = 25;
                deletbtn.Location = new System.Drawing.Point(110, 15);
                deletbtn.Text     = "删除项";
                p2.Controls.Add(deletbtn);

                Button frombtn = new Button();
                frombtn.Name     = "fromkeyvaluid";
                frombtn.Width    = 70;
                frombtn.Height   = 25;
                frombtn.Location = new System.Drawing.Point(200, 15);
                frombtn.Text     = "来源字典模型";
                frombtn.Click   += Frombtn_Click;
                p2.Controls.Add(frombtn);

                ListBox listBox = new ListBox();
                listBox.Name  = "_listbox";
                listBox.Dock  = DockStyle.Left;
                listBox.Width = 200;
                listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged;



                KeyValueProperty keyValueProperty = new KeyValueProperty();
                keyValueProperty.Name = "_keyvalueProperty";
                keyValueProperty.Dock = DockStyle.Fill;
                p.Controls.Add(keyValueProperty);
                //Panel p3 = new Panel();
                //p3.Name = "keyvalueContains";
                //p3.Dock = DockStyle.Fill;

                p.Controls.Add(keyValueProperty);
                p.Controls.Add(listBox);
                p.Controls.Add(p2);

                if (this.entity.Items != null)
                {
                    foreach (LibKeyValue keyvalue in this.entity.Items)
                    {
                        listBox.Items.Add(keyvalue);
                    }
                }

                DialogForm dialogForm = new DialogForm(p);
                dialogForm.Size = new Size(700, 488);


                DialogResult dialog = dialogForm.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    if (this.entity.Items == null)
                    {
                        this.entity.Items = new LibCollection <LibKeyValue>();
                    }
                    this.entity.Items.RemoveAll();
                    foreach (LibKeyValue item in listBox.Items)
                    {
                        //if (this.entity.Items.FindFirst("Key", item.Key) == null)
                        //{
                        this.entity.Items.Add(item);
                        //}
                    }
                    #region 控件赋值
                    this.Controls[ctrNm].Text = string.Empty;
                    foreach (LibKeyValue keyval in this.entity.Items)
                    {
                        if (this.Controls[ctrNm].Text.Length != 0)
                        {
                            this.Controls[ctrNm].Text += ";";
                        }
                        this.Controls[ctrNm].Text += keyval.ToString();
                    }

                    #endregion
                }
            }
            else if (string.Compare(ctrNm, "fd_ValidateExpression") == 0)//有效性验证
            {
                FieldValidationControl fieldValidation = new FieldValidationControl(this.entity.ValidateExpression);
                fieldValidation.Dock = DockStyle.Fill;
                p.Controls.Add(fieldValidation);

                fieldValidation.SetExpressValue();

                DialogForm dialogForm = new DialogForm(p);
                dialogForm.Size = new Size(700, 488);

                DialogResult dialog = dialogForm.ShowDialog(this);
                if (dialog == DialogResult.OK)
                {
                    //this.entity.ValidateExpression.Express = fieldValidation.GetExpressValue();
                    //this.entity.ValidateExpression.MsgCode = fieldValidation.GetExpressValue();
                    fieldValidation.GetExpressValue();
                    #region 控件赋值
                    this.Controls[ctrNm].Text = this.entity.ValidateExpression.Express;
                    #endregion
                }
            }
        }