QuantitativeAnalysisGridSaveDialog.cs 5.1 KB

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