gxc
2020-02-28 66a9965c44ecc32a6696abca876ab9d1cd091584
ZigbeeApp/Shared/Phone/Device/Logic/DoorLockLogic/LockLogicCommunalPage.cs
@@ -18,7 +18,7 @@
            Tag = "LockLogic";
        }
        EditText logicTextBox;
        public void Show(Action action)
        public async void Show(Action action)
        {
            #region  最上面的布局代码
@@ -32,14 +32,15 @@
            var titleName = new Button
            {
                TextSize = 16,
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(176),
                Width = Application.GetRealWidth(400),
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.selection,
                IsBold = true,
            };
            topRowLayout.AddChidren(titleName);
            if (Common.Logic.CurrentLogic.LogicId != 0)
@@ -109,6 +110,7 @@
                TextID = MyInternationalizationString.automationname,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Y = Application.GetRealHeight(35),
                TextSize = 15,
            };
            logicnamefl.AddChidren(text);
@@ -120,7 +122,7 @@
                X = text.Right,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                TextSize = 13,
                TextSize = 14,
                Text = Common.Logic.CurrentLogic.LogicName,
                //TextID=MyInternationalizationString.automation1,
            };
@@ -163,7 +165,7 @@
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                TextSize = 16,
                TextSize = 15,
                Gravity = Gravity.CenterVertical,
            });
@@ -192,11 +194,7 @@
            ///添加条件的点击事件
            EventHandler<MouseEventArgs> conditionaddclick = (sender, e) =>
            {
                var addCondition = new AddCondition();
                addCondition.conditionsIndex = -1;
                UserView.HomePage.Instance.AddChidren(addCondition);
                UserView.HomePage.Instance.PageIndex += 1;
                addCondition.Show();
                AddCondition(-1);
            };
            conditionadd.MouseUpEventHandler += conditionaddclick;
            conditionadd1.MouseUpEventHandler += conditionaddclick;
@@ -229,22 +227,18 @@
                    var addtextbtn = new Button
                    {
                        Height = Application.GetRealHeight(58),
                        Width = Application.GetRealWidth(300),
                        Width = Application.GetRealWidth(500),
                        Y = Application.GetRealHeight(45 + 30),
                        TextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                        TextID = MyInternationalizationString.selectunlockingmode,
                        X = Application.GetRealWidth(390),
                        X = Application.GetRealWidth(290),
                        TextSize = 14,
                    };
                    addfl.AddChidren(addtextbtn);
                    EventHandler<MouseEventArgs> addconditionsclick = (sender, e) =>
                    {
                        var addCondition = new AddCondition();
                        ///记录索引
                        addCondition.conditionsIndex = -1;
                        UserView.HomePage.Instance.AddChidren(addCondition);
                        UserView.HomePage.Instance.PageIndex += 1;
                        addCondition.Show();
                        AddCondition(-1);
                    };
                    addbtn.MouseUpEventHandler += addconditionsclick;
                    addtextbtn.MouseUpEventHandler += addconditionsclick;
@@ -289,7 +283,8 @@
                                var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return obj.DeviceAddr == conditions["MacAddr"] && obj.DeviceEpoint.ToString() == conditions["Epoint"]; });
                                if (deviceinof == null)
                                {
                                    continue;
                                    deviceinof = new ZigBee.Device.CommonDevice();
                                    //continue;
                                }
                                ///显示设备名称
                                var btndevice = new Button
@@ -300,6 +295,7 @@
                                    TextAlignment = TextAlignment.CenterLeft,
                                    Text = deviceinof.DeviceEpointName,
                                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                                    TextSize = 14,
                                };
                                conditionsRowLayout.AddChidren(btndevice);
@@ -323,17 +319,14 @@
                                    BackgroundColor = ZigbeeColor.Current.LogicEditBlackColor1,
                                    Text = Language.StringByID(MyInternationalizationString.edit),
                                    TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                                    Tag=i,
                                    Tag = i,
                                };
                                conditionsRowLayout.AddRightView(deviceedit);
                                deviceedit.MouseUpEventHandler += (sender, e) =>
                                {
                                    var addCondition = new AddCondition();
                                    ///记录索引
                                    addCondition.conditionsIndex = int.Parse(deviceedit.Tag.ToString());
                                    UserView.HomePage.Instance.AddChidren(addCondition);
                                    UserView.HomePage.Instance.PageIndex += 1;
                                    addCondition.Show();
                                    int intvalue = int.Parse(deviceedit.Tag.ToString());
                                    AddCondition(intvalue);
                                };
                                ///显示设备条件状态控件
