wxr
2021-06-06 d7e25d6a5960b3495cd4d8a67545410e03ca7962
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
using Shared;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    public class SensorSmokePage : DeviceFunctionCardCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 图标
        /// </summary>
        private IconViewControl btnIcon = null;
        /// <summary>
        /// 文本控件
        /// </summary>
        private NormalViewControl btnSuctionView = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化白色区域的内容
        /// </summary>
        public override void InitFrameWhiteContent()
        {
            base.SetTitleText(Language.StringByID(StringId.Sensor));
 
            //添加第二索引页
            this.AddSecondPage();
            //初始化第一个索引页的内容
            this.InitFrameWhiteContent1();
            //初始化第二个索引页的内容
            this.InitFrameWhiteContent2();
 
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(this.device);
            //刷新界面状态
            this.RefreshFormStatu();
            //读取状态
            new System.Threading.Thread(() =>
            {
                DriverLayer.Control.Ins.SendReadCommand(device);
            })
            { IsBackground = true }.Start();
        }
 
        /// <summary>
        /// 初始化第一个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent1()
        {
            btnIcon = new IconViewControl(198)
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealWidth(146),
                UnSelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorSmokeStateBgIcon.png",
                SelectedImagePath = "FunctionIcon/ArmSensor/ArmSensorSmokeStateBgIconOn.png",
            };
            FrameWhiteCentet1.AddChidren(btnIcon);
 
            btnSuctionView = new NormalViewControl(300, 84, true)
            {
                Gravity = Gravity.CenterHorizontal,
                Y = btnIcon.Bottom,
                TextAlignment = TextAlignment.Center,
                TextSize = CSS_FontSize.TextFontSize,
                TextColor = CSS_Color.MainColor,
                SelectedTextColor = CSS_Color.AuxiliaryColor2,
            };
            FrameWhiteCentet1.AddChidren(btnSuctionView);
        }
 
        /// <summary>
        /// 初始化第二个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent2()
        {
            var paging = new ArmSensorHistroyPaging(device);
            paging.InitFrame(FrameWhiteCentet2);
        }
 
        #endregion
 
        #region ■ 设备状态反馈_______________________
 
        /// <summary>
        /// 设备状态反馈
        /// </summary>
        /// <param name="i_LocalDevice"></param>
        public override void DeviceStatuPush(Function i_LocalDevice)
        {
            //不是同一个东西
            if (this.device.sid != i_LocalDevice.sid) { return; }
 
            //刷新当前设备的状态缓存
            this.RefreshNowDeviceStatuMemory(i_LocalDevice);
            //刷新界面状态
            this.RefreshFormStatu();
        }
 
        #endregion
 
        #region ■ 发送各种命令_______________________
 
        #endregion
 
        #region ■ 刷新界面状态_______________________
 
        /// <summary>
        /// 刷新界面状态
        /// </summary>
        private void RefreshFormStatu()
        {
            Application.RunOnMainThread(() => {
                var temp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.Status);
                if (temp != null)
                {
                    if (temp.state == "alarm")
                    {
                        btnIcon.IsSelected = true;
                        btnSuctionView.TextID = StringId.InAlarm;
                        btnSuctionView.IsSelected = true;
                    }
                    else
                    {
                        btnIcon.IsSelected = false;
                        btnSuctionView.TextID = StringId.SensorNormalState;
                        btnSuctionView.IsSelected = false;
                    }
                }
            });
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 刷新当前设备的状态缓存
        /// </summary>
        private void RefreshNowDeviceStatuMemory(Function i_LocalDevice)
        {
            //foreach (var data in i_LocalDevice.status)
            //{
            //    if (data.key == "status")
            //    {
            //        if (data.value.ToLower() == "alarm")
            //        {
            //            this.btnIcon.IsSelected = true;
            //            this.btnSuctionView.IsSelected = true;
            //            this.btnSuctionView.TextID = StringId.InAlarm;
            //        }
            //        else
            //        {
            //            this.btnIcon.IsSelected = false;
            //            this.btnSuctionView.IsSelected = false;
            //            this.btnSuctionView.TextID = StringId.SensorNormalState;
            //        }
            //    }
            //}
        }
 
        #endregion
    }
}