wxr
2021-07-01 43b0d5870d528f23ecd6aeceb6cfd4325188b46f
HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs
@@ -261,7 +261,7 @@
                    TextAlignment = TextAlignment.CenterRight,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    Text = FunctionList.List.GetDelayText( scene.delay)
                    Text = scene.GetDelayText()
                };
                sceneDelayRow.AddChidren(btnSceneDelayInfo);
@@ -281,9 +281,14 @@
                {
                    Action<string> action = (obj) => {
                        scene.delay = obj;
                        btnSceneDelayInfo.Text = FunctionList.List.GetDelayText(obj);
                        btnSceneDelayInfo.Text = scene.GetDelayText();
                        scene.EditScene();
                    };
                    Dictionary<string, string> items = new Dictionary<string, string>();
                    items.Add("30", "30s");
                    items.Add("60", "1min");
                    items.Add("120", "2min");
                    items.Add("300", "5min");
                    new PublicAssmebly().SetSceneDelayDialog(action,scene.delay);
                };
@@ -373,32 +378,42 @@
            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)
                try
                {
                    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();
                        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();
                            waitPage.RemoveFromParent();
                        });
                    }
                    else
                    {
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                    }
                }
                else
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                        IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                        waitPage.RemoveFromParent();
                    });
                }
            }).Start();
@@ -410,8 +425,15 @@
        {
            functionListView.RemoveAll();
            functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count);
            foreach (var scenefunction in scene.functions)
            for(int i =0;i<scene.functions.Count;)
            {
                var scenefunction = scene.functions[i];
                if (scenefunction.localFunction == null)
                {
                    scene.functions.Remove(scenefunction);
                    continue;
                }
                i++;
                var row = new RowLayout()
                {
                    Height = Application.GetRealWidth(65),
@@ -444,7 +466,7 @@
                    TextAlignment = TextAlignment.BottomRight,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    Text = GetFunctionScnenInfo(scenefunction),
                    Text = scenefunction.GetFunctionScnenInfo(),
                };
                row.AddChidren(btnFunctionInfo);
@@ -461,7 +483,7 @@
                if (Convert.ToInt32( scenefunction.delay) > 0)
                {
                    btnFunctionDelayInfo.Text = Language.StringByID(StringId.Delay) + " " + FunctionList.List.GetDelayText(scenefunction.delay);
                    btnFunctionDelayInfo.Text = Language.StringByID(StringId.Delay) + " " + new Scene() { delay = scenefunction.delay }.GetDelayText();
                }
                else
                {
@@ -491,20 +513,15 @@
                };
                row.AddChidren(btnFunctionFloorAndRoom);
                btnFunctionName.MouseUpEventHandler = (sender, e) =>
                EventHandler<MouseEventArgs> skipEvent = (sender, e) =>
                {
                    var ssf = new SceneFunctionInfoEditPage(scene, scenefunction, refreshFunctionRowAction);
                    MainPage.BasePageView.AddChidren(ssf);
                    ssf.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                btnFunctionFloorAndRoom.MouseUpEventHandler = (sender, e) =>
                {
                    var ssf = new SceneFunctionInfoEditPage(scene, scenefunction, refreshFunctionRowAction);
                    MainPage.BasePageView.AddChidren(ssf);
                    ssf.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                btnFunctionName.MouseUpEventHandler = skipEvent;
                btnFunctionFloorAndRoom.MouseUpEventHandler = skipEvent;
                Button btnDelSceneFunction = new Button() {
@@ -518,55 +535,8 @@
                    scene.EditScene();
                    row.RemoveFromParent();
                    functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count);
                    //LoadFunctionRow(functionListView);
                };
            }
        }
        /// <summary>
        /// 解析场景功能数据
        /// </summary>
        /// <param name="sceneFunction"></param>
        string GetFunctionScnenInfo(SceneFunction sceneFunction)
        {
            var sceneFunctionInfo = "";
            foreach (var sfs in sceneFunction.status)
            {
                if (sfs.key == FunctionAttributeKey.OnOff)
                {
                    if (sfs.value == "off")
                        return Language.StringByID(StringId.Close);
                }
            }
            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 += briState.value + "%";
            }
            var perState = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
            if (perState != null)
            {
                sceneFunctionInfo += perState.value + "%";
            }
            return sceneFunctionInfo;
        }
        /// <summary>
@@ -788,6 +758,7 @@
                pictureOptionView.Parent.RemoveFromParent();
                Action<string> action = (obj) => {
                    scene.ImagePath = obj;
                    addSceneImageView.ImageBytes = null;//解决有ImageBytes不加载ImagePath
                    addSceneImageView.ImagePath = scene.ImagePath;
                    scene.EditScene();
                };