wxr
2023-11-15 05cd80d1f3120f421008da69309a98708504be3f
HDL_ON/UI/UI2/3-Intelligence/Scene/SceneEditPage.cs
@@ -98,8 +98,9 @@
        public void LoadPage(Action backRefresh)
        {
             //DB_ResidenceData.Instance.sceneChooseRoomId
            new TopViewDiv(bodyView, Language.StringByID(StringId.EditScene)).LoadTopView(backRefresh);
            var topView = new TopViewDiv(bodyView, Language.StringByID(StringId.EditScene));
            topView.LoadTopView(backRefresh);
            initPage();
        }
@@ -109,8 +110,8 @@
            VerticalScrolViewLayout contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(603-50),
                Y = Application.GetRealHeight(64 + 10),
                Height = Application.GetRealHeight(603-50-10),
            };
            bodyView.AddChidren(contentView);
            contentView.AddChidren(new Button() { Height = Application.GetRealWidth(12) });
@@ -479,7 +480,6 @@
        void LoadFunctionRow()
        {
            functionListView.RemoveAll();
            functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count);
            for(int i =0;i<scene.functions.Count;)
            {
                var scenefunction = scene.functions[i];
@@ -488,6 +488,7 @@
                    scene.functions.Remove(scenefunction);
                    continue;
                }
                functionListView.Height = Application.GetRealWidth(65 * scene.functions.Count);
                try
                {
                    //将spk实体里面的min max值放入场景功能实体里,要不然数据会丢失 2022-06-21 16:06:45
@@ -552,6 +553,36 @@
                };
                row.AddChidren(btnFunctionInfo);
                var btnFunctionName = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Height = Application.GetRealWidth(44),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = scenefunction.localFunction.name,
                };
                row.AddChidren(btnFunctionName);
                if (scenefunction.type == "7")
                {
                    btnFunctionName.Gravity = Gravity.CenterVertical;
                    btnFunctionInfo.TextAlignment = TextAlignment.CenterRight;
                    btnFunctionInfo.Gravity = Gravity.CenterVertical;
                    btnFunctionName.MouseUpEventHandler = (sender, e) => {
                        try
                        {
                            LoadAutomationSettingDialog(scenefunction, btnFunctionInfo);
                        }
                        catch (Exception ex)
                        {
                            MainPage.Log($"load automation error : {ex.Message}");
                        }
                    };
                }
                else
                {
                var btnFunctionDelayInfo = new Button()
                {
                    Width = Application.GetRealWidth(327),
@@ -572,16 +603,6 @@
                    btnFunctionDelayInfo.Text = Language.StringByID(StringId.NoDelay);
                }
                var btnFunctionName = new Button()
                {
                    X = Application.GetRealWidth(16),
                    Height = Application.GetRealWidth(44),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = scenefunction.localFunction.name,
                };
                row.AddChidren(btnFunctionName);
                var btnFunctionFloorAndRoom = new Button()
                {
@@ -608,6 +629,7 @@
                btnFunctionInfo.MouseUpEventHandler = skipEvent;
                btnRight.MouseUpEventHandler = skipEvent;
                row.MouseUpEventHandler = skipEvent;
                }
                Button btnDelSceneFunction = new Button() {
                    BackgroundColor = CSS_Color.WarningColor,
@@ -712,6 +734,196 @@
        }
        /// <summary>
        /// 加载自动化配置弹窗
        /// </summary>
        void LoadAutomationSettingDialog(SceneFunction temp, Button btnTipText)
        {
            Dialog dialog = new Dialog();
            var pView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.DialogTransparentColor1,
            };
            dialog.AddChidren(pView);
            var optionBaseView = new FrameLayout()
            {
                Y = Application.GetRealHeight(500),
                Height = Application.GetRealHeight(160),
                AnimateSpeed = 0.3f,
                Animate = Animate.DownToUp,
            };
            pView.AddChidren(optionBaseView);
            var optionView = new VerticalScrolViewLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(100),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
                ScrollEnabled = false,
            };
            optionBaseView.AddChidren(optionView);
            var btnOn = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.OpenArm,
            };
            optionView.AddChidren(btnOn);
            optionView.AddChidren(new Button() { Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
            var btnOff = new Button()
            {
                Height = Application.GetRealHeight(50),
                TextAlignment = TextAlignment.Center,
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
                TextID = StringId.Close,
            };
            optionView.AddChidren(btnOff);
            var btnCancel = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(8) + optionView.Bottom,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(50),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
                TextID = StringId.Cancel,
                TextColor = CSS_Color.WarningColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
            };
            optionBaseView.AddChidren(btnCancel);
            dialog.Show();
            pView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            btnOn.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
                temp.type = "7";
                var kv = temp.status.Find((obj) => obj.key == "enable");
                if (kv != null)
                {
                    kv.value = "true";
                }
                else
                {
                    temp.status.Add(new SceneFunctionStatus()
                    {
                        key = "enable",
                        value = "true",
                    });
                }
                var waitPage = new Loading();
                bodyView.AddChidren(waitPage);
                waitPage.Start("");
                new System.Threading.Thread(() => {
                    try
                    {
                        var code = scene.EditScene();
                        Application.RunOnMainThread(() =>
                        {
                            if (code == "0")
                            {
                                btnTipText.TextID = StringId.OpenArm;
                            }
                            else
                            {
                                IMessageCommon.Current.ShowErrorInfoAlter(code);
                            }
                        });
                    }
                    catch { }
                    finally
                    {
                        Application.RunOnMainThread(() => {
                            if(waitPage!= null)
                            {
                                waitPage.RemoveFromParent();
                                waitPage = null;
                            }
                        });
                    }
                })
                { IsBackground = true }.Start();
            };
            btnOff.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
                temp.type = "7";
                var kv = temp.status.Find((obj) => obj.key == "enable");
                if (kv != null)
                {
                    kv.value = "false";
                }
                else
                {
                    temp.status.Add(new SceneFunctionStatus()
                    {
                        key = "enable",
                        value = "false",
                    });
                }
                var waitPage = new Loading();
                bodyView.AddChidren(waitPage);
                waitPage.Start("");
                new System.Threading.Thread(() => {
                    try
                    {
                        var code = scene.EditScene();
                        Application.RunOnMainThread(() =>
                        {
                            if (code == "0")
                            {
                                btnTipText.TextID = StringId.Close;
                            }
                            else
                            {
                                IMessageCommon.Current.ShowErrorInfoAlter(code);
                            }
                        });
                    }
                    catch { }
                    finally
                    {
                        Application.RunOnMainThread(() => {
                            if (waitPage != null)
                            {
                                waitPage.RemoveFromParent();
                                waitPage = null;
                            }
                        });
                    }
                })
                { IsBackground = true }.Start();
            };
        }
    }
    //--------------------------------------
    public partial class SceneEditPage
@@ -759,10 +971,22 @@
        void LoadEvent_ChangeFunctionList()
        {
            btnAddFunctionTitle.MouseUpEventHandler = (sender, e) => {
                var sefp =new SceneFunctionListChoosePage(scene,refreshFunctionRowAction);
                if (DB_ResidenceData.Instance.HomeGateway.isSupportSceneEnableAutomation)
                {
                    //var sefp =new SceneFunctionListChoosePage(scene,refreshFunctionRowAction);
                    var sefp = new SceneTargetTypeChoosePage(scene, refreshFunctionRowAction);
                MainPage.BasePageView.AddChidren(sefp);
                sefp.LoadPage();
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                }
                else
                {
                    var sefp = new SceneFunctionListChoosePage(scene,refreshFunctionRowAction);
                    //var sefp = new SceneTargetTypeChoosePage(scene, refreshFunctionRowAction);
                    MainPage.BasePageView.AddChidren(sefp);
                    sefp.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                }
            };
        }