BandedTissueSaveDialog.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. public partial class BandedTissueSaveDialog : Form
  14. {
  15. #region 控件
  16. private Label label1;
  17. private TextBox textBox1;
  18. private Button button1;
  19. private Button button2;
  20. private Label label2;
  21. #endregion
  22. /// <summary>
  23. /// 已有的网格
  24. /// </summary>
  25. private List<string> grids;
  26. public BandedTissueSaveDialog(List<string> grids)
  27. {
  28. this.grids = grids;
  29. InitializeComponent();
  30. InitializeLanguageText();
  31. }
  32. #region 初始化
  33. private void InitializeLanguageText()
  34. {
  35. this.label1.Text = PdnResources.GetString("Menu.name.text") + ":";
  36. this.label2.Text = "------------------------------------------------------------";
  37. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  38. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  39. this.Text = PdnResources.GetString("CommonAction.Save");
  40. }
  41. private void InitializeComponent()
  42. {
  43. this.label1 = new System.Windows.Forms.Label();
  44. this.textBox1 = new System.Windows.Forms.TextBox();
  45. this.label2 = new System.Windows.Forms.Label();
  46. this.button1 = new System.Windows.Forms.Button();
  47. this.button2 = new System.Windows.Forms.Button();
  48. this.SuspendLayout();
  49. //
  50. // label1
  51. //
  52. this.label1.AutoSize = true;
  53. this.label1.Location = new System.Drawing.Point(15, 19);
  54. this.label1.Name = "label1";
  55. this.label1.Size = new System.Drawing.Size(41, 12);
  56. this.label1.TabIndex = 0;
  57. //
  58. // textBox1
  59. //
  60. this.textBox1.Location = new System.Drawing.Point(61, 15);
  61. this.textBox1.Name = "textBox1";
  62. this.textBox1.Size = new System.Drawing.Size(277, 21);
  63. this.textBox1.TabIndex = 1;
  64. //
  65. // label2
  66. //
  67. this.label2.AutoSize = true;
  68. this.label2.Location = new System.Drawing.Point(-3, 49);
  69. this.label2.Name = "label2";
  70. this.label2.Size = new System.Drawing.Size(365, 12);
  71. this.label2.TabIndex = 2;
  72. //
  73. // button1
  74. //
  75. this.button1.BackColor = System.Drawing.SystemColors.Control;
  76. this.button1.Location = new System.Drawing.Point(182, 64);
  77. this.button1.Name = "button1";
  78. this.button1.Size = new System.Drawing.Size(75, 23);
  79. this.button1.TabIndex = 3;
  80. this.button1.UseVisualStyleBackColor = false;
  81. this.button1.Click += new System.EventHandler(this.button1_Click);
  82. //
  83. // button2
  84. //
  85. this.button2.BackColor = System.Drawing.SystemColors.Control;
  86. this.button2.Location = new System.Drawing.Point(263, 64);
  87. this.button2.Name = "button2";
  88. this.button2.Size = new System.Drawing.Size(75, 23);
  89. this.button2.TabIndex = 4;
  90. this.button2.UseVisualStyleBackColor = false;
  91. this.button2.Click += new System.EventHandler(this.button2_Click);
  92. //
  93. // BandedTissueSaveDialog
  94. //
  95. this.ClientSize = new System.Drawing.Size(359, 93);
  96. this.Controls.Add(this.button2);
  97. this.Controls.Add(this.button1);
  98. this.Controls.Add(this.label2);
  99. this.Controls.Add(this.textBox1);
  100. this.Controls.Add(this.label1);
  101. this.MaximizeBox = false;
  102. this.MinimizeBox = false;
  103. this.Name = "BandedTissueSaveDialog";
  104. this.ShowInTaskbar = false;
  105. this.ResumeLayout(false);
  106. this.PerformLayout();
  107. }
  108. #endregion
  109. /// <summary>
  110. /// 画面关闭
  111. /// </summary>
  112. /// <param name="sender"></param>
  113. /// <param name="e"></param>
  114. private void button1_Click(object sender, EventArgs e)
  115. {
  116. this.Close();
  117. }
  118. /// <summary>
  119. /// 保存网格
  120. /// </summary>
  121. /// <param name="sender"></param>
  122. /// <param name="e"></param>
  123. private void button2_Click(object sender, EventArgs e)
  124. {
  125. if (string.IsNullOrEmpty(this.textBox1.Text))
  126. {
  127. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenteragridname.text")+"!");
  128. this.textBox1.Focus();
  129. }
  130. else
  131. {
  132. BandedTissueDialog bandedTissueDialog = (BandedTissueDialog)this.Owner;
  133. if (this.grids != null)
  134. {
  135. if (this.grids.Contains(this.textBox1.Text))
  136. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  137. else
  138. {
  139. bandedTissueDialog.RefreshGridItems(this.textBox1.Text);
  140. this.Close();
  141. }
  142. }
  143. else
  144. {
  145. bandedTissueDialog.RefreshGridItems(this.textBox1.Text);
  146. this.Close();
  147. }
  148. }
  149. }
  150. }
  151. }