wxr
2020-12-16 5c5461b7c46aff66d24efe80062c235342e77d4c
HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs
@@ -93,7 +93,7 @@
            refreshFunctionRowAction = () => {
                LoadFunctionRow(functionListView);
                LoadFunctionRow();
            };
        }
@@ -245,7 +245,7 @@
            #endregion
            #region 场景延时row
            if (DB_ResidenceData.residenceData.GatewayType == 1)
            if (DB_ResidenceData.Instance.GatewayType == 1)
            {
                FrameLayout sceneDelayRow = new FrameLayout()
                {
@@ -270,7 +270,7 @@
                    TextAlignment = TextAlignment.CenterRight,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    Text = scene.delayText
                    Text = FunctionList.List.GetDelayText( scene.delay)
                };
                sceneDelayRow.AddChidren(btnSceneDelayInfo);
@@ -288,7 +288,11 @@
                btnSceneDelayTitle.MouseUpEventHandler = (sender, e) =>
                {
                    new PublicAssmebly().SetSceneDelayDialog(scene, btnSceneDelayInfo);
                    Action<string> action = (obj) => {
                        scene.delay = obj;
                        btnSceneDelayInfo.Text = FunctionList.List.GetDelayText(obj);
                    };
                    new PublicAssmebly().SetSceneDelayDialog(action,scene.delay);
                };
                contentView.AddChidren(new Button()
@@ -333,7 +337,7 @@
            };
            contentView.AddChidren(functionListView);
            LoadFunctionRow(functionListView);
            LoadFunctionRow();
            Button btnLine1 = new Button()
            {
@@ -374,11 +378,43 @@
            bodyView.AddChidren(btnComplete);
            LoadEventList();
            var waitPage = new Loading();
            new Thread(() => {
                Application.RunOnMainThread(() => {
                    bodyView.AddChidren(waitPage);
                    waitPage.Start(Language.StringByID(StringId.PleaseWait));
                });
                var pm = new HttpServerRequest();
                var pack = pm.GetSceneInfo(scene.userSceneId);
                if (pack.Code == StateCode.SUCCESS)
                {
                    var sceneList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(pack.Data.ToString());
                    var tempScene = sceneList.Find((obj) => obj.userSceneId == scene.userSceneId);
                    if(tempScene!= null)
                    {
                        scene.functions = tempScene.functions;
                    }
                    Application.RunOnMainThread(() =>
                    {
                        LoadFunctionRow();
                        waitPage.Hide();
                    });
                }
                else
                {
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                    });
                }
            }).Start();
        }
        /// <summary>
        /// 加载功能列表
        /// </summary>
        void LoadFunctionRow(VerticalScrolViewLayout functionListView)
        void LoadFunctionRow()
        {
            functionListView.RemoveAll();
            functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count);
