黄学彪
2020-04-02 9904031f5291daaf56985146bb671f25e18ebbdf
ZigbeeApp/Shared/Phone/Device/Logic/Method.cs
@@ -97,40 +97,47 @@
        {
            List<string> devicetypelist = new List<string>();
            devicetypelist.Clear();
            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput);
            if (lightjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights));
            }
            var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor);
            if (iASZonejosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
            }
            var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch);
            if (onOffSwitchjson != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch));
            }
            var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock);
            if (doorLock != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock));
            }
            var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice);
            if (curtainjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
            }
            var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat);
            if (ac != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC));
            }
            var onOffSwitchjson = devicelist.Find((device) => device.Type == DeviceType.OnOffSwitch);
            if (onOffSwitchjson != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch));
            }
            var doorLock = devicelist.Find((device) => device.Type == DeviceType.DoorLock);
            if (doorLock != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock));
            }
            var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch);
            if (airSwitch != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch));
            }
            var iASZonejosn = devicelist.Find((device) => device.Type == DeviceType.IASZone || device.Type == DeviceType.TemperatureSensor);
            if (iASZonejosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
            }
            return devicetypelist;
@@ -334,7 +341,7 @@
                        deviceTypeList.Add(DeviceType.Thermostat);
                        deviceTypeList.Add(DeviceType.AirSwitch);
                        ///门锁特殊
                        deviceTypeList.Add(DeviceType.DoorLock);
                       // deviceTypeList.Add(DeviceType.DoorLock);
                    }
                    break;
                case "condition_mould":
@@ -356,7 +363,7 @@
                        deviceTypeList.Add(DeviceType.Thermostat);
                        deviceTypeList.Add(DeviceType.AirSwitch);
                        ///门锁特殊
                        deviceTypeList.Add(DeviceType.DoorLock);
                      // deviceTypeList.Add(DeviceType.DoorLock);
                    }
                    break;
@@ -654,6 +661,7 @@
            custompushview.iconBtn.Visible = true;
            custompushview.iconBtn.UnSelectedImagePath = "ZigeeLogic/next.png";
            custompushview.titleBtn.TextID = MyInternationalizationString.custompush;
            custompushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
            middle.AddChidren(custompushview.AddDeviceView());
            EventHandler<MouseEventArgs> customclick = (sender, e) =>
@@ -674,6 +682,7 @@
                    LogicView.IfString.Tag = true;
                    custompushview.frameLayout.Height = Application.GetRealHeight(160);
                    Common.Logic.CurrentLogic.LogicIsCustomPushText = 1;
                    pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor;
                }
                else
@@ -681,6 +690,7 @@
                    LogicView.IfString.Tag = false;
                    custompushview.frameLayout.Height = Application.GetRealHeight(0);
                    Common.Logic.CurrentLogic.LogicIsCustomPushText = 0;
                    pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
                }
                Send.Zj(LogicView.IfString.Tag, Common.Logic.CurrentLogic);
            };
@@ -690,12 +700,14 @@
                LogicView.IfString.Tag = false;
                pushview.switchBtn.IsSelected = false;
                custompushview.frameLayout.Height = Application.GetRealHeight(0);
                pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
            }
            else
            {
                LogicView.IfString.Tag = true;
                pushview.switchBtn.IsSelected = true;
                custompushview.frameLayout.Height = Application.GetRealHeight(160);
                pushview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor;
            }
        }
        /// <summary>
@@ -707,6 +719,16 @@
        /// <param name="CurrentLogic">当前逻辑</param>
        public async static void SaveLogic(string if_logic, string name, bool tag, Common.Logic CurrentLogic)
        {
            if (CurrentLogic.Conditions.Count == 0 || CurrentLogic.Actions.Count == 0)
            {
                var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
                  Language.StringByID(MyInternationalizationString.addnull),
                  Language.StringByID(MyInternationalizationString.confrim));
                alert.Show();
                return;
            }
            if (string.IsNullOrEmpty(name))
            {
                var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
@@ -735,7 +757,17 @@
                {
                    succeed = true;
                    CurrentLogic.LogicId = logicifon.LogicId;
                    Common.Logic.LogicList.Add(CurrentLogic);
                    if (LogicView.IfString._LockLogic == if_logic)
                    {
                        //门锁联动事件逻辑列表
                        Common.Logic.LockLogicList.Add(CurrentLogic);
                    }
                    else
                    {
                        //自动化逻辑列表
                        Common.Logic.LogicList.Add(CurrentLogic);
                    }
                    if (tag)
                    {
                        Send.Zj(tag, CurrentLogic);
@@ -760,13 +792,29 @@
                //TipView("添加自动化失败");
                //return;
            }
            UserView.HomePage.Instance.RemoveViewByTag("Logic");
            if (LogicView.IfString._Logic == if_logic)
            {
                Category.Category.instance?.RefreshBodyView();
                UserView.HomePage.Instance.RemoveViewByTag("Logic");
                if (CurrentLogic.LogicType == 0)
                {
                    //只刷新分类上下滑动view;
                    Phone.Category.CategoryMainForm.instance?.RefreshBodyView();
                    // Category.Category.instance?.RefreshBodyView();
                }
                else if (CurrentLogic.LogicType == 2)
                {
                    //刷新整个分类;
                    //门锁常开模式特殊;
                    UserView.UserPage.Instance.ShowCategoryAutoListForm();
                }
            }
            else if (LogicView.IfString._LockLogic == if_logic)
            {
                UserView.HomePage.Instance.RemoveViewByTag("Logic");//移除所有标记Logic界面
                UserView.HomePage.Instance.RemoveViewByTag("LockListView");//移除所有标记LockListView界面
                var doorLockLogicList = new DoorLockLogic.LockLogicList();
                UserView.HomePage.Instance.AddChidren(doorLockLogicList);
                UserView.HomePage.Instance.PageIndex += 1;
@@ -786,5 +834,7 @@
            UserView.HomePage.Instance.PageIndex += 1;
            deviceTarget.Show(str1, str2);
        }
    }
}