年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

137 lines
4.2 KiB

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<TKey, TValue>
{
public static bool InitComboBoxEdit(ref ComboBoxEdit cmbBox, IList<ItemInfo<TKey, TValue>> items)
{
bool result;
try
{
int selectedIndex = 0;
cmbBox.Properties.Items.Clear();
foreach (ItemInfo<TKey, TValue> 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<ItemInfo<TKey, TValue>> items, ItemInfo<TKey, TValue> selecteditem)
{
bool result;
try
{
int num = 0;
int selectedIndex = 0;
cmbBox.Properties.Items.Clear();
foreach (ItemInfo<TKey, TValue> 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<ItemInfo<TKey, TValue>> items)
{
bool result;
try
{
lstBox.Items.Clear();
int selectedIndex = 0;
foreach (ItemInfo<TKey, TValue> 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<ItemInfo<TKey, TValue>> items, ItemInfo<TKey, TValue> selecteditem)
{
bool result;
try
{
int num = 0;
int selectedIndex = 0;
lstBox.Items.Clear();
foreach (ItemInfo<TKey, TValue> 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<ItemInfo<TKey, TValue>> items)
{
bool result;
try
{
ricmbBox.Items.Clear();
foreach (ItemInfo<TKey, TValue> current in items)
{
ricmbBox.Items.Add(current);
}
result = true;
}
catch (Exception)
{
result = false;
}
return result;
}
}
}