wei
2020-12-22 1b5ec1190a27ebe66f74ca9513020f805d3ec61c
HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
@@ -11,6 +11,7 @@
        FrameLayout bodyView;
        VerticalScrolViewLayout contentView;
        Button btnOnText;
        Button btnBrightnessText;
        Scene scene;
@@ -58,6 +59,9 @@
                        break;
                    case FunctionAttributeKey.Brightness:
                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness));
                        break;
                    case FunctionAttributeKey.FadeTime:
                        LoadFunctionRow(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.FadeTime));
                        break;
                }
            }
@@ -122,6 +126,15 @@
            btnConfrim.MouseUpEventHandler = (sender, e) =>
            {
                var temp = scene.functions.Find((obj) => obj.sid == sceneFunction.sid);
                //if (sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness) != null)
                //{
                //    try
                //    {
                //        //一端口不支持开关值与亮度值一起处理,需要将开关值移除掉
                //        sceneFunction.status.Remove(sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff));
                //    }
                //    catch { }
                //}
                if (temp != null)
                {
                    temp = sceneFunction;
@@ -142,6 +155,11 @@
                    {
                        DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result);
                    }
                }
                else
                {
                    refreshAction();
                    this.RemoveFromParent();
                }
            };
        }
@@ -165,7 +183,7 @@
            {
                row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
            }
            Button btnBrightnessRight = new Button()
            Button btnRight = new Button()
            {
                X = Application.GetRealWidth(339),
                Gravity = Gravity.CenterVertical,
@@ -173,7 +191,7 @@
                Height = Application.GetMinRealAverage(16),
                UnSelectedImagePath = "Public/Right.png",
            };
            row.AddChidren(btnBrightnessRight);
            row.AddChidren(btnRight);
            var btnFunctionText = new Button()
            {
@@ -185,7 +203,13 @@
            };
            row.AddChidren(btnFunctionText);
            if (sceneStatus.key == FunctionAttributeKey.OnOff)
            {
                btnOnText = btnFunctionText;
            }
            else if (sceneStatus.key == FunctionAttributeKey.Brightness || sceneStatus.key == FunctionAttributeKey.Percent)
            {
                btnBrightnessText = btnFunctionText;
            }
            var btnFunctionName = new Button()
            {
@@ -227,7 +251,8 @@
                    case FunctionAttributeKey.SetTemp:
                        LoadEditDialog_Temp(sceneStatus, btnFunctionText);
                        break;
                    case "delay":
                    case FunctionAttributeKey.FadeTime:
                        break;
                    case "cct":
                        break;
@@ -390,12 +415,40 @@
                trait.value = "on";
                sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "on";
                btn.Text = FunctionList.List.GetValueText(trait.key, trait.value) + FunctionList.List.GetUintString(trait.key);
                var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
                if (temp == null)
                {
                    temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
                }
                if (temp != null)
                {
                    if (temp.value == "0")
                    {
                        temp.value = "100";
                    }
                    btnBrightnessText.Text = FunctionList.List.GetValueText(temp.key, temp.value) + "%";
                }
            };
            btnOff.MouseUpEventHandler = (sender,e) =>{
                dialog.Close();
                trait.value = "off";
                sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = "off";
                btn.Text= FunctionList.List.GetValueText(trait.key,trait.value) + FunctionList.List.GetUintString(trait.key);
                var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Brightness);
                if(temp == null)
                {
                    temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.Percent);
                }
                if (temp != null)
                {
                    if (temp.value != "0")
                    {
                        temp.value = "0";
                    }
                    btnBrightnessText.Text = FunctionList.List.GetValueText(temp.key, temp.value) + "%";
                }
            };
        }
@@ -666,7 +719,155 @@
                }
            };
        }
        /// <summary>
        /// 加载变化速度选择弹窗
        /// </summary>
        /// <param name="function"></param>
        /// <param name="btn"></param>
        void LoadEditDialog_FadeTime(SceneFunctionStatus trait, Button btn)
        {
            if (trait == null)
            {
                return;
            }
            Dialog dialog = new Dialog();
            var pView = new FrameLayout()
            {
                BackgroundColor = CSS_Color.DialogTransparentColor1,
            };
            dialog.AddChidren(pView);
            var optionBaseView = new FrameLayout()
            {
                Y = Application.GetRealHeight(467),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(180),
                AnimateSpeed = 0.3f,
                Animate = Animate.DownToUp,
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
            };
            pView.AddChidren(optionBaseView);
            var topView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(40),
                BackgroundColor = CSS_Color.MainBackgroundColor,
                Radius = (uint)Application.GetRealWidth(12),
            };
            optionBaseView.AddChidren(topView);
            topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor });
            var btnTitle = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                TextAlignment = TextAlignment.Center,
                Width = Application.GetRealWidth(100),
                Text = FunctionList.List.GetNameText(trait.key),
                IsBold = true,
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
            };
            topView.AddChidren(btnTitle);
            var btnCancel = new Button()
            {
                X = Application.GetRealWidth(21),
                Width = Application.GetRealWidth(100),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.TextFontSize,
                TextID = StringId.Cancel,
            };
            topView.AddChidren(btnCancel);
            var btnConfrim = new Button()
            {
                Width = Application.GetRealWidth(320),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.TextFontSize,
                TextID = StringId.Confirm,
            };
            topView.AddChidren(btnConfrim);
            Button btnMinusSignIcon = new Button()
            {
                X = Application.GetRealWidth(26),
                Y = Application.GetRealHeight(118),
                Width = Application.GetMinRealAverage(24),
                Height = Application.GetMinRealAverage(24),
                Text = "0s",
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            optionBaseView.AddChidren(btnMinusSignIcon);
            DiyImageSeekBar controlBar = new DiyImageSeekBar()
            {
                X = btnMinusSignIcon.Right + Application.GetRealWidth(12),
                Y = Application.GetRealHeight(100),//414,设计数据
                Width = Application.GetRealWidth(220),
                Height = Application.GetRealHeight(54),
                SeekBarViewHeight = Application.GetRealHeight(8),
                ThumbImagePath = "Public/ThumbImage.png",
                ThumbImageHeight = Application.GetRealHeight(54),
                ProgressBarColor = CSS_Color.MainColor,
                ProgressTextColor = CSS_Color.FirstLevelTitleColor,
                ProgressTextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                MaxValue = 100,
                Progress = trait.value.ToString().Replace("{}", "") == "" ? 0 : Convert.ToInt32(trait.value.Replace("{}", "")),
                SeekBarPadding = Application.GetRealWidth(20),
            };
            optionBaseView.AddChidren(controlBar);
            Button btnPlusSgnIcon = new Button()
            {
                X = controlBar.Right + Application.GetRealWidth(12),
                Y = Application.GetRealHeight(118),
                Width = Application.GetMinRealAverage(24),
                Height = Application.GetMinRealAverage(24),
                Text = "10s",
                TextColor = CSS_Color.PromptingColor1,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            optionBaseView.AddChidren(btnPlusSgnIcon);
            btnMinusSignIcon.MouseUpEventHandler = (sender, e) =>
            {
                controlBar.Progress--;
            };
            btnPlusSgnIcon.MouseUpEventHandler = (sender, e) =>
            {
                controlBar.Progress++;
            };
            dialog.Show();
            pView.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            btnCancel.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
            };
            btnConfrim.MouseUpEventHandler = (sender, e) =>
            {
                dialog.Close();
                trait.value = controlBar.Progress.ToString();
                btn.Text = trait.value + FunctionList.List.GetUintString(trait.key);
            };
        }
        /// <summary>
        /// 加载功能属性数据选择弹窗
        /// </summary>