using DevExpress.XtraEditors;
|
using System;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
public partial class SetSingleCoordLxpNpshDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public event ChangeLxpCoordHandler OnChangedCoord = null;
|
|
private Eventech.Model.LxpCoordinateParas CoordinateParas = null;
|
|
public SetSingleCoordLxpNpshDlg()
|
{
|
InitializeComponent();
|
}
|
|
private void LoadWindow(object sender, EventArgs e)
|
{
|
}
|
Eventech.Model.UnitH _unitNPSH = Eventech.Model.UnitH.M;
|
public void SetBindingData(Eventech.Model.LxpCoordinateParas coord, Eventech.Model.UnitH UnitNPSH)
|
{
|
this.CoordinateParas = coord;
|
if (CoordinateParas == null)
|
return;
|
this._unitNPSH = UnitNPSH;
|
|
comboBoxType.Properties.Items.Add("刻度数,最大最小值");
|
comboBoxType.Properties.Items.Add("刻度数,间隔量,最小值");
|
comboBoxType.Properties.Items.Add("间隔量,最大最小值");
|
comboBoxType.SelectedIndex = 2;
|
|
|
labelMin.Text = "最小汽蚀";
|
labelMax.Text = "最大汽蚀";
|
checkBox1.Text = "从底部开始";
|
//labelSpace.Text = "流量/刻度";
|
if (_unitNPSH == Eventech.Model.UnitH.M)
|
{
|
textStart.Text = CoordinateParas.StartLineNoNPSH.ToString();
|
textNumber.Text = (CoordinateParas.EndLineNoNPSH - CoordinateParas.StartLineNoNPSH + 1).ToString();
|
textMin.Text = Math.Round((CoordinateParas.CoordMinNPSH + CoordinateParas.StartLineNoNPSH
|
* CoordinateParas.CoordSpaceNPSH), 3).ToString();
|
textMax.Text = Math.Round((CoordinateParas.CoordMinNPSH + CoordinateParas.EndLineNoNPSH
|
* CoordinateParas.CoordSpaceNPSH), 3).ToString();
|
textSpace.Text = CoordinateParas.CoordSpaceNPSH.ToString();
|
}
|
else
|
{
|
textStart.Text = CoordinateParas.StartLineNoNPSH.ToString();
|
textNumber.Text = (CoordinateParas.EndLineNoNPSH - CoordinateParas.StartLineNoNPSH + 1).ToString();
|
textMin.Text = Math.Round(Eventech.Common.UnitHHelper.fromM(_unitNPSH, (CoordinateParas.CoordMinNPSH + CoordinateParas.StartLineNoNPSH
|
* CoordinateParas.CoordSpaceNPSH)), 3).ToString();
|
textMax.Text = Math.Round(Eventech.Common.UnitHHelper.fromM(_unitNPSH, (CoordinateParas.CoordMinNPSH + CoordinateParas.EndLineNoNPSH
|
* CoordinateParas.CoordSpaceNPSH)), 3).ToString();
|
textSpace.Text = Math.Round(Eventech.Common.UnitHHelper.fromM(_unitNPSH, CoordinateParas.CoordSpaceNPSH), 3).ToString();
|
}
|
|
}
|
|
private void btnClose_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void btnSet_Click(object sender, EventArgs e)
|
{
|
if (OnChangedCoord == null || CoordinateParas == null)
|
return;
|
|
double space = 0;
|
int num = 0;
|
int start = 0;
|
double minValue = 0;
|
double maxValue = 0;
|
if (!double.TryParse(textSpace.Text, out space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.001)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
|
if (!int.TryParse(textNumber.Text, out num))
|
{
|
XtraMessageBox.Show("刻度数请输入合理值");
|
return;
|
}
|
if (num < 3)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (!int.TryParse(textStart.Text, out start))
|
{
|
XtraMessageBox.Show("刻度数请输入合理值");
|
return;
|
}
|
if (!double.TryParse(textMin.Text, out minValue))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (!double.TryParse(textMax.Text, out maxValue))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (maxValue < minValue)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
switch (comboBoxType.Text)
|
{
|
case "刻度数,最大最小值":
|
space = Math.Round((maxValue - minValue + 0.001) / (num - 1), 3);
|
textSpace.Text = space.ToString();
|
break;
|
case "刻度数,间隔量,最小值":
|
maxValue = minValue + space * (num - 1);
|
textMax.Text = maxValue.ToString();
|
break;
|
case "间隔量,最大最小值":
|
num = (int)((maxValue - minValue + 0.001) / space) + 1;
|
textNumber.Text = num.ToString();
|
break;
|
}
|
|
if (_unitNPSH == Eventech.Model.UnitH.M)
|
{
|
CoordinateParas.StartLineNoNPSH = start;
|
CoordinateParas.EndLineNoNPSH = start + num - 1;
|
CoordinateParas.CoordSpaceNPSH = space;
|
CoordinateParas.CoordMinNPSH = minValue - CoordinateParas.StartLineNoNPSH * CoordinateParas.CoordSpaceNPSH;
|
}
|
else
|
{
|
CoordinateParas.StartLineNoNPSH = start;
|
CoordinateParas.EndLineNoNPSH = start + num - 1;
|
CoordinateParas.CoordSpaceNPSH = Eventech.Common.UnitHHelper.toM2(_unitNPSH, space);
|
CoordinateParas.CoordMinNPSH = Eventech.Common.UnitHHelper.toM2(_unitNPSH, minValue - CoordinateParas.StartLineNoNPSH * CoordinateParas.CoordSpaceNPSH);
|
}
|
//
|
OnChangedCoord(this, new LxpCoordEventArgs(CoordinateParas));
|
}
|
|
private void checkBox1_CheckedChanged(object sender, EventArgs e)
|
{
|
textStart.Enabled = !checkBox1.Checked;
|
if (checkBox1.Checked)
|
{
|
textStart.Text = "0";
|
}
|
}
|
|
private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
switch (comboBoxType.Text)
|
{
|
case "刻度数,最大最小值":
|
labelNumber.Visible = true;
|
textNumber.Visible = true;
|
|
labelMin.Visible = true;
|
textMin.Visible = true;
|
|
labelMax.Visible = true;
|
textMax.Visible = true;
|
|
labelSpace.Visible = false;
|
textSpace.Visible = false;
|
break;
|
case "刻度数,间隔量,最小值":
|
labelNumber.Visible = true;
|
textNumber.Visible = true;
|
|
labelMin.Visible = true;
|
textMin.Visible = true;
|
|
labelMax.Visible = false;
|
textMax.Visible = false;
|
|
labelSpace.Visible = true;
|
textSpace.Visible = true;
|
break;
|
case "间隔量,最大最小值":
|
labelNumber.Visible = false;
|
textNumber.Visible = false;
|
|
labelMin.Visible = true;
|
textMin.Visible = true;
|
|
labelMax.Visible = true;
|
textMax.Visible = true;
|
|
labelSpace.Visible = true;
|
textSpace.Visible = true;
|
|
break;
|
|
}
|
|
|
}
|
|
|
}
|
}
|