Shuxia Ning
2024-12-19 b0c978129ba55cf81e8470b6c9326745a5dbc7d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using DevExpress.XtraEditors;
 
namespace Yw.WinFrmUI.Phart
{
    public partial class SetPointDlg : DevExpress.XtraEditors.XtraForm
    {
        public SetPointDlg()
        {
            InitializeComponent();
        }
 
        public event Func<double, double, bool> VerifyValueChanged;
 
        public void SetBindingData(double? x = null, double? y = null)
        {
            this.txtX.EditValue = x;
            this.txtY.EditValue = y;
        }
 
        private bool Verify()
        {
            this.dxErrorProvider1.ClearErrors();
            if (this.txtX.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtX, "必填项");
                return false;
            }
 
            if (this.txtY.EditValue == null)
            {
                this.dxErrorProvider1.SetError(this.txtY, "必填项");
                return false;
            }
 
            return true;
        }
 
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!Verify())
                return;
            if (VerifyValueChanged == null)
                return;
            var xValue = Convert.ToDouble(this.txtX.Text);
            var yValue = Convert.ToDouble(this.txtY.Text);
            var bol = this.VerifyValueChanged(xValue, yValue);
            if (!bol)
            {
                XtraMessageBox.Show("数值不合理!");
                return;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}