frmVoice.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. internal void LoadVoiceInfo()
  74. {
  75. List<MeterBaseVideoChild> lt = PbCache.videoChild;
  76. List<loginParam> lp = new List<loginParam>();
  77. 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 });
  78. LoadVoice(lp);
  79. this.Hide();
  80. }
  81. private void frmVoice_Load(object sender, EventArgs e)
  82. {
  83. }
  84. private void frmVoice_FormClosing(object sender, FormClosingEventArgs e)
  85. {
  86. try
  87. {
  88. LogOut();
  89. }
  90. catch { }
  91. }
  92. }
  93. }