CrabtreeOn,印度客户定制APP,迁移2.0平台版本
陈嘉乐
2021-03-03 91c2194fce3958afed333119c3aeed3c49ef6bcf
Crabtree/SmartHome/UI/SimpleControl/Phone/Schedule/AddSchedule.cs
@@ -673,6 +673,8 @@
                DeviceDate deviceDate = new DeviceDate ();
                deviceDate.gatewayId = SmartHome.Send.GatewayId;
                deviceDate.homeId = SmartHome.Send.HomeId;
                deviceDate.actions.AddRange (selectedDeviceList);
                timerTemp.controlData = deviceDate;
@@ -687,6 +689,8 @@
                            revertObj = SmartHome.Send.UpdateTimer (timerTemp);
                        } else {
                            revertObj = SmartHome.Send.AddTimer (timerTemp);
                        }
@@ -699,7 +703,9 @@
                            } else {
                                //提示错误
                                SmartHome.Method method = new SmartHome.Method ();
                                if (revertObj.Data != null) {
                                method.ShowGetTimerListErrorInfo (revertObj.Data.ToString ());
                                }
                            }
                        });
                    } catch (Exception ex) {
@@ -833,12 +839,14 @@
                                                    }
                                                    for (int a = 0; a < dev.attributes.Count; a++) {
                                                        var fundev = dev.attributes [a];
                                                        if (fundev.key == "brightness") {
                                                        if (fundev.value == "0") {
                                                            btnLevel.Text = "OFF";
                                                        } else {
                                                            btnLevel.Text = fundev.value + "%";
                                                        }
                                                        levelBar.Progress = int.Parse (fundev.value);
                                                        }
                                                    }
                                                }
                                                } catch { }
@@ -849,6 +857,7 @@
                                    //DeviceType.LightEnergySwitch
                                    //DeviceType.LightEnergySocket
                                    //DeviceType.LightSwitchSocket
                                case SPK.ElectricSocket:
                                    case SPK.LightSwitch: {
                                            #region 继电器
                                            tempSwitch.MouseUpEventHandler += (sender3, e3) => {
@@ -868,7 +877,7 @@
                                        
                                            btnChoose.MouseUpEventHandler += (dds, ddss) => {
                                                btnChoose.IsSelected = !btnChoose.IsSelected;
                                                if (btnChoose.IsSelected) {
                                            if (tempSwitch.IsSelected) {
                                                    value = "on";
                                                } else {
                                                    value = "off";
@@ -900,8 +909,7 @@
                                        break;
                                    case SPK.CurtainRoller:
                                    case SPK.CurtainTrietex:
                                    case SPK.CurtainSwitch:
                                    {
                                case SPK.CurtainSwitch: {
                                            #region 窗帘
                                            tempSwitch.RemoveFromParent ();
                                            var tempSwitch1 = new Button () {
@@ -972,10 +980,6 @@
                                            #endregion
                                        }
                                        break;
                                    case "electrical.socket": {
                                        }
                                        break;
                                    case SPK.ElectricFan: {
                                            #region 风扇
                                            tempSwitch.RemoveFromParent ();
@@ -1013,7 +1017,6 @@
                                                    btnFanLevelTip.TextSize = 11;
                                                }
                                            }
                                            var fanLevel = new HorizontalSeekBar () {
                                                X = btnFanLevel.Right,
                                                Y = btnFanLevel.Y + Application.GetRealHeight (10),
@@ -1027,14 +1030,18 @@
                                            };
                                            deviceRowView.AddChidren (fanLevel);
                                        value = "2";
                                            fanLevel.ProgressChanged += (sender, e) => {
                                            if (!btnChoose.IsSelected) {
                                                btnChoose.IsSelected = true;
                                            }
                                                value = e.ToString ();
                                                DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected);
                                            };
                                            btnChoose.MouseUpEventHandler += (dds, ddss) => {
                                                btnChoose.IsSelected = !btnChoose.IsSelected;
                                                DeviceDateFun (btnChoose.Tag as Function, "0", btnChoose.IsSelected);
                                            DeviceDateFun (btnChoose.Tag as Function, value, btnChoose.IsSelected);
                                            };
                                            if (IsEdit) {
                                                try {
@@ -1045,11 +1052,15 @@
                                                        }
                                                        for (int a = 0; a < dev.attributes.Count; a++) {
                                                            var fundev = dev.attributes [a];
                                                            if (fundev.value == "0") {
                                                        if (fundev.key == "fan_speed_percent") {
                                                           // if (fundev.value == "0") {
                                                                //btnLevel.Text = "OFF";
                                                            } else {
                                                          //  } else {
                                                                fanLevel.Progress = int.Parse (fundev.value);
                                                           // }
                                                            }
                                                           
                                                        }
                                                    }
@@ -1089,16 +1100,20 @@
        {
            string keyValue = "";
            switch (function.spk) {
            case "curtain.trietex":
            case "curtain.roller":
            case "light.switch":
            case "curtain.switch":
            case "electrical.socket": {
            case SPK.CurtainTrietex:
            case SPK.CurtainRoller:
            case SPK.LightSwitch:
            case SPK.CurtainSwitch:
            case SPK.ElectricSocket: {
                    keyValue = "on_off";
                }
                break;
            case "light.dimming": {
            case SPK.LightDimming: {
                    keyValue = "brightness";
                }
                break;
            case SPK.ElectricFan: {
                    keyValue = "fan_speed_percent";
                }
                break;
@@ -1118,6 +1133,43 @@
        /// <param name="isSelected">判断控件点击状态</param>
        public  void AddDeviceList (Fun fun, bool isSelected)
        {
            switch (fun.spk) {
            case SPK.LightDimming: {
                    //调光做了一个特殊处理;
                    if (fun.attributes.Count == 1) {
                        var dic = fun.attributes [0];
                        if (dic.key == "brightness") {
                            Attributes attributes = new Attributes ();
                            attributes.key = "on_off";
                            if (dic.value == "0") {
                                attributes.value = "off";
                            } else {
                                attributes.value = "on";
                            }
                            fun.attributes.Add (attributes);
                        }
                    }
                    break;
                }
            case SPK.ElectricFan: {
                    if (fun.attributes.Count == 1) {
                        var dic = fun.attributes [0];
                        if (dic.key == "fan_speed_percent") {
                            Attributes attributes = new Attributes ();
                            attributes.key = "on_off";
                            if (dic.value == "0") {
                                attributes.value = "off";
                            } else {
                                attributes.value = "on";
                            }
                            fun.attributes.Add (attributes);
                        }
                    }
                }
                break;
            }
            var device = selectedDeviceList.Find ((dev) => dev.deviceId == fun.deviceId);
            if (device != null) {
                selectedDeviceList.Remove (device);