using HStation.WinFrmUI.PhartRelation; using System.Windows.Input; using Yw.WinFrmUI.Phart; namespace HStation.WinFrmUI.Xhs.Core { public partial class XhsProjectSimulationPumpSingleMatchingForm : DevExpress.XtraEditors.XtraUserControl { public XhsProjectSimulationPumpSingleMatchingForm() { InitializeComponent(); this.gridView1.SetNormalView(); this.gridView2.SetNormalView(); } public class PhartViewModel { public long ID { get; set; } public string OtherName { get; set; } public int Importance { get; set; } public int SortCode { get; set; } } public class CurvieInfo { public long? Dbid { get; set; } public long? Curveid { get; set; } public Vmo.XhsPumpMainPhartMappingExtensions Curveinfo { get; set; } } private List _allBindingList = null; private BLL.PumpMain _pumpBll = null; private List _allPhartList = null; private readonly Lazy _bll_ex = new(); private PumpMatchingViewModel _pumpMatchingViewModel; public async void SetBindingData(PumpMatchingViewModel pumpMatchingViewModel) { _pumpMatchingViewModel = pumpMatchingViewModel; _allBindingList = new List(); _pumpBll = new BLL.PumpMain(); var allPumpMain = await _pumpBll.GetAll(); foreach (var Main in allPumpMain) { _allBindingList.Add(new XhsProjectSimulationPumpSingleMatchingViewModel(Main)); } for (int i = 0; i < _allBindingList.Count; i++) { if (long.TryParse(pumpMatchingViewModel.DbId, out long dbID)) { if (_allBindingList[i].ID == dbID) { gridView2.FocusedRowHandle = i; } } } this.gridControl2.DataSource = _allBindingList; this.searchControl1.Text = pumpMatchingViewModel.ModelType; } //初始化图表数据 private void InitChart(Vmo.XhsPumpMainPhartMappingExtensions dto) { if (dto == null) { return; } var diagram = dto.Diagram; if (diagram == null) { return; } var graph_list = diagram.GraphList; if (graph_list == null || !graph_list.Any()) { return; } var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH); var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); if (graph_qp == null) { return; } List points_qh = null, points_qe = null, points_qp = null; points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null); if (graph_qe != null) points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null); if (graph_qp != null) points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null); var cubic_spline_qh = new Yw.Geometry.CubicSpline2d(points_qh); var cubic_spline_qe = new Yw.Geometry.CubicSpline2d(points_qe); var cubic_spline_qp = new Yw.Geometry.CubicSpline2d(points_qp); var disp_paras = diagram.DispParas; var is_calc_disp_paras = string.IsNullOrWhiteSpace(disp_paras); this.xtrPerform2dChart1.SetBindingData(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp, disp_paras, is_calc_disp_paras); } //泵型号列表选择项切换事件 private async void gridView2_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { _allPhartList = new List(); var vm = this.gridView2.GetCurrentViewModel(_allBindingList); if (vm != null) { _pumpMatchingViewModel.MatchingDbId = vm.ID.ToString(); var list = await _bll_ex.Value.GetByPumpMainID(vm.ID); if (list != null && list.Any()) { foreach (var item in list) { _allPhartList.Add(new PhartViewModel { ID = item.ID, OtherName = item.OtherName, Importance = item.Importance, SortCode = item.SortCode }); } } } if (_pumpMatchingViewModel.MatchingCurveDbId != null) { for (int i = 0; i < _allPhartList.Count; i++) { if (_allBindingList[i].ID.ToString() == _pumpMatchingViewModel.MatchingCurveDbId) { gridView1.FocusedRowHandle = i; } } } this.gridControl1.DataSource = _allPhartList; } //曲线列表选择项切换事件 private async void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { var vm = this.gridView1.GetCurrentViewModel(_allPhartList); if (vm != null) { var vmo = await _bll_ex.Value.GetByID(vm.ID); if (vmo != null) { _pumpMatchingViewModel.MatchingCurveDbId = vm.ID.ToString(); var graph_qh = vmo.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH); var graph_qe = vmo.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); var graph_qp = vmo.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); if (graph_qh != null) { var points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 100, null); _pumpMatchingViewModel.MatchingCurveQH = new List(); foreach (var item in points_qh) { _pumpMatchingViewModel.MatchingCurveQH.Add(new CurvePointMatchingViewModel(item.X, item.Y)); } } if (graph_qe != null) { var points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 100, null); _pumpMatchingViewModel.MatchingCurveQE = new List(); foreach (var item in points_qe) { _pumpMatchingViewModel.MatchingCurveQE.Add(new CurvePointMatchingViewModel(item.X, item.Y)); } } if (graph_qp != null) { var points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 100, null); _pumpMatchingViewModel.MatchingCurveQP = new List(); foreach (var item in points_qp) { _pumpMatchingViewModel.MatchingCurveQP.Add(new CurvePointMatchingViewModel(item.X, item.Y)); } } } InitChart(vmo); return; } this.xtrPerform2dChart1.SetBindingData(null, null, null, null, false); } } }