ucManualOperateUnit.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.ComponentModel;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using Core.StlMes.Client.LgClassModel;
  6. using Infragistics.Win;
  7. namespace Core.StlMes.Client.LgCommon
  8. {
  9. public partial class ucManualOperateUnit : UserControl
  10. {
  11. private string _Caption = "";
  12. private CommandCollection Items = new CommandCollection();
  13. public string Caption
  14. {
  15. get
  16. {
  17. return _Caption;
  18. }
  19. set
  20. {
  21. if (!value.Equals(_Caption))
  22. {
  23. _Caption = value;
  24. ultraGroupBox1.Text = value;
  25. }
  26. }
  27. }
  28. [Browsable(false)]
  29. public COM_STL_COMMAND Value
  30. {
  31. get
  32. {
  33. if (ultraOptionSet1.CheckedItem == null) return null;
  34. else
  35. {
  36. string Key = Convert.ToString(ultraOptionSet1.CheckedItem.DataValue);
  37. COM_STL_COMMAND Item = Items[Key];
  38. return Item;
  39. }
  40. }
  41. }
  42. public int Count
  43. {
  44. get { return Items.Count; }
  45. }
  46. public ucManualOperateUnit()
  47. {
  48. InitializeComponent();
  49. this.Caption = "未命名";
  50. this.ClearItems();
  51. }
  52. public void Add(COM_STL_COMMAND Item)
  53. {
  54. COM_STL_COMMAND clc = Items.Add(Item);
  55. if (clc != null)
  56. {
  57. ultraOptionSet1.Items.Add(clc.ID_, clc.OPTCAPTION);
  58. }
  59. }
  60. public void ClearItems()
  61. {
  62. try
  63. {
  64. Items.Clear();
  65. ultraOptionSet1.Items.Clear();
  66. }
  67. catch { }
  68. }
  69. public void ClearSelection()
  70. {
  71. try
  72. {
  73. ultraOptionSet1.CheckedIndex = -1;
  74. }
  75. catch { }
  76. }
  77. private void ResetOthers(Control Parent)
  78. {
  79. foreach (Control ctrl in Parent.Controls)
  80. {
  81. try
  82. {
  83. if (ctrl.GetType().Equals(this.GetType()))
  84. {
  85. if (!ctrl.Equals(this))
  86. ((ucManualOperateUnit)ctrl).ClearSelection();
  87. }
  88. else
  89. {
  90. ResetOthers(ctrl);
  91. }
  92. }
  93. catch { }
  94. }
  95. }
  96. private void ultraOptionSet1_ValueChanged(object sender, EventArgs e)
  97. {
  98. for (int i = 0; i < ultraOptionSet1.Items.Count; i++)
  99. {
  100. try
  101. {
  102. if (ultraOptionSet1.Items[i].Equals(ultraOptionSet1.CheckedItem))
  103. {
  104. ultraOptionSet1.Items[i].Appearance.ForeColor = Color.Blue;
  105. ultraOptionSet1.Items[i].Appearance.FontData.Bold = DefaultableBoolean.True;
  106. }
  107. else
  108. {
  109. ultraOptionSet1.Items[i].Appearance.ResetForeColor();
  110. ultraOptionSet1.Items[i].Appearance.FontData.Bold = DefaultableBoolean.False;
  111. }
  112. }
  113. catch { }
  114. }
  115. try
  116. {
  117. if (ultraOptionSet1.CheckedIndex > -1)
  118. {
  119. Form frm = this.ParentForm;
  120. if (frm != null) ResetOthers(frm);
  121. }
  122. }
  123. catch { }
  124. }
  125. }
  126. }