DebugCallBoxUI.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using ProjectManagementSystem.Common.Core;
  2. using ProjectManagementSystem.Common.Logger;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace ProjectManagementSystem.UI
  13. {
  14. public partial class DebugCallBoxUI : UserControl,IDisplayUI
  15. {
  16. public DebugCallBoxUI()
  17. {
  18. InitializeComponent();
  19. }
  20. public bool Init()
  21. {
  22. dataGridUI1.dataGridView1.CellClick += DataGridView1_CellClick;
  23. return true;
  24. }
  25. private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  26. {
  27. textBox1.Text = dataGridUI1.GetCurrentColValue("Route");
  28. }
  29. public void UpdateDisplay()
  30. {
  31. if (!this.Visible) return;
  32. var dataList = DeviceControl.Instance.Communication.InfoBoxDictionary.Values.ToList();
  33. dataGridUI1.ShowDataGrid(dataList);
  34. }
  35. private void button1_Click(object sender, EventArgs e)
  36. {
  37. CallBoxOpereate(DeviceControl.Instance.CallBoxQuery);
  38. }
  39. private void button2_Click(object sender, EventArgs e)
  40. {
  41. CallBoxOpereate(DeviceControl.Instance.CallBoxLightOff);
  42. }
  43. private void CallBoxOpereate(Action<int> action)
  44. {
  45. try
  46. {
  47. int deviceId = int.Parse(textBox1.Text);
  48. action(deviceId);
  49. }
  50. catch (Exception ex)
  51. {
  52. CLog.Instance.SystemLog.WriteException("UI", ex);
  53. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  54. }
  55. }
  56. }
  57. }