SimulatorView.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.Forms;
  11. using System.Windows.Shapes;
  12. using Aitex.Core.RT.SCCore;
  13. using Aitex.Core.RT.Simulator;
  14. namespace Aitex.Core.Backend
  15. {
  16. public partial class SimulatorView : UserControl
  17. {
  18. //<GroupName, <Name, Description>>
  19. private Dictionary<string, Dictionary<string, string>> _caseGroup = new Dictionary<string, Dictionary<string, string>>();
  20. public SimulatorView()
  21. {
  22. InitializeComponent();
  23. }
  24. private void SimulatorView_Load(object sender, EventArgs e)
  25. {
  26. this.Dock = DockStyle.Fill;
  27. //btnSetSimulation.Enabled = false;
  28. //ckInSimulationMode.Checked = SC.GetValue<bool>(SCName.System_IsSimulatorMode);
  29. foreach (var propertyInfo in typeof(ExceptionCase).GetProperties())
  30. {
  31. foreach (var attr in propertyInfo.GetCustomAttributes(false))
  32. {
  33. var display = attr as DisplayAttribute;
  34. if (display == null)
  35. continue;
  36. if (!_caseGroup.ContainsKey(display.GroupName))
  37. {
  38. _caseGroup[display.GroupName] = new Dictionary<string, string>();
  39. TextBox tb = new TextBox();
  40. tb.ReadOnly = true;
  41. tb.Enabled = false;
  42. tb.Text = display.GroupName;
  43. tb.TextAlign = HorizontalAlignment.Center;
  44. tb.BackColor = System.Drawing.SystemColors.MenuHighlight;
  45. tb.Location = new System.Drawing.Point(3, 3);
  46. tb.Size = new System.Drawing.Size(262, 35);
  47. tb.TabIndex = 0;
  48. this.flowLayoutPanel1.Controls.Add(tb);
  49. }
  50. _caseGroup[display.GroupName][propertyInfo.Name] = display.Description;
  51. CheckBox cb = new CheckBox();
  52. cb.AutoSize = true;
  53. cb.Location = new System.Drawing.Point(16, 34);
  54. cb.Name = "ck" + propertyInfo.Name;
  55. cb.Size = new System.Drawing.Size(126, 16);
  56. cb.TabIndex = 1;
  57. cb.Text = display.Description;
  58. cb.UseVisualStyleBackColor = true;
  59. cb.CheckedChanged += new System.EventHandler(this.cbCheckedChanged);
  60. cb.Tag = propertyInfo;
  61. this.flowLayoutPanel1.Controls.Add(cb);
  62. }
  63. }
  64. }
  65. private void cbCheckedChanged(object sender, EventArgs e)
  66. {
  67. CheckBox cb = sender as CheckBox;
  68. PropertyInfo property = cb.Tag as PropertyInfo;
  69. property.SetValue(null, cb.Checked, null);
  70. }
  71. }
  72. }