Xinzeng.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using SmartCoalApplication.Resources;
  2. using System;
  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. using Resources;
  12. namespace SmartCoalApplication.Setup
  13. {
  14. public partial class Xinzeng : Form
  15. {
  16. #region Windows Form Designer generated code
  17. /// <summary>
  18. /// Required method for Designer support - do not modify
  19. /// the contents of this method with the code editor.
  20. /// </summary>
  21. private void InitializeComponent()
  22. {
  23. this.label1 = new System.Windows.Forms.Label();
  24. this.textMingcheng = new System.Windows.Forms.TextBox();
  25. this.buttonSave = new System.Windows.Forms.Button();
  26. this.SuspendLayout();
  27. //
  28. // label1
  29. //
  30. this.label1.AutoSize = true;
  31. this.label1.Location = new System.Drawing.Point(24, 29);
  32. this.label1.Name = "label1";
  33. this.label1.Size = new System.Drawing.Size(41, 12);
  34. this.label1.TabIndex = 0;
  35. this.label1.Text = "名稱:";
  36. //
  37. // textMingcheng
  38. //
  39. this.textMingcheng.Location = new System.Drawing.Point(62, 26);
  40. this.textMingcheng.Name = "textMingcheng";
  41. this.textMingcheng.Size = new System.Drawing.Size(169, 21);
  42. this.textMingcheng.TabIndex = 1;
  43. //
  44. // buttonSave
  45. //
  46. this.buttonSave.Location = new System.Drawing.Point(106, 68);
  47. this.buttonSave.Name = "buttonSave";
  48. this.buttonSave.Size = new System.Drawing.Size(75, 23);
  49. this.buttonSave.TabIndex = 2;
  50. this.buttonSave.Text = "保存";
  51. this.buttonSave.UseVisualStyleBackColor = false;
  52. this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
  53. //
  54. // Xinzeng
  55. //
  56. this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
  57. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  58. this.ClientSize = new System.Drawing.Size(291, 103);
  59. this.Controls.Add(this.buttonSave);
  60. this.Controls.Add(this.textMingcheng);
  61. this.Controls.Add(this.label1);
  62. this.MaximizeBox = false;
  63. this.MinimizeBox = false;
  64. this.Name = "Xinzeng";
  65. this.Load += new System.EventHandler(this.Xinzeng_Load);
  66. this.ResumeLayout(false);
  67. this.PerformLayout();
  68. }
  69. #endregion
  70. private System.Windows.Forms.Label label1;
  71. private System.Windows.Forms.TextBox textMingcheng;
  72. private System.Windows.Forms.Button buttonSave;
  73. public Xinzeng(string chooseData,int type)
  74. {
  75. InitializeComponent();
  76. setLanguege();
  77. this.Text = type == 1 ? PdnResources.GetString("Xinzeng.Add") : PdnResources.GetString("Xinzeng.Edit");
  78. this.textMingcheng.Text = chooseData;
  79. this.Icon = PdnInfo.AppIcon;
  80. }
  81. private void Xinzeng_Load(object sender, EventArgs e)
  82. {
  83. }
  84. // 创建委托
  85. public delegate void TransferDataDelegate(string mingcheng);
  86. // 声明一个事件(本质是一个委托)
  87. public event TransferDataDelegate TransferEvent;
  88. private void setLanguege()
  89. {
  90. label1.Text = PdnResources.GetString("Xinzeng.Name");
  91. }
  92. private void buttonSave_Click(object sender, EventArgs e)
  93. {
  94. if (string.IsNullOrEmpty(textMingcheng.Text))
  95. MessageBox.Show(PdnResources.GetString("Xinzeng.NullName"));
  96. //单击按钮传递文本框中的数据
  97. else
  98. {
  99. TransferEvent(textMingcheng.Text);
  100. this.Close();// 关闭窗体
  101. }
  102. }
  103. }
  104. }