FormLogNetView.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.Windows.Forms;
  9. namespace HslCommunication.LogNet
  10. {
  11. /// <summary>
  12. /// 日志查看器的窗口类,用于分析统计日志数据
  13. /// </summary>
  14. public partial class FormLogNetView : Form
  15. {
  16. /// <summary>
  17. /// 实例化一个日志查看器的窗口
  18. /// </summary>
  19. public FormLogNetView()
  20. {
  21. InitializeComponent();
  22. }
  23. private void FormLogNetView_Load(object sender, EventArgs e)
  24. {
  25. }
  26. private void userButton1_Click(object sender, EventArgs e)
  27. {
  28. using (OpenFileDialog fDialog = new OpenFileDialog())
  29. {
  30. fDialog.Filter = "日志文件(*.txt)|*.txt";
  31. if (fDialog.ShowDialog() == DialogResult.OK)
  32. {
  33. textBox1.Text = fDialog.FileName;
  34. DealWithFileName(fDialog.FileName);
  35. }
  36. }
  37. }
  38. private void DealWithFileName(string fileName)
  39. {
  40. if (string.IsNullOrEmpty(fileName)) return;
  41. if (!System.IO.File.Exists(fileName))
  42. {
  43. MessageBox.Show("文件不存在!");
  44. return;
  45. }
  46. try
  47. {
  48. using (System.IO.StreamReader sr = new System.IO.StreamReader(fileName, Encoding.UTF8))
  49. {
  50. try
  51. {
  52. logNetAnalysisControl1.SetLogNetSource(sr.ReadToEnd());
  53. }
  54. catch (Exception ex)
  55. {
  56. BasicFramework.SoftBasic.ShowExceptionMessage(ex);
  57. }
  58. }
  59. }
  60. catch (Exception ex)
  61. {
  62. BasicFramework.SoftBasic.ShowExceptionMessage(ex);
  63. }
  64. }
  65. private void logNetAnalysisControl1_Load(object sender, EventArgs e)
  66. {
  67. }
  68. private void toolStripStatusLabel2_Click(object sender, EventArgs e)
  69. {
  70. try
  71. {
  72. System.Diagnostics.Process.Start("explorer.exe", "https://github.com/dathlin/C-S-");
  73. }
  74. catch
  75. {
  76. }
  77. }
  78. private void textBox1_KeyDown(object sender, KeyEventArgs e)
  79. {
  80. }
  81. }
  82. }