F_Log.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. 
  2. using System;
  3. using System.Windows.Forms;
  4. using PLC_S;
  5. namespace PLC_WF
  6. {
  7. public partial class F_Log : Form, IFormLogShow
  8. {
  9. public F_Log()
  10. {
  11. InitializeComponent();
  12. }
  13. public IShowFormLog ShowFormLog
  14. {
  15. get;
  16. set;
  17. }
  18. private void tsbWarp_Click(object sender, EventArgs e)
  19. {
  20. this.txtLog.WordWrap = !this.txtLog.WordWrap;
  21. if (this.txtLog.WordWrap)
  22. {
  23. this.tsbWarp.Text = "√折行";
  24. }
  25. else
  26. {
  27. this.tsbWarp.Text = " 折行";
  28. }
  29. }
  30. private void tsbClear_Click(object sender, EventArgs e)
  31. {
  32. this.txtLog.Text = null;
  33. }
  34. public void ShowLog(string log)
  35. {
  36. if (this.InvokeRequired)
  37. {
  38. this.BeginInvoke(new Action<string>(ShowLog), log);
  39. return;
  40. }
  41. this.txtLog.Text += log + System.Environment.NewLine;
  42. this.txtLog.SelectionStart = this.txtLog.Text.Length;
  43. this.txtLog.ScrollToCaret();
  44. }
  45. private void F_Log_FormClosed(object sender, FormClosedEventArgs e)
  46. {
  47. if (ShowFormLog != null)
  48. {
  49. ShowFormLog.FormLogShow = null;
  50. }
  51. }
  52. }
  53. }