lixiaojun
2025-01-06 f373ad1f566c9c8679547f4205d86eb6e0836d59
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
using DevExpress.Utils.MVVM;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraLayout.Utils;
using DevExpress.XtraVerticalGrid.Events;
using Yw.Model;
 
namespace Yw.WinFrmUI
{
 
    public partial class HydroVisualPropertyCtrl : XtraUserControl
    {
        public HydroVisualPropertyCtrl()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            SetDescriptionVisible(false);
        }
 
        /// <summary>
        /// 匹配db事件
        /// 第一个参数为匹配Db的ViewModel
        /// </summary>
        public event Action<HydroVisualViewModel> MatchingDbEvent;
        /// <summary>
        /// 设置曲线事件
        /// 第一个参数为设置曲线的ViewModel
        /// 第二个参数为曲线 (HydroCurve)
        /// 第三个参数为曲线类型(HydroCurveType)
        /// </summary>
        public event Action<HydroVisualViewModel, string, string> SetCurveEvent;
        /// <summary>
        /// 属性值发生改变事件
        /// </summary>
        public event Action<HydroVisualViewModel> PropertyValueChangedEvent;
        /// <summary>
        /// 标注属性值改变事件
        /// </summary>
        public event Action<HydroVisualViewModel> MarkPropertyValueChangedEvent;
        /// <summary>
        /// 分级属性值改变事件
        /// </summary>
        public event Action<HydroVisualViewModel> GradingPropertyValueChangedEvent;
 
        /// <summary>
        /// 构件改变事件
        /// </summary>
        public event Action<HydroParterInfo, eChangeType> ParterChangedEvent;
 
 
        /// <summary>
        /// 强调连接节点事件
        /// 第一个参数为本身Code
        /// 第二个参数为连接节点Code
        /// </summary>
        public event Action<HydroLinkViewModel, string> BlinkLinkNodeEvent;
        /// <summary>
        /// 查看构件事件
        /// </summary>
        public event Action<HydroVisualViewModel> HydroViewEvent;
 
        //属性状态辅助类
        private HydroPropStatusHelper _propStatusHelper = null;
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void InitialData(HydroPropStatusHelper propStatusHelper)
        {
            _propStatusHelper = propStatusHelper;
        }
 
        /// <summary>
        /// 允许修改
        /// </summary>
        public bool AllowEdit { get; set; }
 
        /// <summary>
        /// 绑定对象
        /// </summary>
        public HydroVisualViewModel SelectedObject
        {
            get
            {
                var vm = this.propertyGridControl1.SelectedObject as HydroVisualViewModel;
                return vm;
            }
            set
            {
                SetSelectedObject(value);
            }
        }
 
        //设置选择对象
        private void SetSelectedObject(HydroVisualViewModel vm)
        {
            if (this.AllowEdit)
            {
                this.barBtnChangeLink.Visibility = vm is HydroLinkViewModel ? BarItemVisibility.Always : BarItemVisibility.Never;
                this.barBtnMatchingDb.Visibility = vm == null ? BarItemVisibility.Never : BarItemVisibility.Always;
            }
            else
            {
                this.barBtnMatchingDb.Visibility = BarItemVisibility.Never;
                this.barBtnChangeLink.Visibility = BarItemVisibility.Never;
            }
            this.barBtnView.Visibility = vm == null ? BarItemVisibility.Never : BarItemVisibility.Always;
            var selectObj = this.propertyGridControl1.SelectedObject as HydroVisualViewModel;
            this.propertyGridControl1.SelectedObject = vm;
            if (selectObj == vm)
            {
                this.propertyGridControl1.UpdateRows();
            }
        }
 
        /// <summary>
        /// 重新从数据源中读取数据,外观恢复刚开始加载的样子
        /// </summary>
        public void UpdateData()
        {
            this.propertyGridControl1.UpdateData();
        }
 
        /// <summary>
        /// 更新数据,样式不变
        /// </summary>
        public void UpdateRows()
        {
            this.propertyGridControl1.UpdateRows();
        }
 
        //获取行的视图对象
        private HydroVisualViewModel GetPropertyViewModel(DevExpress.XtraVerticalGrid.Rows.BaseRow row)
        {
            if (row == null)
            {
                return default;
            }
            if (row.Level <= 1)
            {
                return this.SelectedObject;
            }
            if (row.ParentRow == null)
            {
                return this.SelectedObject;
            }
            if (row.ParentRow.Properties.Value is HydroVisualViewModel)
            {
                return row.ParentRow.Properties.Value as HydroVisualViewModel;
            }
            return GetPropertyViewModel(row.ParentRow);
        }
 
        //设置描述控件的可见性
        private void SetDescriptionVisible(bool isVisible)
        {
            var visible = isVisible ? LayoutVisibility.Always : LayoutVisibility.Never;
            this.layoutDescription.Visibility = this.splitterItem1.Visibility = visible;
        }
 
        //自定义属性Header缩进
        private void propertyGridControl1_CustomDrawRowHeaderIndent(object sender, CustomDrawRowHeaderIndentEventArgs e)
        {
 
        }
 
        //自定义属性Header显示
        private void propertyGridControl1_CustomDrawRowHeaderCell(object sender, CustomDrawRowHeaderCellEventArgs e)
        {
            //字段名称
            var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }
            var realFieldName = fieldName;
            //属性描述器
            var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
            if (descriptor != null)
            {
                //真实属性名称
                var realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)];
                if (realPropAttri != null)
                {
                    realFieldName = realPropAttri.RealPropName;
                }
                //名称
                var displayNameAttri = (DisplayNameAttribute)descriptor.Attributes[typeof(DisplayNameAttribute)];
                if (displayNameAttri != null && !string.IsNullOrEmpty(displayNameAttri.DisplayName))
                {
                    e.Caption = displayNameAttri.DisplayName;
                }
                //图标
                var calcuProAttri = (HydroCalcuProAttribute)descriptor.Attributes[typeof(HydroCalcuProAttribute)];
                if (calcuProAttri != null)
                {
 
                }
            }
 
            //颜色
            var vm = GetPropertyViewModel(e.Row);
            if (vm != null)
            {
                var propStatusInfo = _propStatusHelper?.GetPropStatusInfo(vm.Code, realFieldName);
                if (propStatusInfo != null)
                {
                    e.Appearance.ForeColor = HydroPropStatusColorHelper.GetColor(propStatusInfo.PropStatus);
                }
            }
        }
 
        //自定义属性值显示
        private void propertyGridControl1_CustomDrawRowValueCell(object sender, CustomDrawRowValueCellEventArgs e)
        {
            //行字段名称
            var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }
            //行类型全名称
            var fullTypeName = e.Row.Properties.RowType.FullName;
 
            if (fullTypeName == typeof(DateTime).FullName)
            {
                e.CellText = ((DateTime)e.Properties.Value).ToString("yyyy-MM-dd HH:mm:ss");
            }
            else
            {
                var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
                if (descriptor != null)
                {
                    var calcuPropAttri = (HydroCalcuProAttribute)descriptor.Attributes[typeof(HydroCalcuProAttribute)];
                    if (calcuPropAttri != null)
                    {
                        if (e.Properties.Value == null)
                        {
                            e.CellText = "尚未计算";
                            e.Appearance.ForeColor = Color.OrangeRed;
                        }
                    }
                    var displayUnitAttri = (DisplayUnitAttribute)descriptor.Attributes[typeof(DisplayUnitAttribute)];
                    if (displayUnitAttri != null)
                    {
                        if (e.Properties.Value != null)
                        {
                            e.CellText = e.Properties.Value.ToString() + " " + displayUnitAttri.Unit;
                        }
                    }
                }
            }
        }
 
        //属性编辑框的显示与取消
        private void propertyGridControl1_ShowingEditor(object sender, CancelEventArgs e)
        {
            var rowTypeFullName = this.propertyGridControl1.FocusedRow.Properties.RowType.FullName;
            var fieldName = this.propertyGridControl1.FocusedRow.Properties.FieldName.Split(new char[] { '.' }).Last();
 
            if (rowTypeFullName == typeof(Image).FullName)
            {
                e.Cancel = true;
                return;
            }
 
            var descriptor = this.propertyGridControl1.GetPropertyDescriptor(this.propertyGridControl1.FocusedRow);
 
            if (this.AllowEdit)
            {
                var showEditor = (ShowEditorAttribute)descriptor.Attributes[typeof(ShowEditorAttribute)];
                if (showEditor != null)
                {
                    if (!showEditor.ShowEditor)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            else
            {
                var showEditorInView = (ShowEditorInViewAttribute)descriptor.Attributes[typeof(ShowEditorInViewAttribute)];
                if (showEditorInView == null)
                {
                    e.Cancel = true;
                    return;
                }
                if (!showEditorInView.ShowEditor)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }
 
        //编辑框
        private void propertyGridControl1_CustomRecordCellEdit(object sender, GetCustomRowCellEditEventArgs e)
        {
            var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }
            var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
            var rowTypeFullName = e.Row.Properties.RowType.FullName;
            var vm = GetPropertyViewModel(e.Row);
            if (vm == null)
            {
                return;
            }
 
            #region bool
 
            if (rowTypeFullName == typeof(bool).FullName)
            {
                var ckEdit = new RepositoryItemCheckEdit();
                ckEdit.CheckStyle = DevExpress.XtraEditors.Controls.CheckStyles.Standard;
                if (e.Row.Properties.ReadOnly == true)
                {
                    ckEdit.ReadOnly = true;
                }
                e.RepositoryItem = ckEdit;
            }
 
            #endregion
 
            #region 富文本
 
            if (descriptor != null)
            {
                var attri_multi = (MultiTextAttribute)descriptor.Attributes[typeof(MultiTextAttribute)];
                if (attri_multi != null)
                {
                    var memoEdit = new RepositoryItemMemoEdit();
                    if (e.Row.Properties.ReadOnly == true)
                    {
                        memoEdit.ReadOnly = true;
                    }
                    e.RepositoryItem = memoEdit;
                }
            }
 
            #endregion
 
            #region 图片
 
            if (rowTypeFullName == typeof(Image).FullName)
            {
                var picEdit = new RepositoryItemPictureEdit();
                picEdit.ReadOnly = true;
                picEdit.NullText = "空";
                e.RepositoryItem = picEdit;
                e.Row.Expanded = true;
            }
 
            #endregion
 
            #region 曲线
 
            if (descriptor != null)
            {
                var curvePropAttri = (HydroCurveProAttribute)descriptor.Attributes[typeof(HydroCurveProAttribute)];
                if (curvePropAttri != null)
                {
                    var buttonEdit = new RepositoryItemButtonEdit();
                    buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
                    buttonEdit.ButtonClick += delegate
                    {
                        var vm = GetPropertyViewModel(e.Row);
                        if (vm == null)
                        {
                            return;
                        }
                        if (string.IsNullOrEmpty(curvePropAttri.CurveType))
                        {
                            this.SetCurveEvent?.Invoke(vm, curvePropAttri.Curve, curvePropAttri.CurveType);
                        }
                        else
                        {
                            if (e.Row.Properties.Value == null || string.IsNullOrEmpty(e.Row.Properties.Value.ToString()))
                            {
                                return;
                            }
                            this.radialMenu1.ShowPopup(MousePosition);
                        }
                    };
                    e.RepositoryItem = buttonEdit;
                }
            }
 
            #endregion
 
            #region 模式
 
            if (descriptor != null)
            {
                var patternProAttri = (HydroPatternProAttribute)descriptor.Attributes[typeof(HydroPatternProAttribute)];
                if (patternProAttri != null)
                {
                    var buttonEdit = new RepositoryItemButtonEdit();
                    buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
                    buttonEdit.ButtonClick += delegate
                    {
 
                    };
                    e.RepositoryItem = buttonEdit;
                }
            }
 
 
            #endregion
 
            #region 标签
 
            if (descriptor != null)
            {
                var flagsProAttri = (HydroFlagsProAttribute)descriptor.Attributes[typeof(HydroFlagsProAttribute)];
                if (flagsProAttri != null)
                {
                    var buttonEdit = new RepositoryItemButtonEdit();
                    buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
                    buttonEdit.ButtonClick += async delegate
                    {
                        var vm = GetPropertyViewModel(e.Row);
                        var flagVmoList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(Yw.Hydro.DataType.HydroParter);
                        var dbFlagList = flagVmoList?.Select(x => x.Name).Distinct().ToList();
                        var dlg = new SetFlagsDlg();
                        dlg.SetBindingData(dbFlagList, vm.Vmo.Flags);
                        dlg.ReloadDataEvent += (flags) =>
                        {
                            vm.Vmo.Flags = flags;
                            vm.Flags = Yw.Untity.FlagsHelper.ToString(flags);
                            this.propertyGridControl1.UpdateRows();
                            this.propertyGridControl1.RefreshEditor();
                            this.PropertyValueChangedEvent?.Invoke(vm);
                        };
                        dlg.ShowDialog();
                    };
                    e.RepositoryItem = buttonEdit;
                }
            }
 
            #endregion
 
            #region 连接
 
            if (e.Row.Properties.Value != null)
            {
                if (descriptor != null)
                {
                    var linkCodeAttri = (HydroLinkProAttribute)descriptor.Attributes[typeof(HydroLinkProAttribute)];
                    if (linkCodeAttri != null)
                    {
                        var buttonEdit = new RepositoryItemButtonEdit();
                        buttonEdit.TextEditStyle = TextEditStyles.DisableTextEditor;
                        buttonEdit.ButtonClick += delegate
                        {
                            var vm = GetPropertyViewModel(e.Row);
                            var vmLink = vm as HydroLinkViewModel;
                            this.BlinkLinkNodeEvent?.Invoke(vmLink, e.Row.Properties.Value.ToString());
                        };
                        e.RepositoryItem = buttonEdit;
                    }
                }
            }
 
            #endregion
 
            #region 阀门
 
            if (vm is HydroValveViewModel valve)
            {
                if (fieldName == nameof(HydroValveViewModel.ValveSetting))
                {
                    e.Row.Visible = false;
                }
                switch (valve.Vmo.ValveType)
                {
                    case Yw.Hydro.ValveType.PSV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = true;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.PRV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = true;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.PBV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = true;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.FCV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = true;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.TCV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = true;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.GPV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = true;
                            }
                        }
                        break;
                    case Yw.Hydro.ValveType.CV:
                        {
                            if (fieldName == nameof(HydroValveViewModel.ValvePress))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveFlow))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveOL))
                            {
                                e.Row.Visible = false;
                            }
                            if (fieldName == nameof(HydroValveViewModel.ValveQL))
                            {
                                e.Row.Visible = false;
                            }
                        }
                        break;
                    default: break;
                }
            }
 
 
            #endregion
 
 
        }
 
        //属性值改变
        private void propertyGridControl1_CellValueChanged(object sender, DevExpress.XtraVerticalGrid.Events.CellValueChangedEventArgs e)
        {
            var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }
            var vm = GetPropertyViewModel(e.Row);
            if (vm == null)
            {
                return;
            }
            vm.UpdateVmoProperty();
            this.PropertyValueChangedEvent?.Invoke(vm);
 
            var realFieldName = fieldName;
            var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
            if (descriptor != null)
            {
                //真实属性名称
                var realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)];
                if (realPropAttri != null)
                {
                    realFieldName = realPropAttri.RealPropName;
                }
 
                var hydroMarkPropAttri = descriptor.Attributes[typeof(HydroMarkProAttribute)];
                if (hydroMarkPropAttri != null)
                {
                    this.MarkPropertyValueChangedEvent?.Invoke(vm);
                }
 
                var hydroGradingPropAttri = descriptor.Attributes[typeof(HydroGradingProAttribute)];
                if (hydroGradingPropAttri != null)
                {
                    this.GradingPropertyValueChangedEvent?.Invoke(vm);
                }
 
                this.propertyGridControl1.UpdateRows();
            }
            _propStatusHelper?.UpdatePropStatus(vm.Code, realFieldName, Yw.Hydro.ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过属性控件修改");
            this.ParterChangedEvent?.Invoke(vm.Vmo, eChangeType.Update);
        }
 
        //Db匹配
        private void barBtnMatchingDb_ItemClick(object sender, ItemClickEventArgs e)
        {
            var vm = this.SelectedObject;
            if (vm == null)
            {
                return;
            }
            this.MatchingDbEvent?.Invoke(vm);
        }
 
        //改变连接节点
        private void barBtnChangeLink_ItemClick(object sender, ItemClickEventArgs e)
        {
            var result = XtraMessageBox.Show("是否确认调整上下游?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes;
            if (!result)
            {
                return;
            }
            var link = this.SelectedObject as HydroLinkViewModel;
            if (link != null)
            {
                var tempCode = link.StartCode;
                link.StartCode = link.EndCode;
                link.EndCode = tempCode;
                link.UpdateVmoProperty();
 
                var translation = this.SelectedObject as HydroTranslationViewModel;
                if (translation != null)
                {
                    var tempDiameter = translation.StartDiameter;
                    translation.StartDiameter = translation.EndDiameter;
                    translation.EndDiameter = tempDiameter;
                    translation.UpdateVmoProperty();
                }
 
                var pump = this.SelectedObject as HydroPumpViewModel;
                if (pump != null)
                {
                    var tempDiameter = pump.InletDiameter;
                    pump.InletDiameter = pump.OutletDiameter;
                    pump.OutletDiameter = tempDiameter;
                    pump.UpdateVmoProperty();
                }
 
                this.propertyGridControl1.UpdateRows();
            }
        }
 
        //全部展开
        private void barBtnExpandAll_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.propertyGridControl1.ExpandAllRows();
        }
 
        //全部折叠
        private void barBtnCollpseAll_ItemClick(object sender, ItemClickEventArgs e)
        {
            this.propertyGridControl1.CollapseAllRows();
        }
 
        //查看
        private void barBtnView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var vm = this.SelectedObject;
            if (vm == null)
            {
                return;
            }
            this.HydroViewEvent?.Invoke(vm);
        }
 
        // 描述
        private void barBtnHelp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var visible = this.splitterItem1.Visibility == LayoutVisibility.Always ? false : true;
            SetDescriptionVisible(visible);
        }
 
        //聚焦行改变
        private void propertyGridControl1_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            //字段名称
            var fieldName = e.Row.Properties.FieldName.Split(new char[] { '.' }).Last();
            if (string.IsNullOrEmpty(fieldName))
            {
                return;
            }
            var vm = GetPropertyViewModel(e.Row);
            if (vm == null)
            {
                return;
            }
 
            string caption = string.Empty;
            string descrition = string.Empty;
            string realFieldName = fieldName;
 
 
            //属性描述器
            var descriptor = this.propertyGridControl1.GetPropertyDescriptor(e.Row);
            if (descriptor != null)
            {
                //名称
                var displayNameAttri = (DisplayNameAttribute)descriptor.Attributes[typeof(DisplayNameAttribute)];
                if (displayNameAttri != null && !string.IsNullOrEmpty(displayNameAttri.DisplayName))
                {
                    caption = displayNameAttri.DisplayName;
                }
 
                //描述
                var descritionAttri = (DescriptionAttribute)descriptor.Attributes[typeof(DescriptionAttribute)];
                if (descritionAttri != null)
                {
                    descrition = descritionAttri.Description;
                }
 
                //真实属性名称
                var realPropAttri = (HydroRealProAttribute)descriptor.Attributes[typeof(HydroRealProAttribute)];
                if (realPropAttri != null)
                {
                    realFieldName = realPropAttri.RealPropName;
                }
            }
 
            var propStatusInfo = _propStatusHelper?.GetPropStatusInfo(vm.Code, realFieldName);
            this.hydroVisualPropertyDescriptionCtrl1.SetBindingData(caption, descrition, propStatusInfo);
 
        }
 
        //查看曲线
        private void barBtnViewCurve_ItemClick(object sender, ItemClickEventArgs e)
        {
            var vm = this.SelectedObject;
            if (vm == null)
            {
                return;
            }
            var row = this.propertyGridControl1.FocusedRow;
            var code = row.Properties.Value?.ToString();
            var curve = vm.HydroInfo.Curves?.Find(x => x.Code == code);
            if (curve == null)
            {
                return;
            }
            var dlg = new HydroCurveViewDlg();
            dlg.SetBindingData(curve);
            dlg.ShowDialog();
        }
 
        //编辑曲线
        private void barBtnEditCurve_ItemClick(object sender, ItemClickEventArgs e)
        {
            var vm = this.SelectedObject;
            if (vm == null)
            {
                return;
            }
            var row = this.propertyGridControl1.FocusedRow;
            var code = row.Properties.Value?.ToString();
            var curve = vm.HydroInfo.Curves?.Find(x => x.Code == code);
            if (curve == null)
            {
                return;
            }
            var dlg = new HydroCurveEditDlg();
            dlg.ReloadDataEvent += (rhs) =>
            {
                this.ParterChangedEvent?.Invoke(rhs, eChangeType.Update);
            };
            dlg.SetBindingData(curve);
            dlg.ShowDialog();
        }
 
 
 
 
    }
}