DebugForm.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. button_DebugDisplay.BackColor = Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(215)))), ((int)(((byte)(0)))));
  41. }
  42. else
  43. {
  44. mainForm.mainform1.DebugDataDisplayEnable = false;
  45. button_DebugDisplay.Text = "开始实时显示";
  46. button_DebugDisplay.BackColor = Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(113)))), ((int)(((byte)(185)))));
  47. }
  48. }
  49. private void richTextBox_DebugRev_TextChanged(object sender, EventArgs e)
  50. {
  51. richTextBox_DebugRev.SelectionStart = richTextBox_DebugRev.Text.Length;
  52. richTextBox_DebugRev.ScrollToCaret();
  53. }
  54. private void richTextBox_DebugSend_TextChanged(object sender, EventArgs e)
  55. {
  56. richTextBox_DebugSend.SelectionStart = richTextBox_DebugSend.Text.Length;
  57. richTextBox_DebugSend.ScrollToCaret();
  58. }
  59. private void button_DebugExport_Click(object sender, EventArgs e)
  60. {
  61. SaveFileDialog sf = new SaveFileDialog();
  62. sf.Title = "数据导出";
  63. sf.FileName = "Rev_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss").Replace("/", "-").Replace(":", string.Empty).Replace(" ", "_") + ".txt";
  64. sf.Filter = "文本文件|*.txt";
  65. if (sf.ShowDialog() == DialogResult.OK)
  66. {
  67. richTextBox_DebugRev.SaveFile(sf.FileName, RichTextBoxStreamType.PlainText);
  68. }
  69. }
  70. }
  71. }