@@ -345,6 +338,7 @@
                                    TextAlignment = TextAlignment.CenterRight,
                                    X = Application.GetRealWidth(400),
                                    TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                                    TextSize = 14,
                                };
                                conditionsRowLayout.AddChidren(devicestatus);
@@ -353,39 +347,17 @@
                                    case DeviceType.DoorLock:
                                        {
                                            conditionIcon.UnSelectedImagePath = "ZigeeLogic/doorlock.png";
                                            //for (int a = 0; a < Common.Logic.CurrentLogic.Accounts.Count; a++)
                                            //{
                                            //    if (Common.Logic.CurrentLogic.Accounts[a]["Type"] == "1")
                                            //    {
                                            //        if (Common.Logic.CurrentLogic.Accounts[a]["UserId"] == conditions["AttriButeData2"])
                                            //        {
                                            //            devicestatus.Text = conditions["Account"];
                                            //            break;
                                            //        }
                                            //    }
                                            //}
                                            //(0按键/3卡/15指纹)
                                            switch (conditions["AttriButeId"])
                                            for (int a = 0; a < Common.Logic.CurrentLogic.Accounts.Count; a++)
                                            {
                                                case "0":
                                                if (Common.Logic.CurrentLogic.Accounts[a]["Type"] == "1")
                                                {
                                                    if (Common.Logic.CurrentLogic.Accounts[a]["UserId"] == conditions["AttriButeData2"])
                                                    {
                                                        devicestatus.Text = Language.StringByID(MyInternationalizationString.lockpassword);
                                                        devicestatus.Text = Common.Logic.CurrentLogic.Accounts[a]["Account"];
                                                        break;
                                                    }
                                                    break;
                                                case "3":
                                                    {
                                                        devicestatus.Text = Language.StringByID(MyInternationalizationString.ic);
                                                    }
                                                    break;
                                                case "15":
                                                    {
                                                        devicestatus.Text = Language.StringByID(MyInternationalizationString.fingerprint);
                                                    }
                                                    break;
                                                }
                                            }
                                        }
                                        break;
                                }
@@ -400,23 +372,20 @@
                        Text = Language.StringByID(MyInternationalizationString.del),
                    };
                    conditionsRowLayout.AddRightView(del);
                    del.MouseUpEventHandler += (sender, e) =>
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete),
                                              Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim));
                        alert.ResultEventHandler += (sender1, e1) =>
                        {
                            if (e1)
                            {
                                var lockLogicCommunalPage = new LockLogicCommunalPage();
                                UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
                                UserView.HomePage.Instance.PageIndex += 1;
                                lockLogicCommunalPage.Show(() => { });
                            }
                        };
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
                       Language.StringByID(MyInternationalizationString.doyouwanttodelete),
                       Language.StringByID(MyInternationalizationString.confrim));
                        alert.Show();
                        alert.ConfirmClickEvent += () =>
                        {
                            Common.Logic.CurrentLogic.Conditions.Remove(conditions);
                            var lockLogicCommunalPage = new LockLogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            lockLogicCommunalPage.Show(() => { });
                        };
                    };
@@ -455,7 +424,7 @@
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                TextSize = 16,
                TextSize = 15,
                Gravity = Gravity.CenterVertical,
            };
            targetRowLayout.AddChidren(btntargettitle);
@@ -525,6 +494,7 @@
                        TextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                        TextID = MyInternationalizationString.lockaddaction,
                        X = Application.GetRealWidth(390),
                        TextSize = 14,
                    };
                    addfl.AddChidren(addtextbtn);
                    EventHandler<MouseEventArgs> addfunctionclick = (sender, e) =>
@@ -583,7 +553,8 @@
                                var deviceinof = Common.Logic.LogicDviceList.Find((obj) => { return ((obj.DeviceAddr == obj1) && (obj.DeviceEpoint.ToString() == obj2)); });
                                if (deviceinof == null)
                                {
                                    continue;
                                    deviceinof = new ZigBee.Device.CommonDevice();
                                    //continue;
                                }
                                ///设备名称Button
