PopupTextBox.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Core.Mes.Client.Comm.Tool;
  2. using CoreFS.CA06;
  3. using System;
  4. using System.Text;
  5. using System.Windows.Forms;
  6. namespace Core.StlMes.Client.Judge.Forms
  7. {
  8. public partial class PopupTextBox : FrmBase
  9. {
  10. public string TextInfo
  11. {
  12. get { return txtInfo.Text.Trim(); }
  13. }
  14. private int _maxLength = 0;
  15. public PopupTextBox(string textInfo, int maxLength)
  16. {
  17. InitializeComponent();
  18. _maxLength = maxLength;
  19. this.txtInfo.Text = textInfo;
  20. }
  21. private void btnOk_Click(object sender, EventArgs e)
  22. {
  23. if (UnicodeEncoding.Unicode.GetBytes(this.txtInfo.Text.Trim()).Length > _maxLength)
  24. {
  25. MessageUtil.ShowWarning("输入的文本超出最大字符数限制!");
  26. return;
  27. }
  28. this.DialogResult = DialogResult.OK;
  29. }
  30. private void btnCancel_Click(object sender, EventArgs e)
  31. {
  32. this.DialogResult = DialogResult.Cancel;
  33. }
  34. private void txtInfo_KeyDown(object sender, KeyEventArgs e)
  35. {
  36. if (e.Control)
  37. {
  38. if (e.KeyCode == Keys.A)
  39. {
  40. txtInfo.SelectAll();
  41. }
  42. }
  43. }
  44. }
  45. }