DebugAlarmLightUI.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 DebugAlarmLightUI : UserControl,IDisplayUI
  15. {
  16. public DebugAlarmLightUI()
  17. {
  18. InitializeComponent();
  19. }
  20. public bool Init()
  21. {
  22. dataGridUI1.dataGridView1.CellClick += DataGridView1_CellClick;
  23. comboBox2.SelectedIndex = 0;
  24. return true;
  25. }
  26. private void DataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
  27. {
  28. textBox1.Text = dataGridUI1.GetCurrentColValue("DeviceId");
  29. }
  30. public void UpdateDisplay()
  31. {
  32. if (!this.Visible) return;
  33. var dataList = DeviceControl.Instance.Communication.InfoAlarmLightDictionary.Values.ToList();
  34. dataGridUI1.ShowDataGrid(dataList);
  35. }
  36. private void button1_Click(object sender, EventArgs e)
  37. {
  38. try
  39. {
  40. int deviceId = int.Parse(textBox1.Text);
  41. int code = int.Parse(comboBox2.Text);
  42. DeviceControl.Instance.SetAlarmLight(deviceId, code);
  43. }
  44. catch (Exception ex)
  45. {
  46. CLog.Instance.SystemLog.WriteException("UI", ex);
  47. MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  48. }
  49. }
  50. }
  51. }