123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- 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
- {
- /// <summary>
- /// 条件设置-添加名称
- /// </summary>
- internal class DebrisSelectionAddConditionDialog : PdnBaseForm
- {
- private GroupBox groupBox1;
- private Button button1;
- private GroupBox groupBox2;
- private TextBox textBox1;
- private Label label1;
- /// <summary>
- /// 父级窗口
- /// </summary>
- private DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog;
- /// <summary>
- /// 是否为编辑状态
- /// </summary>
- private bool isEdit = false;
- /// <summary>
- /// 要编辑的项目在原列表的下标
- /// </summary>
- 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);
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- }
- }
|