Shuxia Ning
2025-01-10 4d95d752823b1f5362c5d639001444b260b90395
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
using HStation.PhartRelation;
using Yw.Ahart;
using Yw.WinFrmUI.Phart;
 
namespace HStation.WinFrmUI
{
    public partial class ValveChartExcelImportCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public ValveChartExcelImportCtrl()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>  
        public void SetBindingData(string file_path)
        {
            var err_msg = Yw.WinFrmUI.PhartExcelHelper.ParseValveExcel(file_path, out List<(Yw.Ahart.eCurveType CurveType, List<Yw.Geometry.Point2d> DefPointList, int Opening)> list);
            if (!string.IsNullOrEmpty(err_msg))
            {
                XtraMessageBox.Show(err_msg);
                return;
            }
 
            var vm_list = new List<Yw.WinFrmUI.Phart.ValveEditChartViewModel>();
            for (int i = 0; i < list.Count; i++)
            { 
                var item = list[i];
                var vm = new Yw.WinFrmUI.Phart.ValveEditChartViewModel();
                vm.Id = Guid.NewGuid().ToString();
                vm.Name = item.CurveType == Yw.Ahart.eCurveType.OL ? "默认" : $"{item.Opening}%"; 
                vm.CurveType = item.CurveType;
                vm.FeatType = Yw.Ahart.eFeatType.Cubic;
                vm.DefPointList = item.DefPointList;
                vm.FitPointList = item.DefPointList.GetPointList(vm.FeatType, 50);
                vm.Opening = item.Opening;
                vm_list.Add(vm);
            }
            vm_list[0].IsUpdate = true; 
            this.valveChartExcelEditCtrl1.SetBindingData(vm_list);
        }
 
 
        /// <summary>
        /// 获取
        /// </summary> 
        public Yw.Vmo.PhartDiagramExGraphListVmo Get()
        {
            if (!this.valveChartExcelEditCtrl1.Get(out List<ValveEditChartViewModel> vm_list))
                return default;
            if (vm_list == null || !vm_list.Any())
                return default;
              
            var vmo = new Yw.Vmo.PhartDiagramExGraphListVmo();
            vmo.DiagramType = (int)HStation.PhartRelation.eDiagramType.Feat;
            vmo.GraphList = new List<Yw.Vmo.PhartGraphVmo>();
            foreach (var vm in vm_list)
            {
                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();
                }
 
                var graph = new Yw.Vmo.PhartGraphVmo();
                graph.Name = vm.Name; 
                graph.GraphType = (int)vm.CurveType;
                graph.GeometryParas = geometry_paras.ToJson();
                graph.GeometryStyle = (int)HStation.PhartRelation.eGeometryStyle.FeatCurve;
                graph.GeometryInfo = ds_stirng;
                graph.GraphParas = graph_paras;
                vmo.GraphList.Add(graph);
            }
 
            return vmo;
        }
 
 
    }
}