lixiaojun
2024-10-18 5043208b24f45b3e3c630a596b9e83373096a78a
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using DevExpress.XtraEditors;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace Yw.WinFrmUI
{
    public partial class SetWaterboxCalcuPrefixCtrl : DevExpress.XtraEditors.XtraUserControl
    {
        public SetWaterboxCalcuPrefixCtrl()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 查看事件
        /// </summary>
        public event Action<Yw.Model.HydroWaterboxInfo> ViewEvent;
 
        /// <summary>
        /// 查看曲线事件
        /// </summary>
        public event Action<Yw.Model.HydroWaterboxInfo> ViewCurveEvent;
 
 
        private Yw.Model.HydroWaterboxInfo _waterbox = null; //水箱
 
        /// <summary>
        /// 绑定
        /// </summary>
        public void SetBindingData(Yw.Model.HydroWaterboxInfo waterbox)
        {
            _waterbox = waterbox;
            if (_waterbox == null)
            {
                return;
            }
            this.layoutGroupCaption.Text = "水箱";
            if (!string.IsNullOrEmpty(_waterbox.Name))
            {
                this.layoutGroupCaption.Text = _waterbox.Name;
            }
            this.txtPoolElev.EditValue = _waterbox.PoolElev;
            this.txtInitLevel.EditValue = _waterbox.InitLevel;
            this.txtMinLevel.EditValue = _waterbox.MinLevel;
            this.txtMaxLevel.EditValue = _waterbox.MaxLevel;
            this.txtMinVol.EditValue = _waterbox.MinVol;
            this.btnEditVolCurve.EditValue = string.IsNullOrEmpty(_waterbox.DbId) ? "未匹配" : "已匹配"; ;
            this.ckOverFlow.Checked = _waterbox.OverFlow;
        }
 
        /// <summary>
        /// 
        /// </summary>
        public void UpdateBindingData()
        {
            if (_waterbox == null)
            {
                return;
            }
            _waterbox.PoolElev = double.Parse(this.txtPoolElev.EditValue?.ToString());
            _waterbox.InitLevel = double.Parse(this.txtInitLevel.EditValue?.ToString());
            _waterbox.MinLevel = double.Parse(this.txtMinLevel.EditValue.ToString());
            _waterbox.MaxLevel = double.Parse(this.txtMaxLevel.EditValue?.ToString());
            _waterbox.MinVol = double.Parse(this.txtMinVol.EditValue.ToString());
            _waterbox.OverFlow = this.ckOverFlow.Checked;
        }
 
        //查看曲线
        private void btnEditVolCurve_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (_waterbox == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(_waterbox.DbId))
            {
                TipFormHelper.ShowWarn("尚未匹配");
                return;
            }
            this.ViewCurveEvent?.Invoke(_waterbox);
        }
 
        //查看部件
        private void layoutGroupCaption_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
        {
            if (_waterbox == null)
            {
                return;
            }
            this.ViewEvent?.Invoke(_waterbox);
        }
 
 
    }
}