@@ -595,6 +566,7 @@
                                    TextAlignment = TextAlignment.CenterLeft,
                                    Text = deviceinof.DeviceEpointName,
                                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                                    TextSize = 14,
                                };
                                actionsrowLayout.AddChidren(btndevicename);
@@ -620,6 +592,7 @@
                                    TextAlignment = TextAlignment.CenterRight,
                                    X = Application.GetRealWidth(450),
                                    TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                                    TextSize = 14,
                                };
                                actionsrowLayout.AddChidren(devicestatus);
@@ -635,7 +608,7 @@
                                ///编辑点击事件
                                deviceedit.MouseUpEventHandler += (sender, e) =>
                                {
                                    var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                                    this.AddChidren(flMain);
                                    LockAddDevice.CurrentDeviceStateView(flMain, deviceinof, true);
@@ -788,22 +761,19 @@
                                            bool ifclose = false;
                                            foreach (var status in TaskList)
                                            {
                                                if (status["TaskType"].ToString() == "1")
                                                if (TaskList.Count == 1)
                                                {
                                                    if (status["Data1"].ToString() == "0")
                                                    {
                                                        // devicestatus.Text = Language.StringByID(MyInternationalizationString.close);
                                                        ifclose = false;
                                                    }
                                                    else if (status["Data1"].ToString() == "1")
                                                    {
                                                        //devicestatus.Text = Language.StringByID(MyInternationalizationString.open);
                                                        ifclose = true;
                                                    }
                                                    //数组只有一个元素说明当前空调状态为关;
                                                    ifclose = false;
                                                    //如果空调状态是关;直接跳出for循坏;
                                                    break;
                                                }
                                                else if (status["TaskType"].ToString() == "5")
                                                else
                                                {
                                                    ifclose = true;
                                                }
                                                if (status["TaskType"].ToString() == "5")
                                                {
                                                    if (status["Data1"] == "3")
                                                    {//3---设置工作模式(1:自动;3:制冷;4:制热;7:送风;8:除湿)
@@ -894,11 +864,33 @@
                        case 2:
                            {
                                //在本地查找该场景;
                                var sceneinof = Common.Room.AllRoomSceneUIList.Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); });
                                //本地没有存在;
                                if (sceneinof == null)
                                {
                                    continue;
                                    //实现目的:显示出来让可以自己是否删除
                                    sceneinof = new SceneUI();
                                    #region -----
                                    ////在网关查找该场景;
                                    ////标记问题:网络请求,存在视图加载快慢的问题;
                                    //sceneinof = await Send.GetScene(int.Parse(actions["DeviceAddr"].ToString()));
                                    ////网关没有存在;
                                    //if (sceneinof == null)
                                    //{
                                    //    //注解:本地和网关都不存在该场景,界面将不会显示该场景;
                                    //    //sceneinof = new SceneUI();
                                    //    //移除该场景数据;
                                    //    Common.Logic.CurrentLogic.Actions.Remove(actions);
                                    //    //移除该场景视图;
                                    //    devicesFrameLayout.RemoveFromParent();
                                    //    continue;
                                    //}
                                    #endregion
                                }
                                actionsIcon.UnSelectedImagePath = "ZigeeLogic/scene.png";
                                ///设备名称Button
@@ -910,6 +902,7 @@
                                    TextAlignment = TextAlignment.CenterLeft,
                                    Text = sceneinof.Name,
                                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                                    TextSize = 14,
                                };
                                actionsrowLayout.AddChidren(btndevicename);
@@ -945,16 +938,19 @@
                    del.MouseUpEventHandler += (sender, e) =>
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete),
                                               Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim));
                        alert.ResultEventHandler += (sender1, e1) =>
                        {
                            if (e1)
                            {
                                Common.Logic.CurrentLogic.Actions.Remove(actions);
                                                          }
                        };
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
           Language.StringByID(MyInternationalizationString.doyouwanttodelete),
          Language.StringByID(MyInternationalizationString.confrim));
                        alert.Show();
                        alert.ConfirmClickEvent += () =>
                        {
                            Common.Logic.CurrentLogic.Actions.Remove(actions);
                            var lockLogicCommunalPage = new LockLogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            lockLogicCommunalPage.Show(() => { });
                        };
                    };
