WJC
2019-12-19 7a23bcdf0fe5f7442aa95ec2203cd5b6670a910d
ZigbeeApp/Shared/Phone/Device/Logic/LogicCommunalPage.cs
@@ -18,7 +18,7 @@
            Tag = "Logic";
        }
        EditText logicTextBox;
        public void Show(Action action)
        public async void Show(Action action)
        {
            
            #region  最上面的布局代码
@@ -497,7 +497,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
@@ -1195,9 +1196,11 @@
                                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
                                var btndevicename = new Button
                                {
@@ -1503,11 +1506,25 @@
                            break;
                        case 2:
                            {
                                //在本地查找该场景;
                                var sceneinof = Common.Room.AllRoomSceneUIList.Find((obj) => { return obj.Id.ToString() == actions["DeviceAddr"].ToString(); });
                                //本地没有存在;
                                if (sceneinof == null)
                                {
                                    continue;
                                    //在网关查找该场景;
                                    sceneinof =await Send.GetScene(int.Parse(actions["DeviceAddr"].ToString()));
                                    //网关没有存在;
                                    if (sceneinof == null)
                                    {
                                        //注解:本地和网关都不存在该场景,界面将不会显示该场景;
                                        //sceneinof = new SceneUI();
                                        //移除该场景数据;
                                        Common.Logic.CurrentLogic.Actions.Remove(actions);
                                        //移除该场景视图;
                                        devicesFrameLayout.RemoveFromParent();
                                        continue;
                                    }
                                }
                                actionsIcon.UnSelectedImagePath = "ZigeeLogic/scene.png";
@@ -1539,7 +1556,6 @@
                                Common.Room room = new Common.Room();
                                btnregionname.Text = room.GetRoomNameBySceneId(sceneinof.Id);
                                //Send.RoomNmae(btnregionname, deviceinof);
                            }
@@ -1752,6 +1768,7 @@
                            if (e1)
                            {
                                Common.Logic.CurrentLogic.Actions.Remove(actions);
                                // devicesFrameLayout.RemoveFromParent();
                                var logicCommunalPage = new LogicCommunalPage();
                                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                                UserView.HomePage.Instance.PageIndex += 1;
@@ -1888,23 +1905,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);
@@ -1952,7 +1957,18 @@
            btncustompush.MouseUpEventHandler += customclick;
            custompushback.MouseUpEventHandler += customclick;
            custompushRowLayout.MouseUpEventHandler += customclick;
            btnswitch.MouseUpEventHandler += (sender1, e1) =>
            {
                btnswitch.IsSelected = !btnswitch.IsSelected;
                if (btnswitch.IsSelected)
                {
                    custompushFrameLayout.Height = Application.GetRealHeight(160);
                }
                else
                {
                    custompushFrameLayout.Height = Application.GetRealHeight(0);
                }
            };
            #endregion
@@ -2015,11 +2031,13 @@
                }
                CommonPage.Loading.Hide();
                if (!succeed) {
                if (!succeed)//succeed标记是添加成功还是失败
                {
                    //网关回复失败,不关闭界面,让它停留当前界面;
                    //(原因:考虑到失败重新编辑原来数据给用户带来了麻烦)
                    ///提示:添加自动化失败;
                    return;
                    //TipView("添加自动化失败");
                    //return;
                }
                UserView.HomePage.Instance.RemoveViewByTag("Logic");
                Category.Category.instance?.RefreshBodyView();
@@ -2520,5 +2538,46 @@
            };
        }
        /// <summary>
        /// 闪现式提示框的方法
        /// </summary>
        /// <param name="tipText">提示内容</param>
        /// <param name="second">停留时间单位为s</param>
        public void TipView(string tipText, int second = 1)
        {
            var frameLayout = new FrameLayout { BackgroundColor = 0x50000000 };
            this.AddChidren(frameLayout);
            var btn = new Button
            {
                Gravity = Gravity.Center,
                Text = tipText,
                BackgroundColor = 0xff1f1f1f,
                Width = Application.GetRealWidth(500),
                Height = Application.GetRealHeight(100),
                Radius = (uint)Application.GetRealHeight(50),
            };
            frameLayout.AddChidren(btn);
            var dateTime1 = DateTime.Now;
            new System.Threading.Thread(() =>
            {
                Application.RunOnMainThread(() =>
                {
                    while (true)
                    {
                        if ((DateTime.Now - dateTime1).TotalMilliseconds > second * 1000)
                        {
                            //默认一秒关闭
                            frameLayout.RemoveFromParent();
                            break;
                        }
                    }
                });
            })
            { IsBackground = true }.Start();
        }
    }
}