using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace SystemX.Product.TRA.UIControl { public partial class FrmOptionOverview : Form { OverviewSearchOption Option { get; set; } = new OverviewSearchOption(); public FrmOptionOverview() { InitializeComponent(); } public OverviewSearchOption GetSelectedResult() { return Option; } void DispData() { string strTypeName = "SystemX.Product.TRA.UIControl.OverviewSearchOption"; try { Type typeObj = Type.GetType(strTypeName); foreach(PropertyInfo info in typeObj.GetProperties()) { if (info.PropertyType == typeof(string)) continue; string strProp = info.Name; string strValue = info.GetValue(Option, null).ToString(); bool bState = Convert.ToBoolean(strValue); checkedListBoxControlOption.Items.Add(strProp, bState ? CheckState.Checked : CheckState.Unchecked, true); } } catch(Exception ex) { MessageBox.Show("Error during option display: " + ex.Message); } } private void FrmOptionStationSearch_Load(object sender, EventArgs e) { DispData(); } private void simpleButtonOK_Click(object sender, EventArgs e) { string strTypeName = "SystemX.Product.TRA.UIControl.OverviewSearchOption"; try { Type typeObj = Type.GetType(strTypeName); foreach (PropertyInfo info in typeObj.GetProperties()) { if (info.PropertyType == typeof(string)) continue; string strProp = info.Name; bool bChecked = checkedListBoxControlOption.Items[strProp].CheckState == CheckState.Checked ? true : false; info.SetValue(Option, bChecked); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show("Error during option matching: " + ex.Message); } this.Close(); } private void checkedListBoxControlOption_Click(object sender, EventArgs e) { } private void checkedListBoxControlOption_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e) { } } }