| | |
| | | using System.Data; |
| | | using DevExpress.XtraEditors.Controls; |
| | | using System.Data; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | |
| | | public HydroPumpListStateEditCtrl() |
| | | { |
| | | InitializeComponent(); |
| | | this.layoutControl1.SetupLayoutControl(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | public event Action<HydroPumpListItemStateViewModel> SelectedChangedEvent; |
| | | |
| | | private List<HydroPumpListItemStateViewModel> _allList = null;//所有列表 |
| | | private BindingList<HydroPumpListItemStateViewModel> _allBindingList = null;//所有绑定列表 |
| | | |
| | | /// <summary> |
| | |
| | | get { return _hasChanged; } |
| | | } |
| | | private bool _hasChanged = false; |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | |
| | | /// </summary> |
| | | public void SetBindingData(List<HydroPumpListItemStateViewModel> allStateList) |
| | | { |
| | | _allBindingList = new BindingList<HydroPumpListItemStateViewModel>(); |
| | | allStateList?.ForEach(x => _allBindingList.Add(x)); |
| | | this.hydroPumpListItemStateViewModelBindingSource.DataSource = _allBindingList; |
| | | this.hydroPumpListItemStateViewModelBindingSource.ResetBindings(false); |
| | | InitialGroups(allStateList); |
| | | } |
| | | |
| | | //初始化所有分组 |
| | | private void InitialGroups(List<HydroPumpListItemStateViewModel> allStateList) |
| | | { |
| | | _allList = allStateList?.ToList(); |
| | | var groups = _allList?.Select(x => x.BeginGroup).Distinct().ToList(); |
| | | this.itemForGroup.Visibility = groups != null && groups.Count > 1 ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always |
| | | : DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.imageComboBoxEdit1.Properties.BeginUpdate(); |
| | | this.imageComboBoxEdit1.Properties.Items.Clear(); |
| | | groups?.ForEach(x => |
| | | { |
| | | this.imageComboBoxEdit1.Properties.Items.Add(x, x, -1); |
| | | }); |
| | | this.imageComboBoxEdit1.SelectedIndex = groups != null && groups.Count > 0 ? 0 : -1; |
| | | this.imageComboBoxEdit1.Properties.EndUpdate(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | //分组选择改变 |
| | | private void imageComboBoxEdit1_SelectedValueChanged(object sender, EventArgs e) |
| | | { |
| | | var item = this.imageComboBoxEdit1.SelectedItem as ImageComboBoxItem; |
| | | if (item == null) |
| | | { |
| | | return; |
| | | } |
| | | _allBindingList = new BindingList<HydroPumpListItemStateViewModel>(); |
| | | if (_allList != null && _allList.Count > 0) |
| | | { |
| | | var allList = _allList.Where(x => x.BeginGroup == item.Value?.ToString()).ToList(); |
| | | allList.ForEach(x => _allBindingList.Add(x)); |
| | | } |
| | | this.hydroPumpListItemStateViewModelBindingSource.DataSource = _allBindingList; |
| | | this.hydroPumpListItemStateViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | //选择改变 |
| | | private void imageListBoxControl1_SelectedValueChanged(object sender, EventArgs e) |
| | | { |