| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System;
- using System.ComponentModel;
- using System.Drawing;
- using System.Windows.Forms;
- using Core.StlMes.Client.LgClassModel;
- using Infragistics.Win;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class ucManualOperateUnit : UserControl
- {
- private string _Caption = "";
- private CommandCollection Items = new CommandCollection();
- public string Caption
- {
- get
- {
- return _Caption;
- }
- set
- {
- if (!value.Equals(_Caption))
- {
- _Caption = value;
- ultraGroupBox1.Text = value;
- }
- }
- }
- [Browsable(false)]
- public COM_STL_COMMAND Value
- {
- get
- {
- if (ultraOptionSet1.CheckedItem == null) return null;
- else
- {
- string Key = Convert.ToString(ultraOptionSet1.CheckedItem.DataValue);
- COM_STL_COMMAND Item = Items[Key];
- return Item;
- }
- }
- }
- public int Count
- {
- get { return Items.Count; }
- }
- public ucManualOperateUnit()
- {
- InitializeComponent();
- this.Caption = "未命名";
- this.ClearItems();
- }
- public void Add(COM_STL_COMMAND Item)
- {
- COM_STL_COMMAND clc = Items.Add(Item);
- if (clc != null)
- {
- ultraOptionSet1.Items.Add(clc.ID_, clc.OPTCAPTION);
- }
- }
- public void ClearItems()
- {
- try
- {
- Items.Clear();
- ultraOptionSet1.Items.Clear();
- }
- catch { }
- }
- public void ClearSelection()
- {
- try
- {
- ultraOptionSet1.CheckedIndex = -1;
- }
- catch { }
- }
- private void ResetOthers(Control Parent)
- {
- foreach (Control ctrl in Parent.Controls)
- {
- try
- {
- if (ctrl.GetType().Equals(this.GetType()))
- {
- if (!ctrl.Equals(this))
- ((ucManualOperateUnit)ctrl).ClearSelection();
- }
- else
- {
- ResetOthers(ctrl);
- }
- }
- catch { }
- }
- }
- private void ultraOptionSet1_ValueChanged(object sender, EventArgs e)
- {
- for (int i = 0; i < ultraOptionSet1.Items.Count; i++)
- {
- try
- {
- if (ultraOptionSet1.Items[i].Equals(ultraOptionSet1.CheckedItem))
- {
- ultraOptionSet1.Items[i].Appearance.ForeColor = Color.Blue;
- ultraOptionSet1.Items[i].Appearance.FontData.Bold = DefaultableBoolean.True;
- }
- else
- {
- ultraOptionSet1.Items[i].Appearance.ResetForeColor();
- ultraOptionSet1.Items[i].Appearance.FontData.Bold = DefaultableBoolean.False;
- }
- }
- catch { }
- }
- try
- {
- if (ultraOptionSet1.CheckedIndex > -1)
- {
- Form frm = this.ParentForm;
- if (frm != null) ResetOthers(frm);
- }
- }
- catch { }
- }
- }
- }
|