SystemConfigView.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.Drawing;
  6. using System.Data;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Windows.Controls;
  11. using System.Windows.Forms;
  12. using Aitex.Core.RT.Log;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.RT.Simulator;
  15. using CheckBox = System.Windows.Forms.CheckBox;
  16. using TextBox = System.Windows.Forms.TextBox;
  17. using UserControl = System.Windows.Forms.UserControl;
  18. namespace Aitex.Core.Backend
  19. {
  20. public partial class SystemConfigView : UserControl
  21. {
  22. //<scname, type>
  23. private Dictionary<string, Type> _scItems = new Dictionary<string, Type>();
  24. public SystemConfigView()
  25. {
  26. InitializeComponent();
  27. }
  28. private void SystemConfigView_Load(object sender, EventArgs e)
  29. {
  30. this.Dock = DockStyle.Fill;
  31. //Dictionary<string, object> items = new Dictionary<string, object>();
  32. //List<string> groups = new List<string>();
  33. //foreach (FieldInfo field in typeof(SCName).GetFields())
  34. //{
  35. // var group = field.Name.Split('_')[0];
  36. // var name = field.Name.Split('_')[1];
  37. // if (!groups.Contains(group))
  38. // {
  39. // groups.Add(group);
  40. // TextBox tb = new TextBox();
  41. // tb.ReadOnly = true;
  42. // tb.Enabled = false;
  43. // tb.Text = group;
  44. // tb.TextAlign = HorizontalAlignment.Center;
  45. // tb.BackColor = System.Drawing.SystemColors.MenuHighlight;
  46. // tb.Location = new System.Drawing.Point(3, 3);
  47. // tb.Size = new System.Drawing.Size(262, 35);
  48. // tb.TabIndex = 0;
  49. // this.flowLayoutPanel1.Controls.Add(tb);
  50. // }
  51. // _scItems[name] = typeof(string);
  52. // TextBox tbName = new TextBox();
  53. // tbName.Location = new System.Drawing.Point(3, 3);
  54. // tbName.ReadOnly = true;
  55. // tbName.Size = new System.Drawing.Size(268, 21);
  56. // tbName.Text = name;
  57. // tbName.Tag = field.Name;
  58. // TextBox tbValue = new TextBox();
  59. // tbValue.Location = new System.Drawing.Point(3, 3);
  60. // tbValue.Size = new System.Drawing.Size(168, 21);
  61. // tbValue.Text = SC.GetItemValue(field.Name).ToString();
  62. // tbValue.Name = "tb" + field.Name;
  63. // System.Windows.Forms.Button bt = new System.Windows.Forms.Button();
  64. // bt.Location = new System.Drawing.Point(710, 3);
  65. // bt.Size = new System.Drawing.Size(75, 23);
  66. // bt.Text = "Set";
  67. // bt.UseVisualStyleBackColor = true;
  68. // bt.Click += bt_Click;
  69. // bt.Name = "bt" + field.Name;
  70. // bt.Tag = field.Name;
  71. // FlowLayoutPanel fl = new FlowLayoutPanel();
  72. // fl.Controls.Add(tbName);
  73. // fl.Controls.Add(tbValue);
  74. // fl.Controls.Add(bt);
  75. // fl.Location = new System.Drawing.Point(3, 3);
  76. // fl.Size = new System.Drawing.Size(853, 33);
  77. // this.flowLayoutPanel1.Controls.Add(fl);
  78. //}
  79. }
  80. void bt_Click(object sender, EventArgs e)
  81. {
  82. System.Windows.Forms.Button bt = sender as System.Windows.Forms.Button;
  83. FlowLayoutPanel fl = bt.Parent as FlowLayoutPanel;
  84. TextBox tbName = new TextBox();
  85. TextBox tbValue = new TextBox();
  86. foreach (var v in fl.Controls)
  87. {
  88. TextBox tb = v as TextBox;
  89. if (tb == null)
  90. continue;
  91. if (tb.ReadOnly)
  92. tbName = tb;
  93. else
  94. {
  95. tbValue = tb;
  96. }
  97. }
  98. SC.SetItemValue(bt.Tag.ToString(), tbValue.Text);
  99. }
  100. private void button1_Click(object sender, EventArgs e)
  101. {
  102. //foreach (var panel in flowLayoutPanel1.Controls)
  103. //{
  104. // if (panel.GetType() != typeof(FlowLayoutPanel))
  105. // continue;
  106. // TextBox tbName = new TextBox();
  107. // TextBox tbValue = new TextBox();
  108. // FlowLayoutPanel fl = panel as FlowLayoutPanel;
  109. // foreach (var v in fl.Controls)
  110. // {
  111. // TextBox tb = v as TextBox;
  112. // if (tb == null)
  113. // continue;
  114. // if (tb.ReadOnly)
  115. // tbName = tb;
  116. // else
  117. // {
  118. // tbValue = tb;
  119. // }
  120. // }
  121. // tbValue.Text = SC.GetItemValue(tbName.Tag as string).ToString();
  122. //}
  123. }
  124. }
  125. }