ModifySampleStageDialog.cs 2.0 KB

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