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.PumpCurveExMapping _pumpCurveExMapping = null;
|
|
private Model.FeatCurveExpressGroup _expandFeatCurveExpressGroup = null;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData(Model.PumpCurveExMapping model)
|
{
|
if (model == null)
|
return;
|
if (model.CurveInfo == null)
|
return;
|
|
_pumpCurveExMapping = model;
|
_expandFeatCurveExpressGroup = _pumpCurveExMapping.CurveInfo.Copy();
|
|
this.chartFeatCurveViewCtrl1.SetBindingData(model.CurveInfo.CurveQH, model.CurveInfo.CurveQE, model.CurveInfo.CurveQP);
|
|
this.txtOtherName.EditValue = _pumpCurveExMapping.OtherName;
|
this.txtExpand.EditValue = 100;
|
}
|
|
//比例修改完成
|
private void txtExpand_EditValueChanged(object sender, EventArgs e)
|
{
|
if (_pumpCurveExMapping == null || _pumpCurveExMapping.CurveInfo == null)
|
return;
|
var value = int.Parse(this.txtExpand.EditValue.ToString());
|
double ratioExtend = value / 100f;
|
|
var curveInfo = _pumpCurveExMapping.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.SetBindingData(_expandFeatCurveExpressGroup.CurveQH, _expandFeatCurveExpressGroup.CurveQE, _expandFeatCurveExpressGroup.CurveQP);
|
}
|
|
//验证
|
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();
|
}
|
|
}
|
}
|