using DevExpress.XtraEditors;
|
using System;
|
|
namespace IStation.WinFrmUI.Basic
|
{
|
public partial class SetSingleCoordLxpQDlg : DevExpress.XtraEditors.XtraForm
|
{
|
private Eventech.Model.UnitQ _currentUnit = Eventech.Model.UnitQ.M3H;
|
public SetSingleCoordLxpQDlg()
|
{
|
InitializeComponent();
|
|
comboUnit.Properties.Items.AddRange(Eventech.Common.UnitQHelper.GetEnUnitNameList());
|
comboUnit.SelectedIndex = 1;//默认流量单位m³/kedu_d
|
_currentUnit = Eventech.Model.UnitQ.M3H;
|
}
|
|
private void LoadWindow(object sender, EventArgs e)
|
{
|
LocationDialog();
|
}
|
|
//翻译界面语言
|
private void LocationDialog()
|
{
|
|
}
|
|
Eventech.Model.LxpCoordinateParas _lxpCoordinateParas = null;
|
public void SetBindingData(Eventech.Model.LxpCoordinateParas coord, Eventech.Model.UnitQ? unitQ = null)
|
{
|
if (coord == null)
|
return;
|
|
this._currentUnit = Eventech.Model.UnitQ.M3H;
|
if (unitQ != null)
|
{
|
this._currentUnit = unitQ.Value;
|
}
|
this._lxpCoordinateParas = coord;
|
|
|
labelMin.Text = "最小流量";
|
labelMax.Text = "最大流量";
|
|
comboBoxType.Properties.Items.Add("刻度数,最大最小值");
|
comboBoxType.Properties.Items.Add("刻度数,间隔量,最小值");
|
comboBoxType.Properties.Items.Add("间隔量,最大最小值");
|
comboBoxType.SelectedIndex = 2;
|
|
textNumber.Text = (coord.GridNumberX + 1).ToString();
|
textMin.SetValue(Math.Round(
|
Eventech.Common.UnitQHelper.fromM3H(_currentUnit, coord.CoordMinQ), 2));
|
textMax.SetValue(Math.Round(
|
Eventech.Common.UnitQHelper.fromM3H(_currentUnit,
|
coord.CoordMinQ + coord.GridNumberX * coord.CoordSpaceQ), 2));
|
textSpace.SetValue(Math.Round(
|
Eventech.Common.UnitQHelper.fromM3H(_currentUnit, coord.CoordSpaceQ), 2));
|
|
comboUnit.Enabled = false;
|
|
comboUnit.SelectedIndex = (int)_currentUnit;
|
}
|
|
|
|
public event ChangeLxpCoordHandler OnChangedCoord = null;
|
|
private void comboBoxType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
switch (comboBoxType.SelectedIndex)
|
{
|
case 0:
|
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 1:
|
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 2:
|
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;
|
}
|
|
|
}
|
|
|
private void comboUnit_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
|
}
|
|
private void btnSet_Click(object sender, EventArgs e)
|
{
|
double space = 0;
|
int num = 0;
|
double minValue = 0;
|
double maxValue = 0;
|
if (!double.TryParse(textSpace.Text, out space))
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
if (space < 0.01)
|
{
|
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.SelectedIndex)
|
{
|
case 0:
|
if (!int.TryParse(textNumber.Text, out num))
|
{
|
XtraMessageBox.Show("刻度数请输入合理值");
|
return;
|
}
|
if (num < 3)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
space = Math.Round((maxValue - minValue) / (num - 1), 3);
|
textSpace.Text = space.ToString();
|
break;
|
case 1:
|
if (!int.TryParse(textNumber.Text, out num))
|
{
|
XtraMessageBox.Show("刻度数请输入合理值");
|
return;
|
}
|
if (num < 3)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
maxValue = minValue + (space * (num - 1));
|
textMax.Text = maxValue.ToString();
|
break;
|
case 2:
|
num = (int)((maxValue - minValue) / space) + 1;
|
textNumber.Text = num.ToString();
|
if (num < 4)
|
{
|
XtraMessageBox.Show("请输入合理值");
|
return;
|
}
|
break;
|
}
|
|
|
|
|
if (OnChangedCoord != null)
|
{
|
_lxpCoordinateParas.GridNumberX = num - 1;
|
_lxpCoordinateParas.CoordSpaceQ = Eventech.Common.UnitQHelper.toM3H(this._currentUnit, space);
|
_lxpCoordinateParas.CoordMinQ = Eventech.Common.UnitQHelper.toM3H(this._currentUnit, minValue);
|
|
OnChangedCoord(this, new LxpCoordEventArgs(this._lxpCoordinateParas));
|
}
|
}
|
|
private void btnClose_Click(object sender, EventArgs e)
|
{
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.Close();
|
}
|
|
}
|
}
|