duheng
2024-10-15 21d9f7bcbe8c82d2af9dbdc18f189a3bb1672d74
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
namespace Yw.WinFrmUI
{
    public partial class HydroCheckResultCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public HydroCheckResultCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView(30);
            this.gridView1.RegistCustomDrawRowIndicator(40);
            this.gridView1.ShowFindPanel();
        }
 
        /// <summary>
        /// 点击构件事件
        /// </summary>
        public event Action<string> HydroClickEvent;
 
        private List<HydroCheckItemViewModel> _allBindingList = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(HydroCheckResult result)
        {
            if (result.Succeed)
            {
                this.peSucceed.Image = Yw.WinFrmUI.Hydro.Core.Properties.Resources.succeed_64;
            }
            else
            {
                this.peSucceed.Image = Yw.WinFrmUI.Hydro.Core.Properties.Resources.failed_64;
            }
            this.txtMode.EditValue = HydroCheckMode.Count();
            this.txtType.EditValue = HydroCheckType.Count();
            this.txtItems.EditValue = result.Items.Count;
            this.txtSucceedItems.EditValue = result.Items.Count(x => !x.Failed);
            this.txtFailedItems.EditValue = result.Items.Count(x => x.Failed);
 
            _allBindingList = new List<HydroCheckItemViewModel>();
            foreach (var item in result.Items)
            {
                var vm = new HydroCheckItemViewModel(item);
                _allBindingList.Add(vm);
            }
            this.hydroCheckItemViewModelBindingSource.DataSource = _allBindingList;
            this.hydroCheckItemViewModelBindingSource.ResetBindings(false);
        }
 
        //行点击
        private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            var row = this.gridView1.GetRow(e.RowHandle) as HydroCheckItemViewModel;
            if (row == null)
            {
                return;
            }
            this.HydroClickEvent?.Invoke(row.Code);
        }
 
    }
}