using SmartCoalApplication.Resources; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Resources; namespace SmartCoalApplication.Setup { public partial class Xinzeng : Form { #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textMingcheng = new System.Windows.Forms.TextBox(); this.buttonSave = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(24, 29); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 0; this.label1.Text = "名稱:"; // // textMingcheng // this.textMingcheng.Location = new System.Drawing.Point(62, 26); this.textMingcheng.Name = "textMingcheng"; this.textMingcheng.Size = new System.Drawing.Size(169, 21); this.textMingcheng.TabIndex = 1; // // buttonSave // this.buttonSave.Location = new System.Drawing.Point(106, 68); this.buttonSave.Name = "buttonSave"; this.buttonSave.Size = new System.Drawing.Size(75, 23); this.buttonSave.TabIndex = 2; this.buttonSave.Text = "保存"; this.buttonSave.UseVisualStyleBackColor = false; this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click); // // Xinzeng // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(291, 103); this.Controls.Add(this.buttonSave); this.Controls.Add(this.textMingcheng); this.Controls.Add(this.label1); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Xinzeng"; this.Load += new System.EventHandler(this.Xinzeng_Load); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textMingcheng; private System.Windows.Forms.Button buttonSave; public Xinzeng(string chooseData,int type) { InitializeComponent(); setLanguege(); this.Text = type == 1 ? PdnResources.GetString("Xinzeng.Add") : PdnResources.GetString("Xinzeng.Edit"); this.textMingcheng.Text = chooseData; this.Icon = PdnInfo.AppIcon; } private void Xinzeng_Load(object sender, EventArgs e) { } // 创建委托 public delegate void TransferDataDelegate(string mingcheng); // 声明一个事件(本质是一个委托) public event TransferDataDelegate TransferEvent; private void setLanguege() { label1.Text = PdnResources.GetString("Xinzeng.Name"); } private void buttonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textMingcheng.Text)) MessageBox.Show(PdnResources.GetString("Xinzeng.NullName")); //单击按钮传递文本框中的数据 else { TransferEvent(textMingcheng.Text); this.Close();// 关闭窗体 } } } }