黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/AddScenePage.cs
@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using Microsoft.AppCenter.Crashes;
using Shared.Common;
using Shared.Phone.UserCenter.Device;
using ZigBee.Device;
using static ZigBee.Device.BindObj;
using static ZigBee.Device.Panel;
namespace Shared.Phone.UserCenter.DeviceBind
{
    /// <summary>
    /// 普通面板的绑定场景界面【只可绑定1个场景】
    /// </summary>
    public class AddScenePage : BindCommonLayout
    {
        /// 构造函数
@@ -51,7 +52,7 @@
        /// <summary>
        /// 保存完成按钮
        /// </summary>
        Button btnFinifh;
        Button btnFinish;
        /// <summary>
        /// 楼层文本
        /// </summary>
@@ -165,7 +166,7 @@
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout);
            btnFinifh = new Button()
            btnFinish = new Button()
            {
                Width = Application.GetRealWidth(907),
                Gravity = Gravity.CenterHorizontal,
@@ -176,10 +177,10 @@
                IsBold = true,
                TextSize = 16,
            };
            bottomFrameLayout.AddChidren(btnFinifh);
            bottomFrameLayout.AddChidren(btnFinish);
            #endregion
            #region 数据处理
            #region 数据处理
            //获取楼层
            dicFloor = HdlRoomLogic.Current.GetFloorSortList();
            currentKey.currentSelectFloorId = BindInfo.GetCurrentSelectFloorId();
@@ -236,25 +237,25 @@
            if (curRoom.ListSceneId.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                btnFinish.Enable = false;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                btnFinish.Enable = true;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
            if (targetListDevice.Count == 0 && targetListScene.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                btnFinish.Enable = false;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                btnFinish.Enable = true;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
            btnFinifh.MouseUpEventHandler += (sender, e) =>
            btnFinish.MouseUpEventHandler += (sender, e) =>
            {
                bool isFinish = false;
                System.Threading.Tasks.Task.Run(() =>
@@ -284,9 +285,9 @@
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                        btnFinish.Enable = true;
                                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                                        CommonPage.Loading.Hide();
                                    });
                                    return;
@@ -300,13 +301,13 @@
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    btnFinish.Enable = true;
                                    btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                    var myTip = new Tip();
                                    myTip.Direction = AMPopTipDirection.None;
                                    myTip.CloseTime = 2;
                                    myTip.Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
                                    myTip.Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5006" + ")";
                                    myTip.Show(Common.CommonPage.Instance);
                                });
                                return;
@@ -318,13 +319,13 @@
                        {
                            Application.RunOnMainThread(() =>
                            {
                                btnFinifh.Enable = true;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                btnFinish.Enable = true;
                                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                CommonPage.Loading.Hide();
                                var myTip = new Tip();
                                myTip.Direction = AMPopTipDirection.None;
                                myTip.CloseTime = 2;
                                myTip.Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime);
                                myTip.Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "120_ 6533" + ")";
                                myTip.Show(Common.CommonPage.Instance);
                            });
                            return;
@@ -333,8 +334,8 @@
                        {
                            Application.RunOnMainThread(() =>
                            {
                                btnFinifh.Enable = true;
                                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                btnFinish.Enable = true;
                                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                var myTip = new Tip();
                                myTip.Direction = AMPopTipDirection.None;
                                myTip.CloseTime = 2;
@@ -396,16 +397,16 @@
                                            this.RemoveFromParent();
                                        }
                                        CommonPage.Loading.Hide();
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        btnFinish.Enable = true;
                                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    });
                                }
                                else if (dev.addedDeviceBindResponseData.Result == 1)
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        btnFinish.Enable = true;
                                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        CommonPage.Loading.Hide();
                                        new Tip()
                                        {
@@ -413,7 +414,7 @@
                                            Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
                                            Direction = AMPopTipDirection.Up,
                                            CloseTime = 1
                                        }.Show(btnFinifh);
                                        }.Show(btnFinish);
                                    });
                                    return;
                                }
@@ -421,8 +422,8 @@
                                {
                                    Application.RunOnMainThread(() =>
                                    {
                                        btnFinifh.Enable = true;
                                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        btnFinish.Enable = true;
                                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                        CommonPage.Loading.Hide();
                                        new Tip()
                                        {
@@ -430,7 +431,7 @@
                                            Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
                                            Direction = AMPopTipDirection.Up,
                                            CloseTime = 1
                                        }.Show(btnFinifh);
                                        }.Show(btnFinish);
                                    });
                                    return;
@@ -440,10 +441,10 @@
                            {
                                Application.RunOnMainThread(() =>
                                {
                                    btnFinifh.Enable = true;
                                    btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    btnFinish.Enable = true;
                                    btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                                    CommonPage.Loading.Hide();
                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
                                    new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5001" + ")", Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinish);
                                });
                                return;
@@ -510,7 +511,7 @@
                var btnRoom = new Button
                {
                    Height = Application.GetRealHeight(58),
                    Width = Application.GetRealWidth(127),
                    Width = Application.GetRealWidth(255),
                    Y = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(14),
                    Text = room.Name,
@@ -529,7 +530,7 @@
                    curentOldRoomFrameLayout = btnRoomFrameLayout;
                }
                if (index == roomTempList.Count - 1 && index > 3)
                if (index == roomTempList.Count - 1 && index > 2)
                {
                    var btnRoomFrameLayoutEmpty = new FrameLayout
                    {
@@ -568,23 +569,23 @@
                    curRoom = room;
                    if (curRoom.ListSceneId.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        btnFinish.Enable = false;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        btnFinish.Enable = true;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    if (targetListDevice.Count == 0 && targetListScene.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        btnFinish.Enable = false;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        btnFinish.Enable = true;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    RefreshSceneList(curRoom);
@@ -593,7 +594,7 @@
                btnRoomFrameLayout.MouseUpEventHandler += eHandlerRoom;
                index++;
            }
            BindInfo.FinishDisplay(roomTempList, btnFinifh);
            BindInfo.FinishDisplay(roomTempList, btnFinish);
            RefreshSceneList(curRoom);
        }
@@ -613,8 +614,8 @@
            var currentSceneUIList = GetMatchSceneUIList(curRoom);
            if (currentSceneUIList.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                btnFinish.Enable = false;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                return;
            }
            foreach (var scene in currentSceneUIList)
@@ -736,13 +737,13 @@
                    }
                    if (targetListDevice.Count == 0 && targetListScene.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        btnFinish.Enable = false;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        btnFinish.Enable = true;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                };
                rowLayout.MouseUpEventHandler += hander;
@@ -753,13 +754,13 @@
            }
            if (targetListDevice.Count == 0 && targetListScene.Count == 0)
            {
                btnFinifh.Enable = false;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                btnFinish.Enable = false;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
            }
            else
            {
                btnFinifh.Enable = true;
                btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                btnFinish.Enable = true;
                btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
            }
        }
@@ -906,13 +907,13 @@
                    RefreshSceneList(roomList[0]);
                    if (targetListDevice.Count == 0 && targetListScene.Count == 0)
                    {
                        btnFinifh.Enable = false;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                        btnFinish.Enable = false;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
                    }
                    else
                    {
                        btnFinifh.Enable = true;
                        btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        btnFinish.Enable = true;
                        btnFinish.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                    }
                    dialog.Close();
                };
@@ -942,7 +943,7 @@
        List<SceneUI> GetALlDispalyRoomSceneList()
        {
            currentKeyAllRoomSceneList.Clear();
            // 获取所有房间
            // 获取所有房间
            var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
            foreach (var room in listAllRoom)
            {