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
57
58
59
60
61
62
using DevExpress.XtraEditors;
 
namespace Yw.WinFrmUI.Phart
{
    public partial class ValveEditDlg : XtraForm
    {
        public ValveEditDlg()
        {
            InitializeComponent();
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Func<string, Task<bool>> ReloadDataEvent;
 
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void SetBindingData(string pt_list_json)
        { 
            var pt_list = Yw.JsonHelper.Json2Object<List<Yw.Geometry.Point2d>>(pt_list_json);
            if (pt_list == null || pt_list.Count == 0)
            {
                return;
            }
            var ql = new Yw.Geometry.CubicSpline2d(pt_list);
            this.curveExpressEditCtrl1.SetBindingData(ql);
        }
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Yw.Geometry.Point2d> pt_ql_list,
                    List<Yw.Geometry.Point2d> def_pt_ql_list)
        {
            this.curveExpressEditCtrl1.SetBindingData(pt_ql_list, def_pt_ql_list);
        }
 
        //确定
        private async void btnOk_Click(object sender, EventArgs e)
        {
            var bol = this.curveExpressEditCtrl1.GetPoints(
                out List<Yw.Geometry.Point2d> pt_ql_list);
            if (!bol)
            {
                return;
            }
 
            var pt_list_json = Yw.JsonHelper.Object2Json(pt_ql_list);
            var result = await this.ReloadDataEvent?.Invoke(pt_list_json);
            if (!result)
            {
                XtraMessageBox.Show("更新失败!");
                return;
            }
            XtraMessageBox.Show("更新成功!");
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}