HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/BindCommonLayout.cs
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using ZigBee.Device;
@@ -6,73 +7,176 @@
{
    public class BindCommonLayout : FrameLayout
    {
        public BindCommonLayout()
        {
        }
        #region ◆ 变量申明__________________________
        /// <summary>
        /// 楼层回调
        /// </summary>
        public Action FloorAction = null;
        /// <summary>
        /// 选中的楼层回调
        /// </summary>
        public Action<string, Button> ChooseFloorAction = null;
        /// <summary>
        ///  重新加载
        /// </summary>
        public Action ReLoadAction = null;
        public FrameLayout topFrameLayout = new FrameLayout { Height = Application.GetRealHeight(184), BackgroundColor = ZigbeeColor.Current.XMTopFrameLayout };
        public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1921 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout };
        public FrameLayout bottomRadiusFrameLayout = new FrameLayout()
        {
            Height = Application.GetRealHeight(100),
            Y = Application.GetRealHeight(930),
            Radius = 17,
            BackgroundColor = ZigbeeColor.Current.XMWhite,
        };
        public FrameLayout midFrameLayout = new FrameLayout { Height = Application.GetRealHeight(1925 - 184), BackgroundColor = ZigbeeColor.Current.XMMidFrameLayout };
        public FrameLayout titleFrameLayout = new FrameLayout
        {
            Y = Application.GetRealHeight(92),
            X = Application.GetRealWidth(161),
            Width = Application.GetRealWidth(1080 - 161),//919
            Height = Application.GetRealHeight(69),
        };
        public Button btnTitle = new Button
        {
            TextAlignment = TextAlignment.CenterLeft,
            TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText,
            X = Application.GetRealWidth(161),
            Width = Application.GetRealWidth(1080 - 161),
            Width = Application.GetRealWidth(1080 - 161),//919
            Height = Application.GetRealWidth(69),
            IsBold = true,
            TextSize = 17,
            IsBold = true,
            //X = Application.GetRealWidth(161 - 116),
        };
        /// <summary>
        /// 标题返回布局
        /// </summary>
        public FrameLayout btnBackFrameLayout = new FrameLayout
        {
            X = Application.GetRealWidth(58),
            Height = Application.GetRealHeight(58),
            Width = Application.GetRealWidth(58),
            Width = Application.GetRealWidth(58 * 2),//116
        };
        /// <summary>
        /// 标题返回按键
        /// </summary>
        public Button btnBack = new Button
        {
            Height = Application.GetRealHeight(51),
            Width = Application.GetRealWidth(30),
            X = Application.GetRealWidth(58),
            Y = Application.GetRealHeight(98),
            UnSelectedImagePath = "DoorLock/Left.png",
        };
        /// <summary>
        /// 标题下线
        /// </summary>
        public Button btnTitleLine = new Button
        {
            Y = Application.GetRealHeight(181),
            Height = 1,
            BackgroundColor = Shared.Common.ZigbeeColor.Current.XMTitleLine,
        };
        #region 底部有圆角布局
        /// 背景阴影界面
        /// </summary>
        public FrameLayout shadowRadiusFrameLayout = new FrameLayout { BackgroundColor = 0x0f000000 };
        /// <summary>
        /// 设置圆角的界面
        /// </summary>
        public FrameLayout bottomRadiusFrameLayout = new FrameLayout()
        {
            Height = Application.GetRealHeight(806),
            Y = Application.GetRealHeight(930),
            BackgroundColor = ZigbeeColor.Current.XMWhite,
        };
        /// <summary>
        /// 底部圆角中的取消按钮
        /// </summary>
        public Button btnCancel = new Button
        {
            X = Application.GetRealWidth(81),
            Y = Application.GetRealHeight(40),
            Height = Application.GetRealHeight(58),
            Width = Application.GetRealWidth(101),
            Text = Language.StringByID(R.MyInternationalizationString.Cancel),
            TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
            TextSize = 14,
        };
        /// <summary>
        /// 底部圆角中的标题栏
        /// </summary>
        public Button btnBottomTitle = new Button
        {
            X = Application.GetRealWidth(446 - 50),
            Y = Application.GetRealHeight(35),
            Height = Application.GetRealHeight(63),
            Width = Application.GetRealWidth(284),
            Text = Language.StringByID(R.MyInternationalizationString.MatchPerson),
            TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
            TextSize = 16,
        };
        /// <summary>
        /// 底部圆角中的确认按钮
        /// </summary>
        public Button btnFinish = new Button
        {
            X = Application.GetRealWidth(919),
            Y = Application.GetRealHeight(40),
            Height = Application.GetRealHeight(58),
            Width = Application.GetRealWidth(101),
            Text = Language.StringByID(R.MyInternationalizationString.Complete),
            TextColor = Shared.Common.ZigbeeColor.Current.XMOrange,
            TextSize = 14,
        };
        /// <summary>
        /// 底部圆角中的标题栏下的线条
        /// </summary>
        public Button line = new Button()
        {
            Y = Application.GetRealHeight(138),
            Height = 1,
            BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
        };
        #endregion
        #endregion
        /// <summary>
        /// 门锁顶部布局
        /// 顶部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void TopFrameLayout(FrameLayout frameLayout, string titleText)
        {
            this.AddChidren(topFrameLayout);
            topFrameLayout.AddChidren(btnBackFrameLayout);
            topFrameLayout.AddChidren(titleFrameLayout);
            topFrameLayout.AddChidren(btnTitleLine);
            btnBackFrameLayout.AddChidren(btnBack);
            titleFrameLayout.AddChidren(btnTitle);
            btnTitle.Text = titleText;
            titleFrameLayout.AddChidren(btnBackFrameLayout);
            btnBackFrameLayout.AddChidren(btnBack);
            btnTitle.MouseLongEventHandler = (sender, e) =>
            {
                var f1 = new FrameLayout()
                {
                    Width = Application.GetRealWidth(400),
                    Gravity = Gravity.CenterHorizontal,
                };
                this.titleFrameLayout.AddChidren(f1);
                var btn1 = new Button()
                {
                    Width = Application.GetRealWidth(6),
                    Height = Application.GetRealHeight(6),
                    Radius = (uint)Application.GetRealWidth(3),
                    BackgroundColor = 0xff000000,
                };
                f1.AddChidren(btn1);
                f1.MouseLongEventHandler += (sender1, e1) =>
                {
                    ErrroInfoLayout(this);
                    f1.RemoveFromParent();
                };
            };
        }
        /// <summary>
        /// 门锁中部布局
        /// 中部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void MidFrameLayout(FrameLayout frameLayout)
@@ -83,7 +187,7 @@
        }
        /// <summary>
        /// 门锁底部布局
        /// 底部布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void BottomFrameLayout(FrameLayout frameLayout)
