using DevExpress.XtraEditors;
|
using System;
|
using System.Collections.Generic;
|
|
|
namespace IStation.WinFrmUI.Curve
|
{
|
public partial class InputCurveSplitSpanDlg : DevExpress.XtraEditors.XtraForm
|
{
|
|
public InputCurveSplitSpanDlg()
|
{
|
InitializeComponent();
|
}
|
|
double _min = 0;
|
double _max = 10000;
|
internal void SetBindingData(double min, double max)
|
{
|
this._min = min;
|
this._max = max;
|
}
|
|
|
internal void SetBindingData(List<double> list)
|
{
|
if (list == null || list.Count < 3)
|
return;
|
foreach (var m in list)
|
{
|
dataGridView1.Rows.Add(m);
|
}
|
textNumber.Value = list.Count;
|
}
|
|
|
//手动输入曲线
|
public List<double> GetSplitFlows()
|
{
|
if (dataGridView1.Rows.Count < 5)
|
{
|
XtraMessageBox.Show("至少5个点");
|
return null;
|
}
|
|
|
|
//
|
List<double> points = new List<double>();
|
|
try
|
{
|
for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
|
{
|
double x = double.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString());
|
|
points.Add(x);
|
}
|
points.Sort();
|
}
|
/*catch (System.ServiceModel.CommunicationException ex)
|
{
|
XtraMessageBox.Show( "通讯异常,请重试" , "Error:241 " + ex.Message);
|
return null;
|
}*/
|
catch (TimeoutException ex)
|
{
|
XtraMessageBox.Show("通讯超时,请重试", "Error:246 " + ex.Message);
|
return null;
|
}
|
catch (Exception ex)
|
{
|
XtraMessageBox.Show("请输入数字", ex.Message);
|
return null;
|
}
|
|
|
|
return points;
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
{
|
var points = GetSplitFlows();
|
if (points == null)
|
return;
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
this.Close();
|
}
|
|
|
|
private void labelControl1_Click(object sender, EventArgs e)
|
{
|
dataGridView1.Rows.Clear();
|
List<double> list = new List<double>();
|
int num = Convert.ToInt32(textNumber.Value);
|
for (int i = 1; i < num; i++)//少了两个点,
|
{
|
var v = Math.Round(this._min + (this._max - this._min) * i / num, 0);
|
dataGridView1.Rows.Add(v);
|
}
|
|
}
|
|
private void InputCurveSplitSpanDlg_Load(object sender, EventArgs e)
|
{
|
|
}
|
}
|
}
|