public void Add(string NameParametr = null) { CParametrData oParametrData = new CParametrData(); if (oHeaderData.lst_Parametrs.Count > 0) { oParametrData.ID = oHeaderData.lst_Parametrs[oHeaderData.lst_Parametrs.Count - 1].ID + 1; } else { oParametrData.ID = oHeaderData.lst_Parametrs.Count; } if (string.IsNullOrEmpty(NameParametr)) { oParametrData.NameParametr = "New_Parametr_" + oParametrData.ID; } else { oParametrData.NameParametr = NameParametr; } oHeaderData.lst_Parametrs.Add(oParametrData); }
private void tspParametrs_Add_Click(object sender, EventArgs e) { frmHeaderParametrs frm = (sender as ToolStripButton).Owner.FindForm() as frmHeaderParametrs; Add(); CParametrData oParametrData = oHeaderData.lst_Parametrs[oHeaderData.lst_Parametrs.Count - 1]; Paint(ref oParametrData); if (frm.pnlParametrs.Controls.Count > 0) { frm.tspHeaderTemplate_Save.Enabled = true; } }
private void Paint(CParametrData oParametrData) { int Coordinate = 0; int z = 0; foreach (var VARIABLE in fHeader_Template.panelHeader.Controls) { if (VARIABLE is TextBox) { if ((VARIABLE as TextBox).Location.Y > Coordinate) { Coordinate = (VARIABLE as TextBox).Location.Y; } } } if (Coordinate > 0) { z = 15; } //Динамическое добавление Наименование пареметра Label lblParametr = new Label(); lblParametr.Size = new System.Drawing.Size(116, 18); lblParametr.Location = new System.Drawing.Point(14, 18 + Coordinate + z); lblParametr.Name = "lblParametr" + oParametrData.ID; lblParametr.Tag = oParametrData.ID; lblParametr.Text = oParametrData.NameParametr; fHeader_Template.panelHeader.Controls.Add(lblParametr); //Динамическое добавление Тектстового поля для редактирования пареметра TextBox txtParametr = new TextBox(); txtParametr.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; txtParametr.Size = new System.Drawing.Size(480, 20); txtParametr.Location = new System.Drawing.Point(136, 15 + Coordinate + z); txtParametr.Name = "txtParametr" + oParametrData.ID; txtParametr.Tag = oParametrData.ID; txtParametr.Text = oParametrData.ValueParametr; txtParametr.TextChanged += txtParametr_TextChanged; fHeader_Template.panelHeader.Controls.Add(txtParametr); //Динамическое добавление Кнопки для удаления параметра Button btnDel_Parametr = new Button(); btnDel_Parametr.Anchor = AnchorStyles.Top | AnchorStyles.Right; btnDel_Parametr.Image = Resources.Del_Parametr; btnDel_Parametr.Size = new System.Drawing.Size(21, 21); btnDel_Parametr.UseVisualStyleBackColor = true; btnDel_Parametr.Location = new System.Drawing.Point(630, 15 + Coordinate + z); btnDel_Parametr.Name = "btnDel_Parametr" + oParametrData.ID; btnDel_Parametr.Tag = oParametrData.ID; btnDel_Parametr.Click += btnDel_Parametr_Click; fHeader_Template.panelHeader.Controls.Add(btnDel_Parametr); }
private void Paint(ref CParametrData oParametrData) { int Coordinate = 0; int z = 0; foreach (var VARIABLE in fHeaderParametrs.pnlParametrs.Controls) { if (VARIABLE is TextBox) { if ((VARIABLE as TextBox).Location.Y > Coordinate) { Coordinate = (VARIABLE as TextBox).Location.Y; } } } if (Coordinate > 0) { z = 5; } Label lblParametr_ID = new Label(); lblParametr_ID.AutoSize = true; lblParametr_ID.Size = new Size(23, 13); lblParametr_ID.Location = new Point(9, 25 + Coordinate + z); lblParametr_ID.Name = "lblParametr_ID_" + oParametrData.ID; lblParametr_ID.Text = "ID–" + oParametrData.ID; lblParametr_ID.Tag = oParametrData.ID; fHeaderParametrs.pnlParametrs.Controls.Add(lblParametr_ID); TextBox txtNameParametr = new TextBox(); txtNameParametr.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; txtNameParametr.Location = new Point(62, 22 + Coordinate + z); txtNameParametr.Name = "txtNameParametr_" + oParametrData.ID; txtNameParametr.Size = new Size(305, 20); txtNameParametr.Tag = oParametrData.ID; txtNameParametr.Text = oParametrData.NameParametr; txtNameParametr.TextChanged += txtNameParametr_TextChanged; fHeaderParametrs.pnlParametrs.Controls.Add(txtNameParametr); Label lblColor = new Label(); lblColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; lblColor.AutoSize = true; lblColor.Location = new Point(376, 25 + Coordinate + z); lblColor.Name = "lblColor" + oParametrData.ID; lblColor.Size = new Size(31, 13); lblColor.Text = "Color"; lblColor.Tag = oParametrData.ID; fHeaderParametrs.pnlParametrs.Controls.Add(lblColor); PictureBox pcbColorParametr = new PictureBox(); ((ISupportInitialize)(pcbColorParametr)).BeginInit(); pcbColorParametr.Anchor = AnchorStyles.Top | AnchorStyles.Right; pcbColorParametr.BackColor = SystemColors.ActiveCaptionText; pcbColorParametr.BorderStyle = BorderStyle.Fixed3D; pcbColorParametr.Cursor = Cursors.Hand; pcbColorParametr.Location = new Point(413, 22 + Coordinate + z); pcbColorParametr.Name = "pcbColorParametr" + oParametrData.ID;; pcbColorParametr.Size = new Size(37, 20); pcbColorParametr.TabStop = false; pcbColorParametr.Tag = oParametrData.ID; pcbColorParametr.Click += pcbColorParametr_Click; ((ISupportInitialize)(pcbColorParametr)).EndInit(); fHeaderParametrs.pnlParametrs.Controls.Add(pcbColorParametr); Button btnDel_Parametr = new Button(); btnDel_Parametr.Anchor = AnchorStyles.Top | AnchorStyles.Right; btnDel_Parametr.Location = new Point(465, 21 + Coordinate + z); btnDel_Parametr.Name = "btnDelParametr" + oParametrData.ID;; btnDel_Parametr.Size = new Size(21, 21); btnDel_Parametr.UseVisualStyleBackColor = true; btnDel_Parametr.Image = Resources.Del_Parametr; btnDel_Parametr.Tag = oParametrData.ID; btnDel_Parametr.Click += btnDel_Parametr_Click; fHeaderParametrs.pnlParametrs.Controls.Add(btnDel_Parametr); }