@@ -409,8 +445,6 @@
                };
                row.AddChidren(btnRight);
                var btnFunctionInfo = new Button()
                {
                    Width = Application.GetRealWidth(327),
@@ -435,7 +469,7 @@
                if (Convert.ToInt32( scenefunction.delay) > 0)
                {
                    btnFunctionDelayInfo.Text = Language.StringByID(StringId.Delay) + " " + scenefunction.localFunction.delayText;
                    btnFunctionDelayInfo.Text = Language.StringByID(StringId.Delay) + " " + FunctionList.List.GetDelayText(scenefunction.delay);
                }
                else
                {
@@ -513,66 +547,94 @@
                    if (sfs.value == "off")
                        return Language.StringByID(StringId.Close);
                }
                if (sfs.key == FunctionAttributeKey.Mode)
                {
                }
            }
            FunctionAttributes perTrait;
            switch (sceneFunction.localFunction.functionType)
            if (sceneFunction.status.Count == 0)
            {
                case FunctionType.AC:
                    sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText();
                    sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temperature").curValue.ToString() +
                         sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temperature").uintString;
                    sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText();
                    break;
                case FunctionType.FloorHeating:
                    sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText();
                    sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temperature").curValue.ToString() +
                         sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temperature").uintString;
                    break;
                case FunctionType.Dimmer:
                    perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness");
                    if (perTrait != null)
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%";
                    }
                    else
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open);
                    }
                    break;
                case FunctionType.Relay:
                    sceneFunctionInfo += Language.StringByID(StringId.Open);
                    break;
                case FunctionType.RGB:
                    perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent");
                    if (perTrait != null)
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%";
                    }
                    else
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open);
                    }
                    break;
                case FunctionType.Curtain:
                    sceneFunctionInfo += Language.StringByID(StringId.Open);
                    break;
                case FunctionType.MotorCurtain:
                    perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent");
                    if (perTrait != null)
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%";
                    }
                    else
                    {
                        sceneFunctionInfo += Language.StringByID(StringId.Open);
                    }
                    break;
                return sceneFunctionInfo += Language.StringByID(StringId.Open);
            }
            var modeState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Mode);
            var tempState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.SetTemp);
            var fanState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FanSpeed);
            if (modeState != null)
            {
                sceneFunctionInfo += FunctionList.List.GetValueText(modeState.key, modeState.value);
            }
            if (tempState != null)
            {
                sceneFunctionInfo += FunctionList.List.GetValueText(tempState.key, tempState.value);
                sceneFunctionInfo += FunctionList.List.GetUintString(tempState.key);
            }
            if (fanState != null)
            {
                sceneFunctionInfo += FunctionList.List.GetValueText(fanState.key, fanState.value);
            }
            var briState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
            if (briState != null)
            {
                sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + briState.value + "%";
            }
            var perState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
            if (perState != null)
            {
                sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + perState.value + "%";
            }
            //FunctionAttributes perTrait;
            //switch (sceneFunction.localFunction.functionType)
            //{
            //    case FunctionType.AC:
            //        sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText();
            //        sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() +
            //             sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString;
            //        sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan").GetCurValueText();
            //        break;
            //    case FunctionType.FloorHeating:
            //        sceneFunctionInfo += sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode").GetCurValueText();
            //        sceneFunctionInfo += " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").curValue.ToString() +
            //             sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp").uintString;
            //        break;
            //    case FunctionType.Dimmer:
            //        perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness");
            //        if (perTrait != null)
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%";
            //        }
            //        else
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open);
            //        }
            //        break;
            //    case FunctionType.Relay:
            //        sceneFunctionInfo += Language.StringByID(StringId.Open);
            //        break;
            //    case FunctionType.RGB:
            //        perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent");
            //        if (perTrait != null)
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness").curValue.ToString() + "%";
            //        }
            //        else
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open);
            //        }
            //        break;
            //    case FunctionType.Curtain:
            //        sceneFunctionInfo += Language.StringByID(StringId.Open);
            //        break;
            //    case FunctionType.MotorCurtain:
            //        perTrait = sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent");
            //        if (perTrait != null)
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open) + " " + sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent").curValue.ToString() + "%";
            //        }
            //        else
            //        {
            //            sceneFunctionInfo += Language.StringByID(StringId.Open);
            //        }
            //        break;
            //}
            return sceneFunctionInfo;
        }
@@ -704,7 +766,7 @@
        void LoadEvent_ChangeFunctionList()
        {
            btnAddFunctionTitle.MouseUpEventHandler = (sender, e) => {
                var sefp =new SceneFunctionListEditPage(scene,refreshFunctionRowAction);
                var sefp =new SceneFunctionListChoosePage(scene,refreshFunctionRowAction);
                MainPage.BasePageView.AddChidren(sefp);
                sefp.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
@@ -891,7 +953,7 @@
                        backAction();
                        this.RemoveFromParent();
                    };
                    new PublicAssmebly().TipMsg(StringId.Tip, StringId.DeleteSceneTip, action);
                    new PublicAssmebly().TipOptionMsg(StringId.Tip, StringId.DeleteSceneTip, action);
                };
            };
        }