黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.Guide
{
    /// <summary>
    /// 引导界面的共通界面
    /// </summary>
    public class GuideCommonForm : FrameLayoutBase
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 场景和功能的控件
        /// </summary>
        public FrameLayout contrSwitch = null;
        /// <summary>
        /// 场景控件
        /// </summary>
        public NormalViewControl btnScene = null;
        /// <summary>
        /// 功能
        /// </summary>
        public NormalViewControl btnFunction = null;
        /// <summary>
        /// 住宅名称
        /// </summary>
        public NormalViewControl btnHouse = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 显示界面
        /// </summary>
        public virtual void ShowFrom()
        {
            Phone.MainPage.LeftListRoomViewFrom.Instance.CanClick = false;
 
            UserView.UserPage.Instance.AddChidren(this);
            this.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
 
            //住宅列表图标
            var btnHouseIcon = new IconViewControl(69);
            btnHouseIcon.UnSelectedImagePath = "Item/Floor.png";
            btnHouseIcon.Y = Application.GetRealHeight(86);
            btnHouseIcon.X = HdlControlResourse.XXLeft;
            this.AddChidren(btnHouseIcon);
            //消息图标
            var btnMsg = new IconViewControl(69);
            btnMsg.Y = Application.GetRealHeight(86);
            btnMsg.X = Application.GetRealWidth(953);
            btnMsg.UnSelectedImagePath = "Item/Message.png";
            this.AddChidren(btnMsg);
            //住宅名字
            this.btnHouse = new NormalViewControl(300, 95, true);
            btnHouse.TextSize = 24;
            btnHouse.X = HdlControlResourse.XXLeft;
            btnHouse.Y = Application.GetRealHeight(161);
            btnHouse.TextID = R.MyInternationalizationString.uMyResidence;
            this.AddChidren(btnHouse);
 
            //左右滑动控件的背景容器
            var frameBack = new FrameLayout();
            frameBack.Y = Application.GetRealHeight(302);
            frameBack.Width = this.Width; ;
            frameBack.Height = Application.GetRealHeight(478);
            this.AddChidren(frameBack);
 
            //房间滑动控件左边的虚拟图片
            var mLeftImageView = new ImageView();
            mLeftImageView.ImagePath = "RoomIcon/1.jpg";
            mLeftImageView.Radius = (uint)Application.GetRealHeight(17);
            mLeftImageView.Width = Application.GetRealWidth(717);
            mLeftImageView.Height = Application.GetRealHeight(478);
            //房间滑动控件右边的虚拟图片
            var mRightImageView = new ImageView();
            mRightImageView.ImagePath = "RoomIcon/2.jpg";
            mRightImageView.Radius = (uint)Application.GetRealHeight(17);
            mRightImageView.Width = mLeftImageView.Width;
            mRightImageView.Height = mLeftImageView.Height;
 
            //左右滑动的房间
            var roomPageView = new HorizontalPages();
            roomPageView.Width = frameBack.Width;
            roomPageView.Height = frameBack.Height;
            frameBack.AddChidren(roomPageView);
            //突出边距
            roomPageView.TCBJ = Application.GetRealWidth(124);
            //两个page之间的间距
            roomPageView.JMBJ = Application.GetRealWidth(58);
            //在这个控件的下面添加阴影效果
            var btnRoomBottomShadow = new NormalViewControl(717, 81, true);
            btnRoomBottomShadow.Y = frameBack.Bottom;
            btnRoomBottomShadow.Gravity = Gravity.CenterHorizontal;
            btnRoomBottomShadow.UnSelectedImagePath = "Room/RoomCardShadow.png";
            this.AddChidren(btnRoomBottomShadow);
 
            //设置控制最左和最右2边填充的假背景View,不设置不显示,需要在AddChidren 前调用该方法
            roomPageView.SetLeftAndRightImageView(mLeftImageView, mRightImageView);
 
            //客厅
            var room1 = new Common.Room();
            room1.BackgroundImage = "RoomIcon/0.jpg";
            room1.Name = Language.StringByID(R.MyInternationalizationString.uLivingRoom);
            var roomView1 = new Phone.Device.CommonForm.RoomView(0, 0);
            roomPageView.AddChidren(roomView1);
            roomView1.Init(room1);
            roomView1.HideName(false);
            //阳台
            var room2 = new Common.Room();
            room2.BackgroundImage = "RoomIcon/1.jpg";
            room2.Name = Language.StringByID(R.MyInternationalizationString.uBalcony);
            var roomView2 = new Phone.Device.CommonForm.RoomView(0, 0);
            roomPageView.AddChidren(roomView2);
            roomView2.Init(room2);
            roomView2.HideName(true);
            //卧室
            var room3 = new Common.Room();
            room3.BackgroundImage = "RoomIcon/2.jpg";
            room3.Name = Language.StringByID(R.MyInternationalizationString.uBedroom);
            var roomView3 = new Phone.Device.CommonForm.RoomView(0, 0);
            roomPageView.AddChidren(roomView3);
            roomView3.Init(room3);
            roomView3.HideName(true);
 
            //在房间卡片左边添加遮罩
            var btnRoomLeftShadow = new FrameLayout();
            btnRoomLeftShadow.Width = Application.GetRealWidth(124);
            btnRoomLeftShadow.Height = roomPageView.Height - roomPageView.JMBJ * 2;
            btnRoomLeftShadow.Gravity = Gravity.CenterVertical;
            btnRoomLeftShadow.BackgroundColor = 0x1c000000;
            btnRoomLeftShadow.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomRight);
            frameBack.AddChidren(btnRoomLeftShadow);
 
            //在房间卡片右边添加遮罩
            var btnRoomRightShadow = new FrameLayout();
            btnRoomRightShadow.Width = btnRoomLeftShadow.Width;
            btnRoomRightShadow.Height = btnRoomLeftShadow.Height;
            btnRoomRightShadow.X = Application.GetRealWidth(956);
            btnRoomRightShadow.Gravity = Gravity.CenterVertical;
            btnRoomRightShadow.BackgroundColor = btnRoomLeftShadow.BackgroundColor;
            btnRoomRightShadow.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerBottomLeft);
            frameBack.AddChidren(btnRoomRightShadow);
 
            //控件开始滑动的事件
            roomPageView.StartScrollAction += () =>
            {
                //开始滑动时,隐藏当前的数据显示
                (roomPageView.GetChildren(roomPageView.PageIndex) as Phone.Device.CommonForm.RoomView).HideName(true);
                btnRoomLeftShadow.Visible = false;
                btnRoomRightShadow.Visible = false;
                btnRoomBottomShadow.Visible = false;
            };
            roomPageView.EndScrollAction += () =>
            {
                int curIndex = roomPageView.PageIndex;
                //前一张卡片
                if (roomPageView.GetChildren(curIndex - 1) != null)
                {
                    (roomPageView.GetChildren(curIndex - 1) as Phone.Device.CommonForm.RoomView).HideName(true);
                }
                //当前卡片
                if (roomPageView.GetChildren(curIndex) != null)
                {
                    (roomPageView.GetChildren(curIndex) as Phone.Device.CommonForm.RoomView).HideName(false);
                }
                //下一张卡片
                if (roomPageView.GetChildren(curIndex + 1) != null)
                {
                    (roomPageView.GetChildren(curIndex + 1) as Phone.Device.CommonForm.RoomView).HideName(true);
                }
                btnRoomLeftShadow.Visible = true;
                btnRoomRightShadow.Visible = true;
                btnRoomBottomShadow.Visible = true;
            };
            roomPageView.PageIndex = 0;
 
            //场景和功能的控件
            this.contrSwitch = new FrameLayout();
            contrSwitch.Y = frameBack.Bottom + Application.GetRealHeight(52);
            contrSwitch.Gravity = Gravity.CenterHorizontal;
            contrSwitch.Width = Application.GetRealWidth(804);
            contrSwitch.Height = Application.GetRealHeight(124);
            contrSwitch.Radius = (uint)Application.GetRealHeight(124) / 2;
            contrSwitch.BackgroundColor = 0xff232323;
            this.AddChidren(contrSwitch);
            //场景
            this.btnScene = new NormalViewControl(contrSwitch.Width / 2 - Application.GetRealHeight(124) / 2, contrSwitch.Height, false);
            btnScene.X = Application.GetRealHeight(124) / 2;
            btnScene.IsBold = true;
            btnScene.TextAlignment = TextAlignment.Center;
            btnScene.TextColor = 0xffffffff;
            btnScene.TextSize = 16;
            btnScene.TextID = R.MyInternationalizationString.uScence;
            contrSwitch.AddChidren(btnScene);
 
            //功能
            this.btnFunction = new NormalViewControl(btnScene.Width, contrSwitch.Height, false);
            btnFunction.X = btnScene.Right;
            btnFunction.TextAlignment = TextAlignment.Center;
            btnFunction.TextColor = 0xFFCBCACA;
            btnFunction.TextSize = 15;
            btnFunction.TextID = R.MyInternationalizationString.uFunction;
            contrSwitch.AddChidren(btnFunction);
 
            //自定义场景1
            var sceneView1 = new MainPage.Controls.SceneCardControl();
            sceneView1.X = Application.GetRealWidth(46);
            sceneView1.Y = frameBack.Bottom + Application.GetRealHeight(233);
            this.AddChidren(sceneView1);
            sceneView1.InitControl(new Common.SceneUI() { Name = "Getup", IconPath = "SceneIcon/0.png" });
            //自定义场景2
            var sceneView2 = new MainPage.Controls.SceneCardControl();
            sceneView2.X = Application.GetRealWidth(553);
            sceneView2.Y = sceneView1.Y;
            this.AddChidren(sceneView2);
            sceneView2.InitControl(new Common.SceneUI() { Name = "Relax", IconPath = "SceneIcon/1.png" });
            //自定义场景3
            var sceneView3 = new MainPage.Controls.SceneCardControl();
            sceneView3.X = sceneView1.X;
            sceneView3.Y = sceneView1.Bottom + Application.GetRealHeight(14);
            this.AddChidren(sceneView3);
            sceneView3.InitControl(new Common.SceneUI() { Name = "Dinner", IconPath = "SceneIcon/2.png" });
            //自定义场景4
            var sceneView4 = new MainPage.Controls.SceneCardControl();
            sceneView4.X = sceneView2.X;
            sceneView4.Y = sceneView3.Y;
            this.AddChidren(sceneView4);
            sceneView4.InitControl(new Common.SceneUI() { Name = "Goodnight", IconPath = "SceneIcon/3.png" });
 
            //底部菜单
            var frameMenu = new FrameLayout();
            frameMenu.Height = HdlControlResourse.BottomFrameHeight;
            frameMenu.Gravity = Gravity.BottomCenter;
            this.AddChidren(frameMenu);
            //线
            var btnLine = new NormalViewControl(frameMenu.Width, 1, false);
            btnLine.BackgroundColor = Common.ZigbeeColor.Current.GXCBottomLineColor;
            frameMenu.AddChidren(btnLine);
            //主页
            var btnMenuHome = new IconViewControl(10, false);
            btnMenuHome.X = Application.GetRealWidth(109);
            btnMenuHome.Width = this.GetPictrueRealSize(138);
            btnMenuHome.Height = this.GetPictrueRealSize(98);
            btnMenuHome.UnSelectedImagePath = "Navigation/HomeSelected.png";
            frameMenu.AddChidren(btnMenuHome);
            var btnMenuHomeName = new NormalViewControl(btnMenuHome.Width, Application.GetRealHeight(40), false);
            btnMenuHomeName.X = btnMenuHome.X;
            btnMenuHomeName.Y = btnMenuHome.Bottom;
            btnMenuHomeName.TextAlignment = TextAlignment.Center;
            btnMenuHomeName.TextColor = 0xFF232323;
            btnMenuHomeName.TextSize = 10;
            btnMenuHomeName.TextID = R.MyInternationalizationString.HomePage;
            frameMenu.AddChidren(btnMenuHomeName);
 
            //分类
            var btnFenlei = new IconViewControl(10, false);
            btnFenlei.X = Application.GetRealWidth(469);
            btnFenlei.Width = this.GetPictrueRealSize(138);
            btnFenlei.Height = this.GetPictrueRealSize(98);
            btnFenlei.UnSelectedImagePath = "Navigation/Category.png";
            frameMenu.AddChidren(btnFenlei);
            var btnFenleiName = new NormalViewControl(btnFenlei.Width, Application.GetRealHeight(40), false);
            btnFenleiName.X = btnFenlei.X;
            btnFenleiName.Y = btnFenlei.Bottom;
            btnFenleiName.TextAlignment = TextAlignment.Center;
            btnFenleiName.TextColor = 0xFF232323;
            btnFenleiName.TextSize = 10;
            btnFenleiName.TextID = R.MyInternationalizationString.Category;
            frameMenu.AddChidren(btnFenleiName);
 
            //我的
            var btnMy = new IconViewControl(10, false);
            btnMy.X = Application.GetRealWidth(832);
            btnMy.Width = this.GetPictrueRealSize(138);
            btnMy.Height = this.GetPictrueRealSize(98);
            btnMy.UnSelectedImagePath = "Navigation/Setting.png";
            frameMenu.AddChidren(btnMy);
            var btnMyName = new NormalViewControl(btnMy.Width, Application.GetRealHeight(40), false);
            btnMyName.X = btnMy.X;
            btnMyName.Y = btnMy.Bottom;
            btnMyName.TextAlignment = TextAlignment.Center;
            btnMyName.TextColor = 0xFF232323;
            btnMyName.TextSize = 10;
            btnMyName.TextID = R.MyInternationalizationString.Me;
            frameMenu.AddChidren(btnMyName);
        }
 
        #endregion
 
        #region ■ 一般方法___________________________
 
        /// <summary>
        /// 添加【我知道了】的按钮
        /// </summary>
        /// <returns></returns>
        public NormalViewControl AddIKnwonButton()
        {
            var btnContr = new NormalViewControl(397, 86, true);
            btnContr.BorderWidth = 1;
            btnContr.BorderColor = UserCenterColor.Current.White;
            btnContr.Radius = (uint)Application.GetRealHeight(86) / 2;
            btnContr.BackgroundColor = 0x26FFFFFF;
            btnContr.Gravity = Gravity.CenterHorizontal;
            btnContr.Y = Application.GetRealHeight(1650);
            btnContr.TextAlignment = TextAlignment.Center;
            btnContr.TextColor = UserCenterColor.Current.White;
            btnContr.TextSize = 16;
            btnContr.TextID = R.MyInternationalizationString.uIKnwon;
            this.AddChidren(btnContr);
 
            return btnContr;
        }
 
        #endregion
    }
}