ModifySampleStageDialog.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace Metis.AutoAnalysis
  11. {
  12. public partial class ModifySampleStageDialog : Form
  13. {
  14. Dictionary<string, SampleStageModel> _list;
  15. string _name;
  16. public ModifySampleStageDialog(Dictionary<string, SampleStageModel> list, string name)
  17. {
  18. InitializeComponent();
  19. textBox1.Text = name;
  20. _list = list;
  21. _name = name;
  22. }
  23. public Action<string> CallBack;
  24. private void button1_Click(object sender, EventArgs e)
  25. {
  26. var name = textBox1.Text.Trim();
  27. if (!string.IsNullOrEmpty(name))
  28. {
  29. if (_name == name)
  30. Close();
  31. else if (_list.Keys.Contains(name))
  32. {
  33. MessageBox.Show("重复命名");
  34. }
  35. else
  36. {
  37. CallBack.Invoke(name);
  38. Close();
  39. }
  40. }
  41. else
  42. {
  43. MessageBox.Show("名字不能为空");
  44. }
  45. }
  46. private void button2_Click(object sender, EventArgs e)
  47. {
  48. Close();
  49. }
  50. }
  51. }