DebrisSelectionAddConditionDialog.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace PaintDotNet.GeneralAnalysis
  11. {
  12. /// <summary>
  13. /// 条件设置-添加名称
  14. /// </summary>
  15. internal class DebrisSelectionAddConditionDialog : PdnBaseForm
  16. {
  17. private GroupBox groupBox1;
  18. private Button button1;
  19. private GroupBox groupBox2;
  20. private TextBox textBox1;
  21. private Label label1;
  22. /// <summary>
  23. /// 父级窗口
  24. /// </summary>
  25. private DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog;
  26. /// <summary>
  27. /// 是否为编辑状态
  28. /// </summary>
  29. private bool isEdit = false;
  30. /// <summary>
  31. /// 要编辑的项目在原列表的下标
  32. /// </summary>
  33. private int index = -1;
  34. public DebrisSelectionAddConditionDialog(DebrisSelectionValidConditionDialog debrisSelectionValidConditionDialog, string itemName, int itemIndex)
  35. {
  36. this.debrisSelectionValidConditionDialog = debrisSelectionValidConditionDialog;
  37. InitializeComponent();
  38. InitializeLanguageText();
  39. if (!string.IsNullOrEmpty(itemName))
  40. {
  41. this.textBox1.Text = itemName;
  42. this.isEdit = true;
  43. this.index = itemIndex;
  44. }
  45. }
  46. private void InitializeLanguageText()
  47. {
  48. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  49. this.button1.Text = PdnResources.GetString("Menu.File.Save.Text");
  50. this.groupBox2.Text = PdnResources.GetString("Menu.Setting.Text");
  51. this.label1.Text = PdnResources.GetString("Menu.name.text") + ":";
  52. this.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionsettingname.text");
  53. }
  54. private void InitializeComponent()
  55. {
  56. this.groupBox1 = new System.Windows.Forms.GroupBox();
  57. this.button1 = new System.Windows.Forms.Button();
  58. this.groupBox2 = new System.Windows.Forms.GroupBox();
  59. this.textBox1 = new System.Windows.Forms.TextBox();
  60. this.label1 = new System.Windows.Forms.Label();
  61. this.groupBox1.SuspendLayout();
  62. this.groupBox2.SuspendLayout();
  63. this.SuspendLayout();
  64. //
  65. // groupBox1
  66. //
  67. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  68. | System.Windows.Forms.AnchorStyles.Right)));
  69. this.groupBox1.Controls.Add(this.button1);
  70. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  71. this.groupBox1.Name = "groupBox1";
  72. this.groupBox1.Size = new System.Drawing.Size(304, 42);
  73. this.groupBox1.TabIndex = 0;
  74. this.groupBox1.TabStop = false;
  75. this.groupBox1.Text = "操作";
  76. //
  77. // button1
  78. //
  79. this.button1.Location = new System.Drawing.Point(213, 13);
  80. this.button1.Name = "button1";
  81. this.button1.Size = new System.Drawing.Size(75, 23);
  82. this.button1.TabIndex = 0;
  83. this.button1.Text = "保存";
  84. this.button1.UseVisualStyleBackColor = true;
  85. this.button1.Click += new System.EventHandler(this.button1_Click);
  86. //
  87. // groupBox2
  88. //
  89. this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
  90. | System.Windows.Forms.AnchorStyles.Right)));
  91. this.groupBox2.Controls.Add(this.textBox1);
  92. this.groupBox2.Controls.Add(this.label1);
  93. this.groupBox2.Location = new System.Drawing.Point(13, 60);
  94. this.groupBox2.Name = "groupBox2";
  95. this.groupBox2.Size = new System.Drawing.Size(303, 65);
  96. this.groupBox2.TabIndex = 1;
  97. this.groupBox2.TabStop = false;
  98. this.groupBox2.Text = "设置";
  99. //
  100. // textBox1
  101. //
  102. this.textBox1.Location = new System.Drawing.Point(98, 28);
  103. this.textBox1.Name = "textBox1";
  104. this.textBox1.Size = new System.Drawing.Size(162, 21);
  105. this.textBox1.TabIndex = 1;
  106. //
  107. // label1
  108. //
  109. this.label1.AutoSize = true;
  110. this.label1.Location = new System.Drawing.Point(29, 32);
  111. this.label1.Name = "label1";
  112. this.label1.Size = new System.Drawing.Size(41, 12);
  113. this.label1.TabIndex = 0;
  114. this.label1.Text = "名称:";
  115. //
  116. // DebrisSelectionAddConditionDialog
  117. //
  118. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  119. this.ClientSize = new System.Drawing.Size(328, 137);
  120. this.Controls.Add(this.groupBox2);
  121. this.Controls.Add(this.groupBox1);
  122. this.MaximizeBox = false;
  123. this.MinimizeBox = false;
  124. this.Name = "DebrisSelectionAddConditionDialog";
  125. this.Text = "条件设置名称";
  126. this.Controls.SetChildIndex(this.groupBox1, 0);
  127. this.Controls.SetChildIndex(this.groupBox2, 0);
  128. this.groupBox1.ResumeLayout(false);
  129. this.groupBox2.ResumeLayout(false);
  130. this.groupBox2.PerformLayout();
  131. this.ResumeLayout(false);
  132. }
  133. /// <summary>
  134. /// 保存按钮
  135. /// </summary>
  136. /// <param name="sender"></param>
  137. /// <param name="e"></param>
  138. private void button1_Click(object sender, EventArgs e)
  139. {
  140. if (!string.IsNullOrEmpty(this.textBox1.Text))
  141. {
  142. //编辑
  143. if (isEdit)
  144. {
  145. if (this.index > -1)
  146. debrisSelectionValidConditionDialog.AddContentToListview(this.textBox1.Text, true, this.index);
  147. else
  148. return;
  149. }
  150. //新建
  151. else
  152. debrisSelectionValidConditionDialog.AddContentToListview(this.textBox1.Text, false, 0);
  153. this.Close();
  154. }
  155. }
  156. }
  157. }