IoDataView.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. namespace Aitex.Core.Backend
  10. {
  11. public partial class IoDataView : UserControl
  12. {
  13. public IoDataView()
  14. {
  15. InitializeComponent();
  16. _views.Add(_diView);
  17. _views.Add(_doView);
  18. _views.Add(_aiView);
  19. _views.Add(_aoView);
  20. foreach (var item in _views)
  21. {
  22. item.Hide();
  23. this.splitContainer1.Panel2.Controls.Add(item);
  24. }
  25. _diView.Show();
  26. }
  27. List<UserControl> _views = new List<UserControl>();
  28. DI _diView = new DI();
  29. DO _doView = new DO();
  30. AI _aiView = new AI();
  31. AO _aoView = new AO();
  32. /// <summary>
  33. /// 切换仿真子界面
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="e"></param>
  37. private void rbtBath_CheckedChanged(object sender, EventArgs e)
  38. {
  39. var rbt = (RadioButton)sender;
  40. if (rbt.Checked)
  41. {
  42. foreach (var usc in _views) usc.Hide();
  43. switch (rbt.Text)
  44. {
  45. case "DI": _diView.Show(); break;
  46. case "DO": _doView.Show(); break;
  47. case "AI": _aiView.Show(); break;
  48. case "AO": _aoView.Show(); break;
  49. }
  50. }
  51. foreach (RadioButton bt in splitContainer1.Panel1.Controls)
  52. {
  53. if(bt != null)
  54. bt.BackColor = (rbt == bt) ? Color.Green : Color.LightCyan;
  55. }
  56. }
  57. public void Close()
  58. {
  59. ((IIOView)_diView).Close();
  60. ((IIOView)_doView).Close();
  61. ((IIOView)_aiView).Close();
  62. ((IIOView)_aoView).Close();
  63. }
  64. }
  65. }