lixiaojun
2025-01-03 d672ca82c49f01dae2c5c955202b5857ef680a71
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HStation.WinFrmUI
{
    public partial class XhsSchemeElbowChangeListCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public XhsSchemeElbowChangeListCtrl()
        {
            InitializeComponent();
            this.layoutView1.SetDefuaulView();
            this.layoutView1.SetFindPanel();
        }
 
        /// <summary>
        /// 水力查看事件
        /// </summary>
        public event Action<string> HydroViewEvent;
 
        /// <summary>
        /// 水力改变事件
        /// </summary>
        public event Action<HydroElbowViewModel> HydroChangeEvent;
 
 
        private BindingList<XhsSchemeElbowChangeViewModel> _allBindingList = null;//所有绑定列表
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroModelInfo hydroInfo)
        {
            _allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
            if (hydroInfo != null)
            {
                if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
                {
                    foreach (var blunthead in hydroInfo.Elbows)
                    {
                        var vm = new HydroElbowViewModel(blunthead, hydroInfo);
                        var viewModel = new XhsSchemeElbowChangeViewModel(vm);
                        viewModel.ViewImage = this.svgImg32[0];
                        _allBindingList.Add(viewModel);
                    }
                }
            }
            this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
            this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroVisualViewModel> allVisualViewModelList)
        {
            _allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
            if (allVisualViewModelList != null && allVisualViewModelList.Count > 0)
            {
                foreach (var visualViewModel in allVisualViewModelList)
                {
                    if (visualViewModel.Vmo.Catalog == Yw.Hydro.ParterCatalog.Elbow)
                    {
                        var vm = visualViewModel as HydroElbowViewModel;
                        if (vm != null)
                        {
                            var viewModel = new XhsSchemeElbowChangeViewModel(vm);
                            viewModel.ViewImage = this.svgImg32[0];
                            _allBindingList.Add(viewModel);
                        }
                    }
                }
            }
            this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
            this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<HydroElbowViewModel> allElbowViewModelList)
        {
            _allBindingList = new BindingList<XhsSchemeElbowChangeViewModel>();
            if (allElbowViewModelList != null && allElbowViewModelList.Count > 0)
            {
                foreach (var fourlinkViewModel in allElbowViewModelList)
                {
                    var viewModel = new XhsSchemeElbowChangeViewModel(fourlinkViewModel);
                    viewModel.ViewImage = this.svgImg32[0];
                    _allBindingList.Add(viewModel);
                }
            }
            this.xhsSchemeElbowChangeViewModelBindingSource.DataSource = _allBindingList;
            this.xhsSchemeElbowChangeViewModelBindingSource.ResetBindings(false);
        }
 
        /// <summary>
        /// 设置聚焦行
        /// </summary>
        public void SetFocusedRow(int rowHandle)
        {
            this.layoutView1.FocusedRowHandle = rowHandle;
        }
 
        //字段点击
        private void layoutView1_FieldValueClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.FieldValueClickEventArgs e)
        {
            var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
            if (row == null)
            {
                return;
            }
            if (e.Column == this.colSvgImage)
            {
                var input = Yw.WinFrmUI.HydroMatchingHelper.Create(row.ViewModel.Vmo, row.ViewModel.HydroInfo);
                var dlg = new AssetsElbowSingleMatchingDlg();
                dlg.ReloadDataEvent += (output) =>
                {
                    if (Yw.WinFrmUI.HydroMatchingHelper.Apply(row.ViewModel, output))
                    {
                        this.layoutView1.RefreshRow(e.RowHandle);
                        this.HydroChangeEvent?.Invoke(row.ViewModel);
                    }
                };
                dlg.SetBindingData(input);
                dlg.ShowDialog();
            }
            else if (e.Column == this.colViewImage)
            {
                this.HydroViewEvent?.Invoke(row.ViewModel.Vmo.Code);
            }
        }
 
        //卡片点击
        private void layoutView1_CardClick(object sender, DevExpress.XtraGrid.Views.Layout.Events.CardClickEventArgs e)
        {
            var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
            if (row == null)
            {
                return;
            }
        }
 
        //选中列变换
        private void layoutView1_FocusedColumnChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedColumnChangedEventArgs e)
        {
 
        }
 
        //单元格值变换
        private void layoutView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            var row = this.layoutView1.GetRow(e.RowHandle) as XhsSchemeElbowChangeViewModel;
            if (row == null)
            {
                return;
            }
            row.ViewModel.UpdateVmoProperty();
            this.HydroChangeEvent?.Invoke(row.ViewModel);
        }
 
        private void toolTipController1_GetActiveObjectInfo(object sender, DevExpress.Utils.ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            // 获取当前鼠标所在的单元格信息
            //var hitInfo = this.layoutView1.CalcHitInfo(e.ControlMousePosition);
            //if (hitInfo != null && hitInfo.RowHandle >= 0 && hitInfo.Column != null)
            //{
            //    if (hitInfo.Column == this.colSvgImage)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "从产品中选择");
            //    }
            //    else if (hitInfo.Column == this.colName)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "名称");
            //    }
            //    else if (hitInfo.Column == this.colViewImage)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "模型定位");
            //    }
            //    else if (hitInfo.Column == this.colMaterial)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "材质");
            //    }
            //    else if (hitInfo.Column == this.colCaliber)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "口径(mm)");
            //    }
            //    else if (hitInfo.Column == this.colRunningThroughLoss)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "主管通过损失系数");
            //    }
            //    else if (hitInfo.Column == this.colBranchThroughLoss)
            //    {
            //        e.Info = new DevExpress.Utils.ToolTipControlInfo(this.gridControl1, "支管通过损失系数");
            //    }
            //    else
            //    {
            //        //e.Info = null;
            //    }
            //    return;
            //}
            //else
            //{
            //    //e.Info = null;
            //}
 
        }
 
 
    }
}