DebugForm.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace Welling_Motor_Debug_Tool
  12. {
  13. public partial class DebugForm : Form
  14. {
  15. public static DebugForm debug1 = null;
  16. public DebugForm()
  17. {
  18. InitializeComponent();
  19. }
  20. private void DebugForm_Load(object sender, EventArgs e)
  21. {
  22. }
  23. private void DebugForm_FormClosed(object sender, FormClosedEventArgs e)
  24. {
  25. mainForm.mainform1.指令调试ToolStripMenuItem.Checked = false;
  26. mainForm.mainform1.DebugWindowIsOpen = false;
  27. mainForm.mainform1.DebugDataDisplayEnable = false;
  28. }
  29. private void button_DebugClear_Click(object sender, EventArgs e)
  30. {
  31. richTextBox_DebugRev.Clear();
  32. richTextBox_DebugSend.Clear();
  33. }
  34. private void button_DebugDisplay_Click(object sender, EventArgs e)
  35. {
  36. if (button_DebugDisplay.Text == "开始实时显示")
  37. {
  38. mainForm.mainform1.DebugDataDisplayEnable = true;
  39. button_DebugDisplay.Text = "停止实时显示";
  40. }
  41. else
  42. {
  43. mainForm.mainform1.DebugDataDisplayEnable = false;
  44. button_DebugDisplay.Text = "开始实时显示";
  45. }
  46. }
  47. private void richTextBox_DebugRev_TextChanged(object sender, EventArgs e)
  48. {
  49. richTextBox_DebugRev.SelectionStart = richTextBox_DebugRev.Text.Length;
  50. richTextBox_DebugRev.ScrollToCaret();
  51. }
  52. private void richTextBox_DebugSend_TextChanged(object sender, EventArgs e)
  53. {
  54. richTextBox_DebugSend.SelectionStart = richTextBox_DebugSend.Text.Length;
  55. richTextBox_DebugSend.ScrollToCaret();
  56. }
  57. private void button_DebugExport_Click(object sender, EventArgs e)
  58. {
  59. SaveFileDialog sf = new SaveFileDialog();
  60. sf.Title = "数据导出";
  61. sf.FileName = "Rev_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_") + ".txt";
  62. sf.Filter = "文本文件|*.txt";
  63. if (sf.ShowDialog() == DialogResult.OK)
  64. {
  65. richTextBox_DebugRev.SaveFile(sf.FileName, RichTextBoxStreamType.PlainText);
  66. }
  67. }
  68. }
  69. }