using DevExpress.XtraEditors; using DevExpress.XtraEditors.Repository; using KGIS.Plugin.LayerProperty.Utils; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace KGIS.Plugin.LayerProperty.View.UC_Controls { public class DevExpressControlInitList { public static bool InitComboBoxEdit(ref ComboBoxEdit cmbBox, IList> items) { bool result; try { int selectedIndex = 0; cmbBox.Properties.Items.Clear(); foreach (ItemInfo current in items) { cmbBox.Properties.Items.Add(current); } if (cmbBox.Properties.Items.Count != 0) { cmbBox.SelectedIndex = selectedIndex; } result = true; } catch (Exception) { result = false; } return result; } public static bool InitComboBoxEdit(ref ComboBoxEdit cmbBox, IList> items, ItemInfo selecteditem) { bool result; try { int num = 0; int selectedIndex = 0; cmbBox.Properties.Items.Clear(); foreach (ItemInfo current in items) { cmbBox.Properties.Items.Add(current); if (current == selecteditem) { selectedIndex = num; } num++; } if (cmbBox.Properties.Items.Count != 0) { cmbBox.SelectedIndex = selectedIndex; } result = true; } catch (Exception) { result = false; } return result; } public static bool InitListBoxControl(ref ListBoxControl lstBox, IList> items) { bool result; try { lstBox.Items.Clear(); int selectedIndex = 0; foreach (ItemInfo current in items) { lstBox.Items.Add(current); } if (lstBox.Items.Count != 0) { lstBox.SelectedIndex = selectedIndex; } result = true; } catch (Exception) { result = false; } return result; } public static bool InitListBoxControl(ref ListBoxControl lstBox, IList> items, ItemInfo selecteditem) { bool result; try { int num = 0; int selectedIndex = 0; lstBox.Items.Clear(); foreach (ItemInfo current in items) { lstBox.Items.Add(current); if (current == selecteditem) { selectedIndex = num; } num++; } if (lstBox.Items.Count != 0) { lstBox.SelectedIndex = selectedIndex; } result = true; } catch (Exception) { result = false; } return result; } public static bool InitRepositoryItemComboBox(ref RepositoryItemComboBox ricmbBox, IList> items) { bool result; try { ricmbBox.Items.Clear(); foreach (ItemInfo current in items) { ricmbBox.Items.Add(current); } result = true; } catch (Exception) { result = false; } return result; } } }