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;
|
}
|
|
}
|
}
|