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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 安防记录的行控件
    /// </summary>
    public class SafeguardLogRowView : FrameLayout
    {
        /// <summary>
        /// 安防记录
        /// </summary>
        private SafeguardAlarmInfo safeInfo = null;
        /// <summary>
        /// 安防记录的行控件
        /// </summary>
        /// <param name="frame">容器控件(可以为null,此时请调用InitControl函数)</param>
        /// <param name="i_info">安防记录</param>
        public SafeguardLogRowView(SpecialFrameLayout frame, SafeguardAlarmInfo i_info)
        {
            this.safeInfo = i_info;
            if (i_info.AlarmType == SafeguardAlarmType.Sensor)
            {
                this.Height = ControlCommonResourse.NormalControlHeight * 3;
            }
            else if(i_info.AlarmType == SafeguardAlarmType.Safeguard)
            {
                this.Height = ControlCommonResourse.NormalControlHeight + Application.GetRealHeight(10);
            }
 
            if (frame != null)
            {
                var view = frame.GetChildren(frame.ChildrenCount - 1);
                if (view != null)
                {
                    this.Y = view.Bottom;
                }
                frame.AddChidren(this);
                //初始化控件
                this.InitControl();
            }
        }
 
        /// <summary>
        /// 初始化控件
        /// </summary>
        public void InitControl()
        {
            if (this.safeInfo.AlarmType == SafeguardAlarmType.Safeguard)
            {
                //初始化布防撤防模式的控件
                this.InitControlBySafeguardAlarm();
            }
            else if (this.safeInfo.AlarmType == SafeguardAlarmType.Sensor)
            {
                //初始化传感器上报模式的控件
                this.InitControlBySensorAlarm();
            }
        }
 
        /// <summary>
        /// 初始化布防撤防模式的控件
        /// </summary>
        private void InitControlBySafeguardAlarm()
        {
            //防区
            var btnSafeguard = new RowCenterView(false);
            btnSafeguard.Text = this.safeInfo.AlarmMsg;
            this.AddChidren(btnSafeguard);
 
            //时间:时分秒
            var btnTime = new RowMostRightTextView();
            btnTime.Text = this.safeInfo.Time;
            this.AddChidren(btnTime);
 
        }
 
        /// <summary>
        /// 初始化传感器上报模式的控件
        /// </summary>
        private void InitControlBySensorAlarm()
        {
            //防区名字
            var btnGarrison = new RowTopBlackView(false);
            btnGarrison.TextSize = 16;
            btnGarrison.Text = Common.LocalSafeguard.Current.GetGarrisonText(this.safeInfo.ZoneId);
            this.AddChidren(btnGarrison);
            btnGarrison.ReSetYaxis(UViewAlignment.Top);
 
            //时间:时分秒
            var btnTime = new RowMostRightTextView();
            btnTime.Text = this.safeInfo.Time;
            this.AddChidren(btnTime);
            btnTime.ReSetYaxis(UViewAlignment.Top);
 
            //设备
            var btnDevice = new RowCenterView(false);
            string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(this.safeInfo.DeviceAddr, this.safeInfo.DeviceEpoint);
            var device = Common.LocalDevice.Current.GetDevice(mainkeys);
            if (device == null)
            {
                //使用预备名字
                btnDevice.Text = this.safeInfo.DeviceName;
            }
            else
            {
                //使用当前的设备名字
                btnDevice.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
                //房间名字
                btnDevice.Text += "(" + this.safeInfo.RoomName + ")";
            }
            this.AddChidren(btnDevice);
 
            //报警信息
            var btnMsg = new RowBottomBlackView(false);
            btnMsg.Text = this.safeInfo.AlarmMsg;
            this.AddChidren(btnMsg);
            btnMsg.ReSetYaxis(UViewAlignment.Bottom);
 
            //电池电量
            if (this.safeInfo.BatteryMsg != null)
            {
                var btnBattery = new RowMostRightTextView();
                btnBattery.Text = this.safeInfo.BatteryMsg;
                this.AddChidren(btnBattery);
            }
            //被拆报警
            if (this.safeInfo.DemolishmentMsg != null)
            {
                var btnDemolishment = new RowMostRightTextView();
                btnDemolishment.Text = this.safeInfo.DemolishmentMsg;
                this.AddChidren(btnDemolishment);
                btnDemolishment.ReSetYaxis(UViewAlignment.Bottom);
            }
        }
    }
}