Form1.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using Monitor;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Net;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace centralController
  15. {
  16. public partial class centralController : Form
  17. {
  18. public centralController()
  19. {
  20. InitializeComponent();
  21. if (Monitor.Monitor.ins == null)
  22. {
  23. Monitor.Monitor.ins = new Monitor.Monitor(flowLayoutPanel1.Handle);
  24. Monitor.Monitor.ins.Start();
  25. }
  26. //进度条测试
  27. Task.Factory.StartNew(() =>
  28. {
  29. int temp = 0;
  30. while (true)
  31. {
  32. if (temp != Monitor.Monitor.initializeState)
  33. {
  34. temp = Monitor.Monitor.initializeState;
  35. progressBar1.Invoke(new Action(()=> { progressBar1.Value = temp * 20; }));
  36. }
  37. if (temp == 5) { break; }
  38. Thread.Sleep(200);
  39. }
  40. });
  41. }
  42. private void btn_exit_Click(object sender, EventArgs e)
  43. {
  44. DialogResult result = MessageBox.Show("确定退出系统吗?", "温馨提示", MessageBoxButtons.OKCancel);
  45. if (result.Equals(DialogResult.OK))
  46. {
  47. Monitor.Monitor.ins.Stop();
  48. Close();
  49. }
  50. }
  51. private void button1_Click(object sender, EventArgs e)
  52. {
  53. string ip = textBox1.Text;
  54. IPAddress temp;
  55. if (IPAddress.TryParse(ip, out temp))
  56. {
  57. string license = "";
  58. Task.Factory.StartNew(() =>
  59. {
  60. license = Monitor.Monitor.numMachineLinker.GetLicensePlate(1);
  61. if (textBox2.InvokeRequired)
  62. {
  63. textBox2.Invoke(new Action(() => { textBox2.Text = license; }));
  64. }
  65. else
  66. {
  67. textBox2.Text = license;
  68. }
  69. });
  70. }
  71. }
  72. }
  73. }