@@ -996,6 +992,7 @@
                Height = Application.GetRealHeight(60),
                Gravity = Gravity.CenterVertical,
                TextID = MyInternationalizationString.pushswitch,
                TextSize = 14,
            };
            pushswitchRowlayout.AddChidren(btnswitchtxet);
@@ -1009,23 +1006,11 @@
                Gravity = Gravity.CenterVertical,
            };
            pushswitchRowlayout.AddChidren(btnswitch);
            btnswitch.MouseUpEventHandler += (sender1, e1) =>
            {
                btnswitch.IsSelected = !btnswitch.IsSelected;
                if (btnswitch.IsSelected)
                {
                }
                else
                {
                }
            };
            var custompushFrameLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                Height = Application.GetRealHeight(0),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(custompushFrameLayout);
@@ -1048,6 +1033,7 @@
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(60),
                Gravity = Gravity.CenterVertical,
                TextSize = 14,
            };
            custompushRowLayout.AddChidren(btncustompush);
@@ -1075,7 +1061,37 @@
            #endregion
            bool tag = false;//标记开关状态;
            btnswitch.MouseUpEventHandler += (sender1, e1) =>
            {
                btnswitch.IsSelected = !btnswitch.IsSelected;
                if (btnswitch.IsSelected)
                {
                    tag = true;
                    custompushFrameLayout.Height = Application.GetRealHeight(160);
                    Common.Logic.CurrentLogic.LogicIsCustomPushText = 1;
                }
                else
                {
                    tag = false;
                    custompushFrameLayout.Height = Application.GetRealHeight(0);
                    Common.Logic.CurrentLogic.LogicIsCustomPushText = 0;
                }
                Send.Zj(tag, Common.Logic.CurrentLogic);
            };
            if (Common.Logic.CurrentLogic.LogicIsCustomPushText == 0)
            {
                tag = false;
                btnswitch.IsSelected = false;
                custompushFrameLayout.Height = Application.GetRealHeight(0);
            }
            else
            {
                tag = true;
                btnswitch.IsSelected = true;
                custompushFrameLayout.Height = Application.GetRealHeight(160);
            }
            var saveFrameLayout = new FrameLayout
            {
                Y = middle.Bottom,
@@ -1093,6 +1109,7 @@
                BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
                TextID = MyInternationalizationString.Save,
                TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                TextSize = 16,
            };
            saveFrameLayout.AddChidren(btnsave);
            btnsave.MouseUpEventHandler += async (sender, e) =>
@@ -1100,15 +1117,18 @@
                var name = logicTextBox.Text.Trim();
                if (string.IsNullOrEmpty(logicTextBox.Text.Trim()))
                {
                    new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.PleaseEnterLogicName), Language.StringByID(MyInternationalizationString.Close)).Show();
                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
            Language.StringByID(MyInternationalizationString.PleaseEnterLogicName),
            Language.StringByID(MyInternationalizationString.confrim));
                    alert.Show();
                    return;
                }
                var logicname = Common.Logic.LockLogicList.Find((logic) => Common.Logic.CurrentLogic.LogicId != logic.LogicId && logic.LogicName == name);
                if (logicname != null)
                {
                    new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.Rename), Language.StringByID(MyInternationalizationString.Close)).Show();
                    return;
                }
                //var logicname = Common.Logic.LockLogicList.Find((logic) => Common.Logic.CurrentLogic.LogicId != logic.LogicId && logic.LogicName == name);
                //if (logicname != null)
                //{
                //    new Alert(Language.StringByID(MyInternationalizationString.Tip), Language.StringByID(MyInternationalizationString.Rename), Language.StringByID(MyInternationalizationString.Close)).Show();
                //    return;
                //}
                Common.Logic.CurrentLogic.LogicName = name;
@@ -1122,6 +1142,10 @@
                    {
                        Common.Logic.CurrentLogic.LogicId = logicifon.LogicId;
                        Common.Logic.LockLogicList.Add(Common.Logic.CurrentLogic);
                        if (tag)
                        {
                            Send.Zj(tag, Common.Logic.CurrentLogic);
                        }
                    }
                }
                else
@@ -1140,5 +1164,14 @@
            };
        }
        public  void AddCondition(int value)
        {
            var addCondition = new AddCondition();
            addCondition.conditionsIndex = value;
            UserView.HomePage.Instance.AddChidren(addCondition);
            UserView.HomePage.Instance.PageIndex += 1;
            addCondition.Show();
        }
    }
}