| | |
| | | namespace HStation.WinFrmUI |
| | | using HStation.PhartRelation; |
| | | using Yw.Ahart; |
| | | using Yw.WinFrmUI.Phart; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public partial class ValveChartExcelImportCtrl : DevExpress.XtraEditors.XtraUserControl |
| | | { |
| | |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | |
| | | private Yw.Ahart.eCurveType _curve_type; |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public void SetBindingData(string file_path, Yw.Ahart.eCurveType curve_type) |
| | | 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> |
| | | 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; |
| | | |
| | | return null; |
| | | 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; |
| | | } |
| | | |
| | | |