frmVoice.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using Common;
  2. using MeterPlugInLibrary;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace CarMeterSystem
  15. {
  16. public partial class frmVoice : Form
  17. {
  18. public frmVoice()
  19. {
  20. InitializeComponent();
  21. }
  22. List<CamerEs> lc = new List<CamerEs>();
  23. private void LoadVoice(List<loginParam> lt)
  24. {
  25. int i = 1;
  26. foreach (loginParam lp in lt)
  27. {
  28. CamerEs c = new CamerEs(lp);
  29. PictureBox pb = new PictureBox();
  30. pb.Name = $"pb{i++}";
  31. pb.Height = 100;
  32. pb.BackColor = Color.Black;
  33. pb.Dock = DockStyle.Top;
  34. flowLayoutPanel1.Controls.Add(pb);
  35. c.Login(pb);
  36. lc.Add(c);
  37. }
  38. }
  39. public void LogOut()
  40. {
  41. foreach (CamerEs lp in lc)
  42. {
  43. lp.LoginOut();
  44. }
  45. }
  46. /// <summary>
  47. /// 传入了值,则按传入的路径及Ip进行截图,否则则全部截图
  48. /// </summary>
  49. /// <param name="imgUrl"></param>
  50. /// <param name="ip"></param>
  51. public void CapturePictrue(string actualFirstNo, string imgUrl = default, string ip = default)
  52. {
  53. string strUrl = imgUrl ?? PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, 1);
  54. lc[0]?.CapturePictrue(strUrl);
  55. /*
  56. * 只截取第一张图片
  57. if (!string.IsNullOrEmpty(ip))
  58. {
  59. string strUrl = imgUrl ?? PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.jpg", PbCache.sportInfo.baseSpotNo, "C" + actualFirstNo, 1);
  60. lc.Where(s => s._lg?.ip == ip).FirstOrDefault()?.CapturePictrue(strUrl);
  61. }
  62. else
  63. {
  64. string strUrl = imgUrl ?? $"{Environment.CurrentDirectory}/imgShort/formalImg";
  65. int i = 1;
  66. foreach (CamerEs lp in lc)
  67. {
  68. //lp.CapturePictrue($"{strUrl}/{DateTime.Now.ToString("yyyyMMddHHmmss")}_{i++}.jpg");
  69. }
  70. }
  71. */
  72. }
  73. /// <summary>
  74. /// 传入了值,则按传入的路径及Ip进行截图,否则则全部截图
  75. /// </summary>
  76. /// <param name="imgUrl"></param>
  77. /// <param name="ip"></param>
  78. public void SaveRealData(string actualFirstNo)
  79. {
  80. string strUrl = PbCache.path + string.Format("\\imgShort\\formalImg\\{0}_{1}_{2}.3gp", PbCache.sportInfo.baseSpotNo, "V" + actualFirstNo, 1);
  81. lc[0]?.SaveRealData(strUrl);
  82. }
  83. /// <summary>
  84. /// 传入了值,则按传入的路径及Ip进行截图,否则则全部截图
  85. /// </summary>
  86. /// <param name="imgUrl"></param>
  87. /// <param name="ip"></param>
  88. public void StopRealData()
  89. {
  90. lc[0]?.StopRealData();
  91. }
  92. internal void LoadVoiceInfo()
  93. {
  94. List<MeterBaseVideoChild> lt = PbCache.videoChild;
  95. List<loginParam> lp = new List<loginParam>();
  96. lp.Add(new loginParam { ip = lt[0].p_ip, port = int.Parse(lt[0].vdo_port), userId = lt[0].vdo_user, pwd = lt[0].vdo_pwd });
  97. LoadVoice(lp);
  98. this.Hide();
  99. }
  100. private void frmVoice_Load(object sender, EventArgs e)
  101. {
  102. }
  103. private void frmVoice_FormClosing(object sender, FormClosingEventArgs e)
  104. {
  105. try
  106. {
  107. LogOut();
  108. }
  109. catch { }
  110. }
  111. }
  112. }