using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.GeneralAnalysis { /// /// 条件设置-添加名称 /// internal class DebrisSelectionAddConditionDialog : PdnBaseForm { private GroupBox groupBox1; private Button button1; private GroupBox groupBox2; private TextBox textBox1; private Label label1; /// /// 父级窗口 /// private DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog; /// /// 是否为编辑状态 /// private bool isEdit = false; /// /// 要编辑的项目在原列表的下标 /// private int index = -1; public DebrisSelectionAddConditionDialog(DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog, string itemName, int itemIndex) { this.debrisSelectionValidConditionDialog = debrisSelectionValidConditionDialog; InitializeComponent(); InitializeLanguageText(); if (!string.IsNullOrEmpty(itemName)) { this.textBox1.Text = itemName; this.isEdit = true; this.index = itemIndex; } } private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button1.Text = PdnResources.GetString("Menu.File.Save.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text"); this.label1.Text = PdnResources.GetString("Menu.name.text") + ":"; this.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionsettingname.text"); } private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(304, 42); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // button1 // this.button1.Location = new System.Drawing.Point(213, 13); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "保存"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.textBox1); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(13, 60); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(303, 65); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "设置"; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(98, 28); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(162, 21); this.textBox1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(29, 32); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 0; this.label1.Text = "名称:"; // // DebrisSelectionAddConditionDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(328, 137); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "DebrisSelectionAddConditionDialog"; this.Text = "条件设置名称"; this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.ResumeLayout(false); } /// /// 保存按钮 /// /// /// private void button1_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.textBox1.Text)) { //编辑 if (isEdit) { if (this.index > -1) debrisSelectionValidConditionDialog.AddContentToListview(this.textBox1.Text, true, this.index); else return; } //新建 else debrisSelectionValidConditionDialog.AddContentToListview(this.textBox1.Text, false, 0); this.Close(); } } } }