using DevExpress.XtraEditors;
|
using System;
|
using System.Windows.Forms;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
public partial class CopyAndExpandCurveDlg : XtraForm
|
{
|
public CopyAndExpandCurveDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = WinFrmUI.Properties.Resources.App;
|
this.dataLayoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
/// 回调事件
|
/// </summary>
|
public event Func<string, Model.FeatCurveExpressGroup, bool> ReloadDataEvent;
|
|
private Model.PumpCurve _pumpCurve = null;
|
private Model.PumpCurveMapping _pumpCurveMapping = null;
|
|
private Model.FeatCurveExpressGroup _expandFeatCurveExpressGroup = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Model.PumpCurve pumpCurve, Model.PumpCurveMapping mapping)
|
{
|
if (pumpCurve == null || mapping == null)
|
return;
|
if (pumpCurve.CurveInfo == null)
|
return;
|
|
_pumpCurve = pumpCurve;
|
_pumpCurveMapping = mapping;
|
_expandFeatCurveExpressGroup = _pumpCurve.CurveInfo.Copy();
|
|
this.chartFeatCurveViewCtrl1.SetCurveInfo(pumpCurve.CurveInfo.CurveQH, pumpCurve.CurveInfo.CurveQE, pumpCurve.CurveInfo.CurveQP);
|
this.chartFeatCurveViewCtrl1.UpdateChart(true);
|
this.chartFeatCurveViewCtrl1.SetWorkPointQ_Auto();
|
|
this.txtOtherName.EditValue = _pumpCurveMapping.OtherName;
|
this.txtExpand.EditValue = 100;
|
}
|
|
//比例修改完成
|
private void txtExpand_EditValueChanged(object sender, EventArgs e)
|
{
|
if (_pumpCurve == null || _pumpCurve.CurveInfo == null)
|
return;
|
var value = int.Parse(this.txtExpand.EditValue.ToString());
|
double ratioExtend = value / 100f;
|
|
var curveInfo = _pumpCurve.CurveInfo;
|
var qhCurve = curveInfo.CurveQH;
|
var qeCurve = curveInfo.CurveQE;
|
var qpCurve = curveInfo.CurveQP;
|
|
var qhExPoints = IStation.Model.FitCurveHelper.GetFitPointsByExtend(qhCurve, ratioExtend, 12);
|
_expandFeatCurveExpressGroup.CurveQH = new Model.CurveExpress(qhExPoints, qhCurve.FitType, true);
|
|
if (qeCurve != null)
|
{
|
var qeExPoints = IStation.Model.FitCurveHelper.GetFitPointsByExtend(qeCurve, ratioExtend, 12);
|
_expandFeatCurveExpressGroup.CurveQE = new Model.CurveExpress(qeExPoints, qeCurve.FitType, true);
|
}
|
|
if (qpCurve != null)
|
{
|
var qpExPoints = IStation.Model.FitCurveHelper.GetFitPointsByExtend(qpCurve, ratioExtend, 12);
|
_expandFeatCurveExpressGroup.CurveQP = new Model.CurveExpress(qpExPoints, qpCurve.FitType, true);
|
}
|
|
this.chartFeatCurveViewCtrl1.SetCurveInfo(_expandFeatCurveExpressGroup.CurveQH, _expandFeatCurveExpressGroup.CurveQE, _expandFeatCurveExpressGroup.CurveQP);
|
this.chartFeatCurveViewCtrl1.UpdateChart(true);
|
this.chartFeatCurveViewCtrl1.SetWorkPointQ_Auto();
|
}
|
|
//验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.txtOtherName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtOtherName, "必填项");
|
return false;
|
}
|
return true;
|
}
|
|
//确定
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
var name = this.txtOtherName.Text.Trim();
|
|
var result = this.ReloadDataEvent?.Invoke(name, _expandFeatCurveExpressGroup);
|
if (result == null || !result.Value)
|
{
|
XtraMessageBox.Show("复制失败!");
|
return;
|
}
|
XtraMessageBox.Show("复制成功!");
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
}
|
}
|