AddSampleStageDialog.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.AutoAnalysis
  12. {
  13. public partial class AddSampleStageDialog : Form
  14. {
  15. Dictionary<string, SampleStageModel> _list;
  16. public AddSampleStageDialog(Dictionary<string, SampleStageModel> list)
  17. {
  18. InitializeComponent();
  19. _list = list;
  20. this.Load += (s, e) => InitializeText();
  21. }
  22. public void InitializeText()
  23. {
  24. this.Text = PdnResources.GetString("AutoAnalysis.StageNameModify");
  25. groupBox1.Text = PdnResources.GetString("AutoAnalysis.StageName");
  26. groupBox2.Text = PdnResources.GetString("AutoAnalysis.Operate");
  27. label1.Text = PdnResources.GetString("AutoAnalysis.Name");
  28. button1.Text = PdnResources.GetString("AutoAnalysis.Button.OK");
  29. button2.Text = PdnResources.GetString("AutoAnalysis.Button.Cancel");
  30. }
  31. public Action<string> CallBack;
  32. private void button1_Click(object sender, EventArgs e)
  33. {
  34. var name = textBox1.Text.Trim();
  35. if (!string.IsNullOrEmpty(name))
  36. {
  37. if (_list.Keys.Contains(name))
  38. {
  39. MessageBox.Show("重复命名");
  40. }
  41. else
  42. {
  43. CallBack.Invoke(name);
  44. Close();
  45. }
  46. }
  47. else
  48. {
  49. MessageBox.Show("名字不能为空");
  50. }
  51. }
  52. private void button2_Click(object sender, EventArgs e)
  53. {
  54. Close();
  55. }
  56. }
  57. }