LabelListChangeName.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using PaintDotNet;
  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. namespace Metis.ImageLabel
  12. {
  13. public partial class LabelListChangeName : PdnBaseForm
  14. {
  15. private TextBox textBox1;
  16. private Button button1;
  17. private Label label1;
  18. // 创建委托
  19. public delegate void TransferDataDelegate(string name);
  20. // 声明一个事件(本质是一个委托)
  21. public event TransferDataDelegate TransferEvent;
  22. public LabelListChangeName()
  23. {
  24. this.StartPosition = FormStartPosition.CenterParent;
  25. InitializeComponent();
  26. }
  27. private void InitializeComponent()
  28. {
  29. this.label1 = new System.Windows.Forms.Label();
  30. this.textBox1 = new System.Windows.Forms.TextBox();
  31. this.button1 = new System.Windows.Forms.Button();
  32. this.SuspendLayout();
  33. //
  34. // label1
  35. //
  36. this.label1.AutoSize = true;
  37. this.label1.Location = new System.Drawing.Point(31, 60);
  38. this.label1.Name = "label1";
  39. this.label1.Size = new System.Drawing.Size(41, 12);
  40. this.label1.TabIndex = 0;
  41. this.label1.Text = "名称:";
  42. //
  43. // textBox1
  44. //
  45. this.textBox1.Location = new System.Drawing.Point(78, 57);
  46. this.textBox1.Name = "textBox1";
  47. this.textBox1.Size = new System.Drawing.Size(202, 21);
  48. this.textBox1.TabIndex = 1;
  49. //
  50. // button1
  51. //
  52. this.button1.Location = new System.Drawing.Point(124, 99);
  53. this.button1.Name = "button1";
  54. this.button1.Size = new System.Drawing.Size(75, 23);
  55. this.button1.TabIndex = 2;
  56. this.button1.Text = "确定";
  57. this.button1.UseVisualStyleBackColor = true;
  58. this.button1.Click += new System.EventHandler(this.button1_Click);
  59. //
  60. // LabelListChangeName
  61. //
  62. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  63. this.ClientSize = new System.Drawing.Size(323, 134);
  64. this.Controls.Add(this.button1);
  65. this.Controls.Add(this.textBox1);
  66. this.Controls.Add(this.label1);
  67. this.MaximizeBox = false;
  68. this.MinimizeBox = false;
  69. this.Name = "LabelListChangeName";
  70. this.Text = "标注信息";
  71. this.Controls.SetChildIndex(this.label1, 0);
  72. this.Controls.SetChildIndex(this.textBox1, 0);
  73. this.Controls.SetChildIndex(this.button1, 0);
  74. this.ResumeLayout(false);
  75. this.PerformLayout();
  76. }
  77. /// <summary>
  78. /// 确定
  79. /// </summary>
  80. /// <param name="sender"></param>
  81. /// <param name="e"></param>
  82. private void button1_Click(object sender, EventArgs e)
  83. {
  84. if (string.IsNullOrEmpty(textBox1.Text))
  85. MessageBox.Show("名称不能為空");
  86. else
  87. {
  88. TransferEvent(textBox1.Text);
  89. this.Close();// 关闭窗体
  90. }
  91. }
  92. }
  93. }