xm
2019-07-16 b910cb79c9b5bcc204022a3cf9e6950f0a64dfbd
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个显示设备+房间的RowLayout
    /// </summary>
    public class DeviceRoomViewRow : StatuRowLayout
    {
        /// <summary>
        /// 设备
        /// </summary>
        public CommonDevice device = null;
        /// <summary>
        /// 房间名字列表
        /// </summary>
        public List<string> listRoom = null;
        /// <summary>
        /// 图标控件
        /// </summary>
        public RowLeftIconView btnIcon = null;
        /// <summary>
        /// 设备控件
        /// </summary>
        public RowTopBlackView btnDevie = null;
        /// <summary>
        /// 房间控件
        /// </summary>
        public RowBottomGrayView btnRoom = null;
 
 
        /// <summary>
        /// 做成一个显示设备+房间的RowLayout
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="i_device"></param>
        /// <param name="i_listRoom"></param>
        public DeviceRoomViewRow(VerticalScrolViewLayout listView, CommonDevice i_device, List<string> i_listRoom = null)
        {
            this.device = i_device;
            this.listRoom = i_listRoom;
 
            listView.AddChidren(this);
            //初始化内部控件
            this.InitControl();
        }
 
        /// <summary>
        /// 做成一个显示设备+房间的RowLayout,加入父容器后,调用InitControl()执行初始化
        /// </summary>
        /// <param name="i_device"></param>
        /// <param name="i_listRoom"></param>
        public DeviceRoomViewRow(CommonDevice i_device, List<string> i_listRoom = null)
        {
            this.device = i_device;
            this.listRoom = i_listRoom;
        }
 
        /// <summary>
        /// 初始化内部控件
        /// </summary>
        public void InitControl()
        {
            //图标
            btnIcon = new RowLeftIconView();
            Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
 
            if (btnIcon.UnSelectedImagePath != null
                && btnIcon.UnSelectedImagePath.Contains(DeviceType.OnOffSwitch.ToString()) == true)
            {
                //将控件适配为【点号】控件
                btnIcon.ChangedControlInPointMode();
                btnIcon.UnSelectedImagePath = "Device/OnOffSwitch.png";
                btnIcon.SelectedImagePath = "Device/OnOffSwitchSelected.png";
            }
            this.AddChidren(btnIcon);
 
            //设备
            btnDevie = new RowTopBlackView();
            btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            this.AddChidren(btnDevie);
 
            //房间
            btnRoom = new RowBottomGrayView();
            if (this.listRoom != null)
            {
                btnRoom.Text = Common.Room.CurrentRoom.GetRoomName(this.listRoom);
            }
            else
            {
                btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
            }
            this.AddChidren(btnRoom);
        }
 
        /// <summary>
        /// 刷新全部显示信息
        /// </summary>
        /// <param name="i_device"></param>
        public void RefreshControlInfo(CommonDevice i_device)
        {
            this.device = i_device;
            btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
 
            var btnCom = new ButtonCommon();
            Common.LocalDevice.Current.SetDeviceIconToControl(btnCom, device);
            if (btnIcon.PointMode == true && btnCom.UnSelectedImagePath != null 
                && btnCom.UnSelectedImagePath.Contains(DeviceType.OnOffSwitch.ToString()) == false)
            {
                //变更为原来的大小
                btnIcon.ChangedControlInNormalMode();
            }
            btnIcon.UnSelectedImagePath = btnCom.UnSelectedImagePath;
            btnIcon.SelectedImagePath = btnCom.SelectedImagePath;
        }
    }
}