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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter
{
    /// <summary>
    /// 做成一个场景选择的行控件
    /// </summary>
    public class SceneSelectRow : StatuRowLayout
    {
        /// <summary>
        /// 场景(由初始化函数的参数指定,有可能为空)
        /// </summary>
        public Common.SceneRoomUI sceneRoomUI = null;
        /// <summary>
        /// 场景
        /// </summary>
        public Common.SceneUI sceneUI = null;
        /// <summary>
        /// 图片控件
        /// </summary>
        private PicViewControl btnImage = null;
        /// <summary>
        /// 场景名字控件
        /// </summary>
        private ViewNormalControl btnSceneName = null;
        /// <summary>
        /// 房间控件
        /// </summary>
        private ViewNormalControl btnRoom = null;
        /// <summary>
        /// 选择控件
        /// </summary>
        private MostRightEmptyView btnSelect = null;
        /// <summary>
        /// 模糊背景
        /// </summary>
        private ViewNormalControl btnBack = null;
        /// <summary>
        /// 状态
        /// </summary>
        private StatuMode Statu = StatuMode.UN_SELECT;
        /// <summary>
        /// 是否处于选择状态
        /// </summary>
        public bool IsSelected
        {
            get { return Statu == StatuMode.SELECT; }
            set
            {
                if (value == false)
                {
                    this.SetUnselectStatu();
                }
                else
                {
                    this.SetSelectStatu();
                }
            }
        }
 
        /// <summary>
        /// 行之间的间隔
        /// </summary>
        private int rowSpcace = 5;
 
        /// <summary>
        /// 做成一个场景选择的行控件
        /// </summary>
        /// <param name="listView">列表控件,可以为空</param>
        /// <param name="i_SceneRoomUI">场景</param>
        public SceneSelectRow(VerticalScrolViewLayout listView, Common.SceneRoomUI i_SceneRoomUI)
        {
            this.sceneRoomUI = i_SceneRoomUI;
            this.sceneUI = this.sceneRoomUI.sceneUI;
            this.Height = Application.GetRealHeight(365 + rowSpcace * 2);
 
            this.MouseUpEvent += (sender, e) =>
            {
                this.IsSelected = Statu == StatuMode.SELECT ? false : true;
            };
            if (listView != null)
            {
                listView.AddChidren(this);
                //初始化内部控件
                this.InitControl();
            }
        }
 
        /// <summary>
        /// 做成一个场景选择的行控件
        /// </summary>
        /// <param name="listView">列表控件,可以为空</param>
        /// <param name="i_SceneUI">场景</param>
        public SceneSelectRow(VerticalScrolViewLayout listView, Common.SceneUI i_SceneUI)
        {
            this.sceneUI = i_SceneUI;
            this.Height = Application.GetRealHeight(365 + rowSpcace * 2);
 
            this.MouseUpEvent += (sender, e) =>
            {
                this.IsSelected = Statu == StatuMode.SELECT ? false : true;
            };
            if (listView != null)
            {
                listView.AddChidren(this);
                //初始化内部控件
                this.InitControl();
            }
        }
 
        /// <summary>
        /// 初始化内部控件
        /// </summary>
        public void InitControl()
        {
            this.LineColor = UserCenterColor.Current.Transparent;
 
            //选择
            btnSelect = new MostRightEmptyView();
            btnSelect.Visible = false;
            btnSelect.UnSelectedImagePath = "Item/TickSelected.png";
            this.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly);
 
            //图片
            btnImage = new PicViewControl(Application.CurrentWidth - ControlCommonResourse.XXLeft * 2, this.Height - Application.GetRealHeight(rowSpcace * 2), false);
            btnImage.X = ControlCommonResourse.XXLeft;
            btnImage.UnSelectedImagePath = this.sceneUI.IconPath;
            btnImage.Radius = Common.CommonPage.BigFormRadius;
            btnImage.Gravity = Gravity.CenterVertical;
            this.AddChidren(btnImage, ChidrenBindMode.NotBind);
 
            //模糊背景
            this.btnBack = new ViewNormalControl(btnImage.Width, this.Height - Application.GetRealHeight(rowSpcace * 2));
            btnBack.Radius = Common.CommonPage.BigFormRadius;
            btnBack.X = ControlCommonResourse.XXLeft;
            btnBack.Gravity = Gravity.CenterVertical;
            btnBack.BackgroundColor = Common.ZigbeeColor.Current.GXCBlack70Color;
            this.AddChidren(btnBack, ChidrenBindMode.BindEventOnly);
 
            //房间
            btnRoom = new ViewNormalControl(600, true);
            btnRoom.X = Application.GetRealWidth(30) + ControlCommonResourse.XXLeft;
            btnRoom.TextSize = 10;
            btnRoom.TextColor = UserCenterColor.Current.White;
            this.AddChidren(btnRoom, ChidrenBindMode.BindEventOnly);
            if (this.sceneRoomUI != null)
            {
                btnRoom.Text = this.sceneRoomUI.room.Name;
            }
 
            //场景名
            btnSceneName = new ViewNormalControl(btnImage.Width, false);
            btnSceneName.TextAlignment = TextAlignment.Center;
            btnSceneName.Text = sceneUI.Name;
            btnSceneName.TextSize = 20;
            btnSceneName.TextColor = UserCenterColor.Current.White;
            btnSceneName.Gravity = Gravity.CenterVertical;
            this.AddChidren(btnSceneName, ChidrenBindMode.BindEventOnly);
        }
 
        /// <summary>
        /// 设定选择状态
        /// </summary>
        public void SetSelectStatu()
        {
            if (Statu == StatuMode.SELECT)
            {
                return;
            }
            btnSelect.Visible = true;
            btnSceneName.X = btnSceneName.X - Application.GetRealWidth(130);
            btnRoom.X = btnRoom.X - Application.GetRealWidth(130);
            btnBack.X = btnBack.X - Application.GetRealWidth(130);
            btnImage.X = btnImage.X - Application.GetRealWidth(130);
            //状态变更
            Statu = StatuMode.SELECT;
        }
 
        /// <summary>
        /// 设置非选择状态
        /// </summary>
        public void SetUnselectStatu()
        {
            if (Statu == StatuMode.UN_SELECT)
            {
                return;
            }
            btnSelect.Visible = false;
            btnSceneName.X = btnSceneName.X + Application.GetRealWidth(130);
            btnRoom.X = btnRoom.X + Application.GetRealWidth(130);
            btnBack.X = btnBack.X + Application.GetRealWidth(130);
            btnImage.X = btnImage.X + Application.GetRealWidth(130);
            //状态变更
            Statu = StatuMode.UN_SELECT;
        }
    }
}