using DevExpress.XtraEditors;
|
using System;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
/// <summary>
|
/// 二元系数
|
/// </summary>
|
public partial class TwiceRatioMatrixDlg : XtraForm
|
{
|
public TwiceRatioMatrixDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<string, bool> ReloadDataEvent;
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void Set(string paras)
|
{
|
var model = Model.TwiceRatioMatrix.ToModel(paras);
|
if (model == null)
|
model = new Model.TwiceRatioMatrix();
|
this.spinEditA.EditValue = model.RatioA;
|
this.spinEditB.EditValue = model.RatioB;
|
this.spinEditC.EditValue = model.RatioC;
|
}
|
|
//验证
|
public bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.spinEditA.Text))
|
{
|
this.dxErrorProvider1.SetError(this.spinEditA, "必填项");
|
return default;
|
}
|
if (string.IsNullOrEmpty(this.spinEditB.Text))
|
{
|
this.dxErrorProvider1.SetError(this.spinEditB, "必填项");
|
return default;
|
}
|
if (string.IsNullOrEmpty(this.spinEditC.Text))
|
{
|
this.dxErrorProvider1.SetError(this.spinEditC, "必填项");
|
return default;
|
}
|
return true;
|
}
|
|
private void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
|
var model = new Model.TwiceRatioMatrix();
|
model.RatioA = Convert.ToDouble(this.spinEditA.EditValue);
|
model.RatioB = Convert.ToDouble(this.spinEditB.EditValue);
|
model.RatioC = Convert.ToDouble(this.spinEditC.EditValue);
|
var json = model.ToJson();
|
|
if (model.RatioA == 0 && model.RatioB == 1 && model.RatioC == 0)
|
{
|
json = string.Empty;
|
}
|
if (this.ReloadDataEvent != null)
|
{
|
var bol = this.ReloadDataEvent(json);
|
if (!bol)
|
{
|
XtraMessageBox.Show("设置失败!");
|
return;
|
}
|
XtraMessageBox.Show("设置成功!");
|
}
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
this.Close();
|
|
}
|
}
|
}
|