GrainSizePointCountingMethodGridSaveDialog.cs 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace PaintDotNet.DedicatedAnalysis.QuantitativeAnalysis
  12. {
  13. /// <summary>
  14. /// 晶粒度(计点法)网格保存
  15. /// </summary>
  16. public partial class GrainSizePointCountingMethodGridSaveDialog : Form
  17. {
  18. #region 控件
  19. private Label label1;
  20. private TextBox textBox1;
  21. private Button button1;
  22. private Button button2;
  23. private Label label2;
  24. #endregion
  25. /// <summary>
  26. /// 已有的网格
  27. /// </summary>
  28. private List<string> grids;
  29. private int form;
  30. public GrainSizePointCountingMethodGridSaveDialog(List<string> grids, int form, string oldValue)
  31. {
  32. this.form = form;
  33. this.grids = grids;
  34. InitializeComponent();
  35. InitializeLanguageText();
  36. this.textBox1.Text = oldValue;
  37. if (form == 1)
  38. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  39. else if (form == 2)
  40. this.button2.Text = PdnResources.GetString("Form.OkButton.Text");
  41. }
  42. public GrainSizePointCountingMethodGridSaveDialog(List<string> grids, int form)
  43. {
  44. this.form = form;
  45. this.grids = grids;
  46. InitializeComponent();
  47. InitializeLanguageText();
  48. if (form == 1)
  49. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  50. else if (form == 2)
  51. this.button2.Text = PdnResources.GetString("Form.OkButton.Text");
  52. }
  53. #region 初始化
  54. private void InitializeLanguageText()
  55. {
  56. this.label1.Text = PdnResources.GetString("Menu.name.text") + ":";
  57. this.label2.Text = "------------------------------------------------------------";
  58. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  59. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  60. this.Text = PdnResources.GetString("Menu.Pleaseenteranameofthephase.text");
  61. }
  62. private void InitializeComponent()
  63. {
  64. this.label1 = new System.Windows.Forms.Label();
  65. this.textBox1 = new System.Windows.Forms.TextBox();
  66. this.label2 = new System.Windows.Forms.Label();
  67. this.button1 = new System.Windows.Forms.Button();
  68. this.button2 = new System.Windows.Forms.Button();
  69. this.SuspendLayout();
  70. //
  71. // label1
  72. //
  73. this.label1.AutoSize = true;
  74. this.label1.Location = new System.Drawing.Point(15, 19);
  75. this.label1.Name = "label1";
  76. this.label1.Size = new System.Drawing.Size(41, 12);
  77. this.label1.TabIndex = 0;
  78. //
  79. // textBox1
  80. //
  81. this.textBox1.Location = new System.Drawing.Point(61, 15);
  82. this.textBox1.Name = "textBox1";
  83. this.textBox1.Size = new System.Drawing.Size(277, 21);
  84. this.textBox1.TabIndex = 1;
  85. //
  86. // label2
  87. //
  88. this.label2.AutoSize = true;
  89. this.label2.Location = new System.Drawing.Point(-3, 49);
  90. this.label2.Name = "label2";
  91. this.label2.Size = new System.Drawing.Size(365, 12);
  92. this.label2.TabIndex = 2;
  93. //
  94. // button1
  95. //
  96. this.button1.BackColor = System.Drawing.SystemColors.Control;
  97. this.button1.Location = new System.Drawing.Point(182, 64);
  98. this.button1.Name = "button1";
  99. this.button1.Size = new System.Drawing.Size(75, 23);
  100. this.button1.TabIndex = 3;
  101. this.button1.UseVisualStyleBackColor = false;
  102. this.button1.Click += new System.EventHandler(this.button1_Click);
  103. //
  104. // button2
  105. //
  106. this.button2.BackColor = System.Drawing.SystemColors.Control;
  107. this.button2.Location = new System.Drawing.Point(263, 64);
  108. this.button2.Name = "button2";
  109. this.button2.Size = new System.Drawing.Size(75, 23);
  110. this.button2.TabIndex = 4;
  111. this.button2.UseVisualStyleBackColor = false;
  112. this.button2.Click += new System.EventHandler(this.button2_Click);
  113. //
  114. // GrainSizePointCountingMethodGridSaveDialog
  115. //
  116. this.ClientSize = new System.Drawing.Size(359, 93);
  117. this.Controls.Add(this.button2);
  118. this.Controls.Add(this.button1);
  119. this.Controls.Add(this.label2);
  120. this.Controls.Add(this.textBox1);
  121. this.Controls.Add(this.label1);
  122. this.MaximizeBox = false;
  123. this.MinimizeBox = false;
  124. this.Name = "GrainSizePointCountingMethodGridSaveDialog";
  125. this.ShowInTaskbar = false;
  126. this.ResumeLayout(false);
  127. this.PerformLayout();
  128. }
  129. #endregion
  130. /// <summary>
  131. /// 画面关闭
  132. /// </summary>
  133. /// <param name="sender"></param>
  134. /// <param name="e"></param>
  135. private void button1_Click(object sender, EventArgs e)
  136. {
  137. this.Close();
  138. }
  139. /// <summary>
  140. /// 保存网格
  141. /// </summary>
  142. /// <param name="sender"></param>
  143. /// <param name="e"></param>
  144. private void button2_Click(object sender, EventArgs e)
  145. {
  146. if (string.IsNullOrEmpty(this.textBox1.Text))
  147. {
  148. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenteragridname.text")+"!");
  149. this.textBox1.Focus();
  150. }
  151. else
  152. {
  153. GrainSizePointCountingMethodDialog grainSizePointCountingMethodDialog = (GrainSizePointCountingMethodDialog)this.Owner;
  154. if (this.form == 1)
  155. {
  156. if (this.grids != null)
  157. {
  158. if (this.grids.Contains(this.textBox1.Text))
  159. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  160. else
  161. {
  162. grainSizePointCountingMethodDialog.RefreshGridItems(this.textBox1.Text);
  163. //MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!");//##20598
  164. this.Close();
  165. }
  166. }
  167. else
  168. {
  169. grainSizePointCountingMethodDialog.RefreshGridItems(this.textBox1.Text);
  170. //MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!");//##20598
  171. this.Close();
  172. }
  173. }
  174. else if(this.form == 2)
  175. {
  176. if (this.grids != null)
  177. {
  178. if (this.grids.Contains(this.textBox1.Text))
  179. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  180. else
  181. {
  182. grainSizePointCountingMethodDialog.typeName = this.textBox1.Text;
  183. //MessageBox.Show(PdnResources.GetString("Menu.Addsuccessfully.text")+"!");//##20598
  184. this.Close();
  185. }
  186. }
  187. else
  188. {
  189. grainSizePointCountingMethodDialog.typeName = this.textBox1.Text;
  190. //MessageBox.Show(PdnResources.GetString("Menu.Addsuccessfully.text")+"!");//##20598
  191. this.Close();
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }