Shuxia Ning
2025-01-14 0f99d4d12f2eae29bbe343f4b3131f2faeccda5d
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
using Yw.Ahart;
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI
{
    public partial class ValveChartEditCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public ValveChartEditCtrl()
        {
            InitializeComponent(); 
        }
         
 
        private Yw.Vmo.PhartDiagramExGraphListVmo _vmo;
 
        /// <summary>
        /// 绑定数据
        /// </summary>  
        public void SetBindingData(Yw.Vmo.PhartDiagramExGraphListVmo vmo)
        {
            _vmo = vmo;
            if (_vmo.GraphList == null || !_vmo.GraphList.Any())
                return;
 
            var vm_list = new List<ValveEditChartViewModel>();
            foreach (var graph in _vmo.GraphList)
            {
                var curve_type = (Yw.Ahart.eCurveType)graph.GraphType;
                var feat_curve = Yw.WinFrmUI.PhartGraphHelper.GetPerformCurve(curve_type, graph.GeometryInfo);
                if (feat_curve == null || feat_curve.IsInvalid())
                    continue;
 
                var geometry_paras = Yw.WinFrmUI.PhartGraphHelper.GetGeometryParas(curve_type, graph.GeometryParas);
                var graph_paras = Yw.WinFrmUI.PhartGraphHelper.GetGraphParas<Yw.WinFrmUI.Phart.QLGraphParasViewModel>(curve_type, graph.GraphParas);
 
                var vm = new Yw.WinFrmUI.Phart.ValveEditChartViewModel();
                vm.Id = graph.ID.ToString();
                vm.Name = graph.Name;
                vm.CurveType = curve_type;
                vm.FeatType = feat_curve.FeatType;
                vm.FitPointList = feat_curve.FeatCurve.GetPointList(50);
                vm.DefPointList = (geometry_paras?.DefinePoints == null || !geometry_paras.DefinePoints.Any()) ? vm.FitPointList : geometry_paras.DefinePoints;
                vm.Opening = graph_paras?.Opening ?? 0;
                vm_list.Add(vm);
            } 
            if (vm_list==null||!vm_list.Any())
            {
                return;
            }
            vm_list[0].IsUpdate = true;
            this.valveChartExcelEditCtrl1.SetBindingData(vm_list);
        }
 
        /// <summary>
        /// 获取
        /// </summary> 
        public Yw.Vmo.PhartDiagramExGraphListVmo Get()
        {
            if (_vmo == null)
                return default;
            if (!this.valveChartExcelEditCtrl1.Get(out List<ValveEditChartViewModel> vm_list))
                return default;
            if (vm_list == null || !vm_list.Any())
                return default;
            foreach (var vm in vm_list)
            {
                if (!long.TryParse(vm.Id, out long id))
                    return default;
                var graph = _vmo.GraphList.Find(x => x.ID == id);
                if (graph == null)
                    return default; 
 
                var ds_stirng = vm.DefPointList.ToDbString(vm.CurveType, vm.FeatType);
                if (string.IsNullOrEmpty(ds_stirng))
                    return default;
                var geometry_paras = new Yw.WinFrmUI.Phart.CurveGeometryParasViewModel();
                geometry_paras.DefinePoints = vm.DefPointList;
 
                string graph_paras = string.Empty;
                if (vm.CurveType == eCurveType.QL)
                {
                    graph_paras = new QLGraphParasViewModel()
                    {
                        Opening = vm.Opening
                    }.ToJson();
                }
                   
                graph.GeometryParas = geometry_paras.ToJson(); 
                graph.GeometryInfo = ds_stirng;
                graph.GraphParas = graph_paras;
            }
 
 
            return _vmo;
        }
 
    }
}