using DevExpress.XtraEditors;
|
|
namespace Yw.WinFrmUI.Phart.Cubic
|
{
|
public partial class ChartCoordinateDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public ChartCoordinateDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Action<PerformCoordinate> OnChangedCoord = null;
|
|
/// <summary>
|
/// 坐标参数
|
/// </summary>
|
public PerformCoordinate CoordinateParas
|
{
|
get => _coordinateParas;
|
set => _coordinateParas = value;
|
}
|
private PerformCoordinate _coordinateParas = null;
|
|
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
/// <param name="coordinate">坐标参数</param>
|
public void SetBindingData(PerformCoordinate coordinate, bool onlyQH = false)
|
{
|
if (coordinate == null)
|
return;
|
|
if (onlyQH)
|
{
|
this.groupBoxE.Enabled = false;
|
this.groupBoxP.Enabled = false;
|
}
|
|
_coordinateParas = new PerformCoordinate(coordinate);
|
this.textMinDispQ.EditValue = _coordinateParas.CoordMinQ;
|
|
this.textGridNumberX.EditValue = _coordinateParas.GridNumberX;
|
this.textGridNumberY.EditValue = _coordinateParas.GridNumberY;
|
this.textCoordSpaceQ.EditValue = _coordinateParas.CoordSpaceQ;
|
this.textStartLineNoH.EditValue = _coordinateParas.StartLineNoH;
|
this.textEndLineNoH.EditValue = _coordinateParas.EndLineNoH;
|
|
this.textMaxDispH.EditValue = (_coordinateParas.CoordMinH + _coordinateParas.EndLineNoH * _coordinateParas.CoordSpaceH);
|
this.textCoordSpaceH.EditValue = _coordinateParas.CoordSpaceH;
|
|
this.textEndLineNoE.EditValue = _coordinateParas.EndLineNoE;
|
this.textStartLineNoE.EditValue = _coordinateParas.StartLineNoE;
|
this.textCoordSpaceE.EditValue = _coordinateParas.CoordSpaceE;
|
this.textMaxDispE.EditValue = (_coordinateParas.CoordMinE + _coordinateParas.EndLineNoE * _coordinateParas.CoordSpaceE);
|
|
double minP = _coordinateParas.CoordMinP + _coordinateParas.StartLineNoP * _coordinateParas.CoordSpaceP;
|
if (minP < 0.001)
|
minP = 0;
|
this.textMinDispP.EditValue = minP;
|
this.textStartLineNoP.EditValue = _coordinateParas.StartLineNoP;
|
this.textEndLineNoP.EditValue = _coordinateParas.EndLineNoP;
|
this.textCoordSpaceP.EditValue = _coordinateParas.CoordSpaceP;
|
|
}
|
|
|
|
private void btnSet_Click(object sender, EventArgs e)
|
{
|
if (_coordinateParas == null)
|
return;
|
|
if (!double.TryParse(this.textCoordSpaceQ.Text, out double space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.1)
|
{
|
XtraMessageBox.Show("刻度值过小,请重新调整");
|
return;
|
}
|
|
if (!int.TryParse(this.textGridNumberX.Text, out int num))
|
{
|
XtraMessageBox.Show("扬程刻度数请输入合理值");
|
return;
|
}
|
_coordinateParas.GridNumberX = num;
|
|
if (!int.TryParse(this.textGridNumberY.Text, out num))
|
{
|
XtraMessageBox.Show("扬程刻度数请输入合理值");
|
return;
|
}
|
_coordinateParas.GridNumberY = num;
|
|
double.TryParse(this.textMinDispQ.Text, out double CoordMinQ);
|
|
_coordinateParas.CoordMinQ = CoordMinQ;
|
_coordinateParas.CoordSpaceQ = space;
|
|
if (!int.TryParse(this.textStartLineNoH.Text, out int start))
|
{
|
XtraMessageBox.Show("扬程刻度数请输入合理值");
|
return;
|
}
|
if (!int.TryParse(this.textEndLineNoH.Text, out int end))
|
{
|
XtraMessageBox.Show("扬程刻度数请输入合理值");
|
return;
|
}
|
if (start >= end - 1)
|
{
|
XtraMessageBox.Show("扬程刻度设置不合理");
|
return;
|
}
|
if (!double.TryParse(this.textCoordSpaceH.Text, out space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.1)
|
{
|
XtraMessageBox.Show("刻度值过小,请重新调整");
|
return;
|
}
|
if (!double.TryParse(this.textMaxDispH.Text, out double maxValue))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
|
_coordinateParas.StartLineNoH = start;
|
_coordinateParas.EndLineNoH = end;
|
_coordinateParas.CoordSpaceH = space;
|
_coordinateParas.CoordMinH = maxValue - _coordinateParas.EndLineNoH * space;
|
|
if (this.groupBoxE.Enabled)
|
{
|
if (!int.TryParse(this.textEndLineNoE.Text, out end))
|
{
|
XtraMessageBox.Show("效率刻度数请输入合理值");
|
return;
|
}
|
if (!int.TryParse(this.textStartLineNoE.Text, out start))
|
{
|
XtraMessageBox.Show("效率刻度数请输入合理值");
|
return;
|
}
|
if (start >= end - 1)
|
{
|
XtraMessageBox.Show("效率刻度设置不合理");
|
return;
|
}
|
if (!double.TryParse(this.textCoordSpaceE.Text, out space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.1)
|
{
|
XtraMessageBox.Show("刻度值过小,请重新调整");
|
return;
|
}
|
if (!double.TryParse(this.textMaxDispE.Text, out maxValue))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
_coordinateParas.CoordSpaceE = space;
|
_coordinateParas.StartLineNoE = start;
|
_coordinateParas.EndLineNoE = end;
|
_coordinateParas.CoordMinE = maxValue - _coordinateParas.EndLineNoE * _coordinateParas.CoordSpaceE;
|
|
}
|
|
if (this.groupBoxP.Enabled)
|
{
|
if (!int.TryParse(this.textStartLineNoP.Text, out start))
|
{
|
XtraMessageBox.Show("功率刻度数请输入合理值");
|
return;
|
}
|
if (!int.TryParse(this.textEndLineNoP.Text, out end))
|
{
|
XtraMessageBox.Show("功率刻度数请输入合理值");
|
return;
|
}
|
if (start >= end - 1)
|
{
|
XtraMessageBox.Show("功率刻度设置不合理");
|
return;
|
}
|
if (!double.TryParse(this.textCoordSpaceP.Text, out space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.01)
|
{
|
XtraMessageBox.Show("刻度值过小,请重新调整");
|
return;
|
}
|
if (!double.TryParse(this.textMinDispP.Text, out double minValue))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
_coordinateParas.StartLineNoP = start;
|
_coordinateParas.EndLineNoP = end;
|
_coordinateParas.CoordSpaceP = space;
|
_coordinateParas.CoordMinP = minValue - _coordinateParas.StartLineNoP * _coordinateParas.CoordSpaceP;
|
}
|
|
this.OnChangedCoord?.Invoke(_coordinateParas);
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
|
}
|
|
|
|
}
|
}
|