@@ -96,5 +200,417 @@
            };
            this.midFrameLayout.AddChidren(bottomFrameLayout1);
        }
        /// <summary>
        /// 门锁底部带圆角布局
        /// </summary>
        /// <param name="frameLayout"></param>
        public void BottomRadiusFrameLayout(FrameLayout frameLayout)
        {
            this.shadowRadiusFrameLayout.AddChidren(this.bottomRadiusFrameLayout);
            this.bottomRadiusFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            this.bottomRadiusFrameLayout.AddChidren(btnCancel);
            this.bottomRadiusFrameLayout.AddChidren(btnBottomTitle);
            this.bottomRadiusFrameLayout.AddChidren(btnFinish);
            this.bottomRadiusFrameLayout.AddChidren(line);
        }
        /// <summary>
        /// 显示重新加载的界面(主要是用在界面加载错误时,再次加载)
        /// </summary>
        public void ShowReLoadView()
        {
            var frame = new FrameLayout();
            frame.BackgroundColor = UserCenterColor.Current.White;
            frame.Tag = "ReLoadView";
            this.midFrameLayout.AddChidren(frame);
            //重新加载
            var btnReLoad = new BottomClickButton();
            btnReLoad.Gravity = Gravity.Center;
            btnReLoad.TextID = R.MyInternationalizationString.uDoReload;
            frame.AddChidren(btnReLoad);
            btnReLoad.ButtonClickEvent += (sender, e) =>
            {
                ReLoadAction?.Invoke();
                ReLoadAction = null;
            };
        }
        /// <summary>
        /// 添加楼层UI
        /// </summary>
        public void BindDownFrameLayout(FrameLayout frameLayout, Panel curControlDev, Dictionary<string, string> dicFloorList, ref Button btnFloorText)
        {
            var btnAddFrameLayout = new FrameLayout
            {
                X = Application.GetRealWidth(619),
            };
            this.titleFrameLayout.AddChidren(btnAddFrameLayout);
            btnFloorText = new Button
            {
                Width = Application.GetRealWidth(300 - 69 - 58),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
                IsBold = true,
                TextAlignment = TextAlignment.CenterRight,
            };
            btnAddFrameLayout.AddChidren(btnFloorText);
            var btnBindDownFrameLayout = new FrameLayout
            {
                Width = Application.GetMinReal(69 + 58),
                X = Application.GetRealWidth(300 - 69 - 58),
            };
            btnAddFrameLayout.AddChidren(btnBindDownFrameLayout);
            var btnBindDown = new Button
            {
                Height = Application.GetMinReal(69),
                Width = Application.GetMinReal(69),
                UnSelectedImagePath = "BindPic/BindDown.png",
                Gravity = Gravity.CenterVertical,
            };
            btnBindDownFrameLayout.AddChidren(btnBindDown);
            EventHandler<MouseEventArgs> eHandlerBindDown = (sender, e) =>
            {
                if (dicFloorList == null)
                {
                    dicFloorList = new Dictionary<string, string>();
                }
                SideslipFramelayout(curControlDev, dicFloorList);
            };
            btnBindDown.MouseDownEventHandler += eHandlerBindDown;
            btnBindDownFrameLayout.MouseDownEventHandler += eHandlerBindDown;
            if (Common.Config.Instance.Home.FloorDics.Count == 0)
            {
                btnAddFrameLayout.Width = 0;
            }
            else
            {
                btnAddFrameLayout.Width = Application.GetRealWidth(300);
            }
        }
        /// <summary>
        /// 楼层选择的侧边栏
        /// </summary>
        void SideslipFramelayout(Panel curControlDev, Dictionary<string, string> dicFloorList)
        {
            var dialog = new Dialog
            {
            };
            dialog.Show();
            var flMain = new FrameLayout { BackgroundColor = 0x00000000 };
            dialog.AddChidren(flMain);
            flMain.MouseUpEventHandler += (sender11, e11) =>
            {
                dialog.Close();
            };
            var sidelipFrameLayout = new FrameLayout()
            {
                Width = Application.GetMinReal(449),
                Y = Application.GetRealHeight(161),
                X = Application.GetRealWidth(596),
                BackgroundImagePath = "DoorLock/SideslipPic.png",
            };
            flMain.AddChidren(sidelipFrameLayout);
            var btnSelectFloor = new Button()
            {
                Width = Application.GetRealWidth(200),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(81),
                TextColor = Shared.Common.ZigbeeColor.Current.XMBlack,
                TextSize = 14,
                IsBold = true,
                TextAlignment = TextAlignment.CenterLeft,
                TextID = R.MyInternationalizationString.SelectFloor,
            };
            sidelipFrameLayout.AddChidren(btnSelectFloor);
            var sidelipVerticalScrolViewLayout = new VerticalScrolViewLayout()
            {
                Y = btnSelectFloor.Bottom + Application.GetRealHeight(45),
                Height = Application.GetRealHeight(600),
            };
            sidelipFrameLayout.AddChidren(sidelipVerticalScrolViewLayout);
            Button oldbutton = null;
            Button oldbuttonText = null;
            int count = 0;
            foreach (var floorId in dicFloorList.Keys)
            {
                var rowFrameLayout = new RowLayout()
                {
                    Height = Application.GetRealHeight(152),
                    LineColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
                    X = Application.GetRealWidth(81),
                };
                sidelipVerticalScrolViewLayout.AddChidren(rowFrameLayout);
                var btnAllMethod = new Button()
                {
                    Width = Application.GetMinReal(81),
                    Height = Application.GetMinReal(81),
                    UnSelectedImagePath = "Floor/Floor.png",
                    SelectedImagePath = "Floor/FloorSelected.png",
                    Gravity = Gravity.CenterVertical,
                };
                rowFrameLayout.AddChidren(btnAllMethod);
                var btnMethodText = new Button()
                {
                    Width = Application.GetRealWidth(311),
                    Height = Application.GetRealHeight(58),
                    X = Application.GetRealWidth(92),
                    Gravity = Gravity.CenterVertical,
                    TextColor = Shared.Common.ZigbeeColor.Current.XMGray3,
                    TextSize = 14,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = dicFloorList[floorId],
                };
                rowFrameLayout.AddChidren(btnMethodText);
                if (curControlDev.currentSelectFloorId == floorId)
                {
                    btnAllMethod.IsSelected = true;
                    btnAllMethod.IsBold = true;
                    btnMethodText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                }
                EventHandler<MouseEventArgs> hander = (sender, e) =>
                {
                    if (curControlDev.currentSelectFloorId == floorId)
                    {
                        return;
                    }
                    curControlDev.currentSelectFloorId = floorId;
                    if (!btnMethodText.IsSelected)
                    {
                        if (oldbutton != null)
                        {
                            oldbutton.IsSelected = false;
                        }
                        if (oldbuttonText != null)
                        {
                            oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3;
                        }
                        oldbutton = btnMethodText;
                        oldbuttonText = btnMethodText;
                        btnMethodText.IsSelected = true;
                        oldbuttonText.TextColor = Shared.Common.ZigbeeColor.Current.XMBlack;
                        oldbuttonText.IsBold = true;
                    }
                    int index = 0;
                    dialog.Close();
                    ChooseFloorAction?.Invoke(floorId, btnMethodText);
                };
                btnAllMethod.MouseUpEventHandler += hander;
                rowFrameLayout.MouseUpEventHandler += hander;
                btnMethodText.MouseUpEventHandler += hander;
                count++;
            }
            if (count == 0)
            {
                sidelipFrameLayout.Height = 0;
            }
            else if (count <= 4 && count > 0)
            {
                sidelipFrameLayout.Height = Application.GetRealHeight(180) + count * Application.GetRealHeight(150);
            }
            else
            {
                sidelipFrameLayout.Height = Application.GetMinReal(780);
            }
        }
        /// <summary>
        /// Layout
        /// </summary>
        public void ErrroInfoLayout(FrameLayout frameLayout)
        {
            // 准备加一需要输入密码才 dialog.Show();
            var editText = new EditText
            {
                Width = Application.GetRealWidth(800),
                Height = Application.GetMinReal(100),
                Text = "Bind",
                TextAlignment = TextAlignment.Center,
                TextSize = 12,
                Gravity = Gravity.Center,
                Radius = 10,
                BorderColor = 0xffff00,
                BorderWidth = 5,
                BackgroundColor = 0xff000000,
            };
            frameLayout.AddChidren(editText);
            Action<Shared.View> action = (obj) =>
            {
                if (editText.Text == "Bind")
                {
                    editText.RemoveFromParent();
                    var dialog = new Dialog
                    {
                    };
                    dialog.Show();
                    var flMain = new FrameLayout { BackgroundColor = 0xff000000 };
                    dialog.AddChidren(flMain);
                    flMain.MouseUpEventHandler += (sender11, e11) =>
                    {
                        dialog.Close();
                    };
                    var titleFrameLayout = new FrameLayout
                    {
                        BackgroundColor = 0xff2f2f2f,
                        Height = Application.GetMinReal(80),
                        Y = Application.GetMinReal(80),
                    };
                    dialog.AddChidren(titleFrameLayout);
                    var title = new Button
                    {
                        Width = Application.GetRealWidth(1080 - 200),
                        Text = "Search Error Infomation",
                        TextAlignment = TextAlignment.Center,
                        TextSize = 12,
                        IsBold = true,
                    };
                    titleFrameLayout.AddChidren(title);
                    title.MouseUpEventHandler += (sender11, e11) =>
                    {
                        dialog.Close();
                    };
                    var close = new Button
                    {
                        Height = Application.GetMinReal(80),
                        Width = Application.GetRealWidth(200),
                        X = Application.GetRealWidth(1080 - 200),
                        Text = "关闭",
                        TextAlignment = TextAlignment.CenterLeft,
                        TextSize = 12,
                        Radius = 5,
                    };
                    titleFrameLayout.AddChidren(close);
                    close.MouseUpEventHandler += (sender11, e11) =>
                    {
                        dialog.Close();
                    };
                    var contentLayout = new VerticalScrolViewLayout()
                    {
                        BackgroundColor = 0xff2f2f2f,
                        Y = titleFrameLayout.Bottom,
                        Height = Application.GetRealHeight(1710),
                    };
                    flMain.AddChidren(contentLayout);
                    var Info = GetErrorList();
                    for (int i = 0; i < Info.Count; i++)
                    {
                        var mess = Info[i];
                        var msgArry = mess.Split(new string[] { "[0]" }, StringSplitOptions.RemoveEmptyEntries);
                        var row = new RowLayout()
                        {
                            Height = Application.GetRealHeight(90),
                        };
                        contentLayout.AddChidren(row);
                        var btnText1 = new Button
                        {
                            Height = Application.GetMinReal(80),
                            Width = Application.GetRealWidth(200),
                            X = Application.GetRealWidth(5),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextSize = 10,
                            Text = msgArry[0],
                            IsBold = true,
                        };
                        row.AddChidren(btnText1);
                        var btnText2 = new Button
                        {
                            Height = Application.GetMinReal(80),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextSize = 8,
                            X = btnText1.Right,
                            Text = msgArry[1],
                        };
                        row.AddChidren(btnText2);
                        if (msgArry.Length > 2)
                        {
                            btnText2.Height = Application.GetRealHeight(90 / 2);
                            var btnText3 = new Button
                            {
                                X = btnText1.Right,
                                Y = Application.GetRealHeight(90 / 2),
                                Height = Application.GetRealHeight(90 / 2),
                                Text = msgArry[2],
                                TextAlignment = TextAlignment.CenterLeft,
                                TextSize = 8,
                            };
                            row.AddChidren(btnText3);
                        }
                    }
                }
            };
            editText.EditorEnterAction += action;
        }
        /// <summary>
        ///绑定错误表
        /// </summary>
        /// <returns></returns>
        private List<string> GetErrorList()
        {
            var sList = new List<string> { };
            sList.Add("0003:[0]获取按键支持的功能时,网关没回【 透传命令:0003 】");
            sList.Add("0003_switch:[0]获取开关具体类型时(私有功能第三级别),网关没回【透传命令:0003】");
            sList.Add("0003_dimmer:[0]获取调光具体类型时(私有功能第三级别),网关没回【透传命令:0003】");
            sList.Add("0003_curtain:[0]获取调光具体类型时(私有功能第三级别),网关没回【透传命令:0003】");
            sList.Add("108_ 6533:[0]读取面板的配置信息时,网关没回【命令108,属性6533】");
            sList.Add("120_ 6533:[0]配置面板功能时,网关没回【命令120,属性6533】");
            sList.Add("5001:[0]设备绑定时,网关没回【命令5001】");
            sList.Add("5001_1:[0]设备添加绑定目标时,网关绑定目标失败,绑定设备目标有漏掉【命令5001】");
            sList.Add("5001_2:[0]设备添加绑定目标时,网关回复未知错误【命令5001】");
            sList.Add("5003:[0]删除设备时,网关没回【命令5003】");
            sList.Add("5003_1:[0]当绑定空目标,发删除已经存在按键的目标时,[0]网关没回【命令5003】");
            sList.Add("5003_2:[0]当绑定空目标,发删除已经存在按键的目标时,[0]按键回复错误结果【命令5003】");
            sList.Add("5003_3:[0]当绑定空目标,发删除已经存在按键的目标时,[0]按键结果是空,网关回复错误结果【命令5003】");
            sList.Add("5003_4:[0]更换目标时,发删除按键旧的目标时,按键结果是空,[0]网关回复错误结果【命令5003】");
            sList.Add("5003_5:[0]更换目标时,发删除按键旧的目标时,[0]按键回复错误结果【命令5003】");
            sList.Add("5003_6:[0]更换目标时,发删除按键旧的目标时,按键结果是空,[0]网关回复错误结果【命令5003】");
            sList.Add("5003_7:[0]更换目标时,发删除按键旧的目标时,旧的同种类型的目标没有删除完,[0]不能绑定新的目标【命令5003】");
            sList.Add("5003_8:[0]删除单个设备,网关回复的结果是失败的【命令5003】");
            sList.Add("5003_9:[0]删除单个设备,网关回复错误单结果【命令5003】");
            sList.Add("5006:[0]删除按键所有绑定表时,网关没回【命令5006】");
            sList.Add("5007:[0]获取按键绑定表时, 网关没回【命令5007】");
            sList.Add("5007_1:[0]获取按键绑定表时,网关没回,结果是[0]获取多功能面板的目标个数不全【命令5007】");
            sList.Add("5007_2:[0]获取按键绑定的温度传感器失败【命令5007】");
            sList.Add("5007_3:[0]获取按键绑定的湿度度传感器失败【命令5007】");
            sList.Add("5020:[0]一对一绑定设备时,网关没回【命令5020】");
            sList.Add("5020_1:[0]一对一绑定,设备添加绑定目标时,[0]网关绑定目标失败,绑定设备不存在【命令5020】");
            sList.Add("5020_2:[0]一对一绑定,设备添加绑定目标时,网关绑定目标失败,[0]绑定未知,可能是等待节点设备回复【命令5020】");
            return sList;
        }
    }
}
}