Exemple #1
0
        private void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox          listBox          = sender as ListBox;
            KeyValueProperty keyValueProperty = this.panel3.Controls["_keyvalueProperty"] as KeyValueProperty;

            LibKeyValue keyValue = listBox.Items[listBox.SelectedIndex] as LibKeyValue;

            keyValueProperty.SetPropertyValue(keyValue, null);
        }
Exemple #2
0
        public KeyValuesControl(LibTreeNode funcNode)
            : this()
        {
            this._funNode = funcNode;
            KeyValueProperty keyValueProperty = new KeyValueProperty();

            keyValueProperty.Name = "_keyvalueProperty";
            keyValueProperty.Dock = DockStyle.Fill;
            this.panel3.Controls.Add(keyValueProperty);
        }
Exemple #3
0
        /// <summary>
        /// 新增项事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button1_Click(object sender, EventArgs e)
        {
            LibKeyValue keyValue = new LibKeyValue();

            keyValue.ID    = Guid.NewGuid().ToString();
            keyValue.Key   = string.Format("itemkey{0}", this.listBox1.Items.Count + 1);
            keyValue.Value = string.Format("itemvalue{0}", this.listBox1.Items.Count + 1);

            this.listBox1.Items.Add(keyValue);
            this.listBox1.SelectedItem = keyValue;
            KeyValueProperty keyValueProperty = this.panel3.Controls["_keyvalueProperty"] as KeyValueProperty;

            keyValueProperty.SetPropertyValue(keyValue, null);
        }
Exemple #4
0
        private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox          listBox          = sender as ListBox;
            Control          container        = listBox.Parent;
            KeyValueProperty keyValueProperty = container.Controls["_keyvalueProperty"] as KeyValueProperty;

            LibKeyValue keyValue = listBox.Items[listBox.SelectedIndex] as LibKeyValue;

            keyValueProperty.SetPropertyValue(keyValue, null);
            if (!string.IsNullOrEmpty(keyValue.FromkeyValueID))
            {
                keyValueProperty.Enabled = false;
            }
            else
            {
                keyValueProperty.Enabled = true;
            }
        }
Exemple #5
0
        /// <summary>键值对窗体中的添加按钮事件</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Addbtn_Click(object sender, EventArgs e)
        {
            Control     ctl       = sender as Control;
            Control     container = ctl.Parent.Parent;
            ListBox     box       = container.Controls["_listbox"] as ListBox;
            LibKeyValue keyValue  = new LibKeyValue();

            keyValue.ID    = Guid.NewGuid().ToString();
            keyValue.Key   = string.Format("itemkey{0}", box.Items.Count + 1);
            keyValue.Value = string.Format("itemvalue{0}", box.Items.Count + 1);

            box.Items.Add(keyValue);

            //KeyValueProperty keyValueProperty = new KeyValueProperty();
            //keyValueProperty.Dock = DockStyle.Fill;
            KeyValueProperty keyValueProperty = container.Controls["_keyvalueProperty"] as KeyValueProperty;

            keyValueProperty.SetPropertyValue(keyValue, null);

            //container.Controls["keyvalueContains"].Controls.Add(keyValueProperty);
        }
Exemple #6
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
                }
            }
        }