InputValue.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 OTSExtremum
  11. {
  12. public partial class InputValue : Form
  13. {
  14. public InputValue()
  15. {
  16. InitializeComponent();
  17. }
  18. public delegate void TextEventHandler(string strText);
  19. public TextEventHandler TextHandler;
  20. private void btnOK_Click(object sender, EventArgs e)
  21. {
  22. if (null != TextHandler)
  23. {
  24. TextHandler.Invoke(txtString.Text);
  25. DialogResult = DialogResult.OK;
  26. }
  27. }
  28. private void btnCancel_Click(object sender, EventArgs e)
  29. {
  30. DialogResult = DialogResult.Cancel;
  31. }
  32. private void txtString_KeyPress(object sender, KeyPressEventArgs e)
  33. {
  34. if (Keys.Enter == (Keys)e.KeyChar)
  35. {
  36. if (null != TextHandler)
  37. {
  38. TextHandler.Invoke(txtString.Text);
  39. DialogResult = DialogResult.OK;
  40. }
  41. }
  42. }
  43. }
  44. }