using HStation.PhartRelation; using Yw.Ahart; using Yw.WinFrmUI.Phart; namespace HStation.WinFrmUI { public partial class ValveChartExcelImportCtrl : DevExpress.XtraEditors.XtraUserControl { public ValveChartExcelImportCtrl() { InitializeComponent(); } /// /// 绑定数据 /// public void SetBindingData(string file_path) { var err_msg = Yw.WinFrmUI.PhartExcelHelper.ParseValveExcel(file_path, out List<(Yw.Ahart.eCurveType CurveType, List DefPointList, int Opening)> list); if (!string.IsNullOrEmpty(err_msg)) { XtraMessageBox.Show(err_msg); return; } var vm_list = new List(); 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); } /// /// 获取 /// public Yw.Vmo.PhartDiagramExGraphListVmo Get() { if (!this.valveChartExcelEditCtrl1.Get(out List 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(); 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; } } }