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
using System;
using System.Collections.Generic;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.Direction
{
    /// <summary>
    /// 网关添加可能的设备类型的一览画面,
    /// 它从[DeviceManagementMainForm]画面打开
    /// </summary>
    public class AddDeviceTypeListForm : UserCenterCommonForm
    {
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设定标题
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDeviceType));
 
            //初始化中部控件
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部控件
        /// </summary>
        private void InitMiddleFrame()
        {
            listView = new VerticalScrolViewLayout();
            listView.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listView);
 
            string objectText = string.Empty;
            string unSelectPic = string.Empty;
            string selectPic = string.Empty;
 
            //智能空气开关
            objectText = Language.StringByID(R.MyInternationalizationString.uAirSwitch);
            unSelectPic = "Device/CloudContrAirSwitch.png";
            selectPic = "Device/CloudContrAirSwitchSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.CloudContr_AirSwitch);
 
            //窗帘电机
            objectText = Language.StringByID(R.MyInternationalizationString.uCurtainMotor);
            unSelectPic = "Device/AutoOpenCurtain.png";
            selectPic = "Device/AutoOpenCurtainSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.AutoOpen_Curtain);
 
            //2按键触摸面板
            objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDefultName202);
            var arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
            objectText = arry[0].Trim();
            unSelectPic = "Device/TwoButtonPanel.png";
            selectPic = "Device/TwoButtonPanelSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.Two_ButtonPanel);
 
            //3按键触摸面板
            objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDefultName201);
            arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
            objectText = arry[0].Trim();
            unSelectPic = "Device/ThreeButtonPanel.png";
            selectPic = "Device/ThreeButtonPanelSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.Three_ButtonPanel);
 
            //4按键触摸面板
            objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDefultName200);
            arry = objectText.Split(new string[] { "(" }, StringSplitOptions.RemoveEmptyEntries);
            objectText = arry[0].Trim();
            unSelectPic = "Device/FourButtonPanel.png";
            selectPic = "Device/FourButtonPanelSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.Four_ButtonPanel);
 
            //红外传感器
            objectText = Language.StringByID(R.MyInternationalizationString.uDeviceDefultName1303);
            unSelectPic = "Device/InfraredSensor.png";
            selectPic = "Device/InfraredSensorSelected.png";
            this.AddMenuRow(objectText, unSelectPic, selectPic, DeviceConcreteType.Pir_Sensor);
 
            ////第三方设备
            //objectText = Language.StringByID(R.MyInternationalizationString.uThirdPartyDevice);
            //unSelectPic = "Device/Relay.png";
            //selectPic = "Device/RelaySelected.png";
            //deviceType = DeviceType.UnKown;
            //this.AddMenuRow(objectText, unSelectPic, selectPic, deviceType);
        }
 
        /// <summary>
        /// 添加菜单栏
        /// </summary>
        /// <param name="objectText">显示文本</param>
        /// <param name="unSelectPic">图片:非点亮</param>
        /// <param name="selectPic">图片:点亮</param>
        /// <param name="deviceType">设备具体类型</param>
        private void AddMenuRow(string objectText, string unSelectPic, string selectPic, DeviceConcreteType deviceType)
        {
            var rowLayout = new StatuRowLayout(listView);
 
            //图标
            var btnIcon = new RowLeftIconView();
            btnIcon.UnSelectedImagePath = unSelectPic;
            btnIcon.SelectedImagePath = selectPic;
            rowLayout.AddChidren(btnIcon);
 
            //设备
            var btnObject = new RowCenterView();
            btnObject.Text = objectText;
            rowLayout.AddChidren(btnObject);
 
            //添加向右的图标
            rowLayout.AddRightIconControl();
 
            rowLayout.MouseUpEvent += (sender, e) =>
            {
                //第三方设备:直接进入配置设备阶段,因为也不知道它咋入网
                if (deviceType == DeviceConcreteType.UnKownDevice)
                {
                    var form = new Device.SearchDeviceForm();
                    this.AddForm(form);
                }
                else
                {
                    //让设备入网的指示图画面
                    var form = new Direction.AddDeviceDirectionForm();
                    this.AddForm(form, deviceType);
                }
            };
        }
    }
}