黄学彪
2019-09-30 404cdc88627f942df7944af04ee05b9d527752d6
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个显示设备回路+房间的RowLayout
    /// </summary>
    public class DeviceRoomControl : RowLayoutControl
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 设备主键
        /// </summary>
        private string mainKey = string.Empty;
        /// <summary>
        /// 设备对象
        /// </summary>
        public CommonDevice device
        {
            get { return Common.LocalDevice.Current.GetDevice(mainKey); }
        }
        /// <summary>
        /// 图标控件
        /// </summary>
        public IconViewControl btnIcon = null;
        /// <summary>
        /// 设备控件
        /// </summary>
        public NormalViewControl btnDevie = null;
        /// <summary>
        /// 房间控件
        /// </summary>
        public NormalViewControl btnRoom = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 做成一个显示设备回路+房间的RowLayout
        /// </summary>
        /// <param name="i_device">设备对象</param>
        /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(真实值,有些界面需要这种特殊操作)</param>
        public DeviceRoomControl(CommonDevice i_device, int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
        {
            this.mainKey = Common.LocalDevice.Current.GetDeviceMainKeys(i_device);
        }
 
        /// <summary>
        /// 初始化内部控件
        /// </summary>
        public void InitControl()
        {
            //图标
            btnIcon = frameTable.AddLeftIcon();
            Common.LocalDevice.Current.SetDeviceIconToControl(btnIcon, device);
 
            //设备
            string eName = Common.LocalDevice.Current.GetDeviceEpointName(device);
            btnDevie = frameTable.AddLeftCaption(eName, 600, 60);
            btnDevie.TextSize = 15;
            //这个坐标有点特殊
            btnDevie.Y = Application.GetRealHeight(12) + this.chidrenYaxis;
            frameTable.AddChidren(btnDevie, ChidrenBindMode.BindEventOnly);
 
            //房间
            string roomName = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
            btnRoom = frameTable.AddLeftCaption(roomName, 600, 50, true);
            //这个坐标有点特殊
            btnRoom.Y = Application.GetRealHeight(72) + this.chidrenYaxis;
            btnRoom.TextSize = 12;
            btnRoom.TextColor = UserCenterColor.Current.TextGrayColor1;
            frameTable.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly);
        }
 
        #endregion
 
        #region ■ 刷新信息___________________________
 
        /// <summary>
        /// 刷新全部显示信息
        /// </summary>
        /// <param name="i_device"></param>
        public void RefreshControlInfo()
        {
            btnDevie.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            btnRoom.Text = Common.Room.CurrentRoom.GetRoomNameByDevice(device);
 
            string unSelectPath = string.Empty;
            string selectPath = string.Empty;
            Common.LocalDevice.Current.GetDeviceIcon(device, ref unSelectPath, ref selectPath);
 
            btnIcon.UnSelectedImagePath = unSelectPath;
        }
        #endregion
    }
}