DICtrl.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Aitex.Core.RT.Simulator;
  10. namespace Aitex.Core.Backend
  11. {
  12. public partial class DICtrl : UserControl
  13. {
  14. private string _ioName;
  15. private bool _rawValue;
  16. public DICtrl()
  17. {
  18. InitializeComponent();
  19. this.Load += DICtrl_Load;
  20. }
  21. private void DICtrl_Load(object sender, EventArgs e)
  22. {
  23. }
  24. public void SetIoName(string group, string ioName)
  25. {
  26. _ioName = ioName;
  27. }
  28. public void SetName(string name)
  29. {
  30. this.labelRaw.Text = name;
  31. }
  32. public void SetValue(bool latchedValue, bool rawValue)
  33. {
  34. _rawValue = rawValue;
  35. this.labelRaw.BackColor = rawValue ? Color.Lime : Color.LightGray;
  36. }
  37. private void labelName_Click(object sender, EventArgs e)
  38. {
  39. }
  40. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  41. {
  42. if (checkBox1.Checked)
  43. {
  44. checkBox2.Checked = _rawValue;
  45. DiForce.Instance.Set(_ioName, checkBox2.Checked);
  46. checkBox2.Enabled = true;
  47. this.BackColor = Color.DodgerBlue;
  48. }
  49. else
  50. {
  51. DiForce.Instance.Unset(_ioName);
  52. checkBox2.Enabled = false;
  53. this.BackColor = Color.White;
  54. }
  55. }
  56. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  57. {
  58. DiForce.Instance.Set(_ioName, checkBox2.Checked);
  59. }
  60. }
  61. }