using DevExpress.XtraEditors;
|
|
namespace Yw.WinFrmUI.Phart
|
{
|
public partial class ValveChartCoordinateDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public ValveChartCoordinateDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Action<ValveCoordinate> OnChangedCoord = null;
|
|
/// <summary>
|
/// 坐标参数
|
/// </summary>
|
public ValveCoordinate CoordinateParas
|
{
|
get => _coordinate_paras;
|
set => _coordinate_paras = value;
|
}
|
private ValveCoordinate _coordinate_paras = null;
|
|
|
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
/// <param name="coordinate">坐标参数</param>
|
public void SetBindingData(ValveCoordinate coordinate)
|
{
|
if (coordinate == null)
|
return;
|
|
_coordinate_paras = new ValveCoordinate(coordinate);
|
this.textMinDispQ.EditValue = _coordinate_paras.CoordMinQ;
|
|
this.textGridNumberX.EditValue = _coordinate_paras.GridNumberX;
|
this.textGridNumberY.EditValue = _coordinate_paras.GridNumberY;
|
this.textCoordSpaceQ.EditValue = _coordinate_paras.CoordSpaceQ;
|
this.textStartLineNoH.EditValue = _coordinate_paras.StartLineNoL;
|
this.textEndLineNoH.EditValue = _coordinate_paras.EndLineNoL;
|
|
this.textMaxDispH.EditValue = (_coordinate_paras.CoordMinL + _coordinate_paras.EndLineNoL * _coordinate_paras.CoordSpaceL);
|
this.textCoordSpaceH.EditValue = _coordinate_paras.CoordSpaceL;
|
|
}
|
|
|
|
private void btnSet_Click(object sender, EventArgs e)
|
{
|
if (_coordinate_paras == 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;
|
}
|
_coordinate_paras.GridNumberX = num;
|
|
if (!int.TryParse(this.textGridNumberY.Text, out num))
|
{
|
XtraMessageBox.Show("水损刻度数请输入合理值");
|
return;
|
}
|
_coordinate_paras.GridNumberY = num;
|
|
double.TryParse(this.textMinDispQ.Text, out double CoordMinQ);
|
|
_coordinate_paras.CoordMinQ = CoordMinQ;
|
_coordinate_paras.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;
|
}
|
|
_coordinate_paras.StartLineNoL = start;
|
_coordinate_paras.EndLineNoL = end;
|
_coordinate_paras.CoordSpaceL = space;
|
_coordinate_paras.CoordMinL = maxValue - _coordinate_paras.EndLineNoL * space;
|
|
this.OnChangedCoord?.Invoke(_coordinate_paras);
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
|
}
|
|
|
|
}
|
}
|