lixiaojun
2024-11-25 839d9f96be96108dc9ca9359b3db32596e7e2454
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
namespace Yw.WinFrmUI
{
    public partial class SetHydroWorkingPumpCtrl : DevExpress.XtraEditors.XtraUserControl, ISetHydroWorkingVisualCtrl
    {
        public SetHydroWorkingPumpCtrl()
        {
            InitializeComponent();
            this.layoutControl1.SetupLayoutControl();
            InitialLinkStatus();
        }
 
        /// <summary>
        /// 查看组件事件
        /// </summary>
        public event Action<Yw.Model.HydroVisualInfo> HydroViewEvent;
 
        //组件
        private Yw.Model.HydroPumpInfo _visual = null;
        //工况
        private HydroWorkingPumpViewModel _working = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(Yw.Model.HydroVisualInfo visual, HydroWorkingVisualViewModel working = null)
        {
            _visual = visual as Yw.Model.HydroPumpInfo;
            if (_visual == null)
            {
                return;
            }
            this.layoutGroupCaption.Text = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump);
            if (!string.IsNullOrEmpty(_visual.Name))
            {
                this.layoutGroupCaption.Text = _visual.Name;
            }
            _working = working as HydroWorkingPumpViewModel;
            if (_working == null)
            {
                _working = new HydroWorkingPumpViewModel(_visual);
            }
            this.imgCmbLinkStatus.EditValue = _working.LinkStatus;
            this.txtCurrentHz.EditValue = Math.Round(_working.CurrentHz, 1);
        }
 
        /// <summary>
        /// 获取工况
        /// </summary>
        public HydroWorkingVisualViewModel GetWorking()
        {
            if (_visual == null)
            {
                return default;
            }
            if (_working == null)
            {
                return default;
            }
            _working.LinkStatus = this.imgCmbLinkStatus.EditValue?.ToString();
            _working.CurrentHz = double.Parse(this.txtCurrentHz.EditValue.ToString());
            return _working;
        }
 
        //初始化管段状态
        private void InitialLinkStatus()
        {
            this.imgCmbLinkStatus.Properties.BeginUpdate();
            this.imgCmbLinkStatus.Properties.Items.Clear();
            this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Open), Yw.Hydro.PumpStatus.Open, -1);
            this.imgCmbLinkStatus.Properties.Items.Add(HydroLinkStatusHelper.GetStatusName(Yw.Hydro.PumpStatus.Closed), Yw.Hydro.PumpStatus.Closed, -1);
            this.imgCmbLinkStatus.Properties.EndUpdate();
        }
 
        //查看部件
        private void layoutGroupCaption_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
        {
            if (_visual == null)
            {
                return;
            }
            this.HydroViewEvent?.Invoke(_visual);
        }
 
        //开关状态决定设定频率的可用性
        private void imgCmbLinkStatus_EditValueChanged(object sender, EventArgs e)
        {
            var linkStatus = this.imgCmbLinkStatus.EditValue?.ToString();
            if (linkStatus == Yw.Hydro.PumpStatus.Open)
            {
                this.txtCurrentHz.Properties.ReadOnly = false;
            }
            else
            {
                this.txtCurrentHz.Properties.ReadOnly = true;
            }
        }
 
    }
}