From 43b0d5870d528f23ecd6aeceb6cfd4325188b46f Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 01 七月 2021 15:50:43 +0800
Subject: [PATCH] Revert "1"

---
 HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs |  280 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 250 insertions(+), 30 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
index 3485bdd..ff17320 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Scene/SetSceneFunctionInfoPage.cs
@@ -11,6 +11,7 @@
         FrameLayout bodyView;
         VerticalScrolViewLayout contentView;
         Button btnOnText;
+        Button btnBrightnessText;
 
         Scene scene;
 
@@ -59,6 +60,9 @@
                     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;
                 }
             }
 
@@ -66,33 +70,36 @@
             //LoadFunctionRow(sceneFunction.localFunction.trait_on_off);
             //switch (sceneFunction.localFunction.functionType)
             //{
-            //    case FunctionType.AC:
+            //    case SPK.AcStandard:
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp"));
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode"));
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "fan"));
             //        break;
-            //    case FunctionType.FloorHeating:
+            //    case SPK.FloorHeatStandard:
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "set_temp"));
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "mode"));
             //        break;
-            //    case FunctionType.Curtain:
+            //    case SPK.CurtainSwitch:
             //        //鏃犳搷浣�
             //        break;
-            //    case FunctionType.MotorCurtain:
-            //    case FunctionType.RollingShutter:
+            //    case SPK.CurtainTrietex:
+            //    case SPK.CurtainRoller:
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "percent"));
             //        break;
-            //    case FunctionType.Relay:
+            //    case SPK.LightSwitch:
             //        //鏃犳搷浣�
             //        break;
-            //    case FunctionType.Dimmer:
-            //    case FunctionType.RGB:
+            //    case SPK.LightDimming:
+            //    case SPK.LightRGB:
             //        LoadFunctionRow(sceneFunction.localFunction.attributes.Find((obj) => obj.key == "brightness"));
             //        break;
             //}
 
-            //鍔犺浇寤舵椂Row
-            LoadDelayRow();
+            if (DB_ResidenceData.Instance.GatewayType != 0)
+            {
+                //鍔犺浇寤舵椂Row
+                LoadDelayRow();
+            }
 
             var bottomView = new FrameLayout()
             {
@@ -122,6 +129,16 @@
             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;
@@ -143,6 +160,11 @@
                         DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(result);
                     }
                 }
+                else
+                {
+                    refreshAction();
+                    this.RemoveFromParent();
+                }
             };
         }
 
@@ -161,11 +183,20 @@
                 BackgroundColor = CSS_Color.MainBackgroundColor,
             };
             contentView.AddChidren(row);
+
+
             if (sceneStatus.key != FunctionAttributeKey.OnOff)
             {
                 row.AddChidren(new Button() { X = Application.GetRealWidth(16), Height = Application.GetRealHeight(1), Width = Application.GetRealWidth(343), BackgroundColor = CSS_Color.DividingLineColor });
             }
-            Button btnBrightnessRight = new Button()
+            else
+            {
+                if(sceneStatus.value == "stop")
+                {
+                    sceneStatus.value = "on";
+                }
+            }
+            Button btnRight = new Button()
             {
                 X = Application.GetRealWidth(339),
                 Gravity = Gravity.CenterVertical,
@@ -173,7 +204,7 @@
                 Height = Application.GetMinRealAverage(16),
                 UnSelectedImagePath = "Public/Right.png",
             };
-            row.AddChidren(btnBrightnessRight);
+            row.AddChidren(btnRight);
 
             var btnFunctionText = new Button()
             {
@@ -181,11 +212,17 @@
                 TextAlignment = TextAlignment.CenterRight,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-                Text = FunctionList.List.GetValueText(sceneStatus.key,sceneStatus.value) + FunctionList.List.GetUintString(sceneStatus.key)
+                Text = sceneStatus.GetValueText() + sceneStatus.GetUintString()
             };
             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()
             {
@@ -193,7 +230,7 @@
                 TextAlignment = TextAlignment.CenterLeft,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
-                Text = FunctionList.List.GetNameText(sceneStatus.key)
+                Text = sceneStatus.GetNameText()
             };
             row.AddChidren(btnFunctionName);
             btnFunctionName.MouseUpEventHandler = (sender, e) =>
@@ -227,7 +264,8 @@
                     case FunctionAttributeKey.SetTemp:
                         LoadEditDialog_Temp(sceneStatus, btnFunctionText);
                         break;
-                    case "delay":
+                    case FunctionAttributeKey.FadeTime:
+
                         break;
                     case "cct":
                         break;
@@ -272,7 +310,7 @@
                 TextAlignment = TextAlignment.CenterRight,
                 TextColor = CSS_Color.PromptingColor1,
                 TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
-                Text = FunctionList.List.GetDelayText( sceneFunction.delay)
+                Text = new Scene() { delay = sceneFunction.delay }.GetDelayText()
             };
             delayRow.AddChidren(btnDelayInfo);
 
@@ -290,14 +328,20 @@
             btnSceneDelayTitle.MouseUpEventHandler = (sender, e) => {
                 Action<string> action = (obj) => {
                     sceneFunction.delay = obj;
-                    btnDelayInfo.Text = FunctionList.List.GetDelayText(obj);
+                    btnDelayInfo.Text = new Scene() { delay = sceneFunction.delay }.GetDelayText();
                 };
-                new PublicAssmebly().SetSceneDelayDialog(action,sceneFunction.delay);
+                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, sceneFunction.delay);
             };
             #endregion
 
 
         }
+
         #endregion
 
         #region 灞炴�ч�夋嫨寮圭獥
@@ -389,13 +433,41 @@
                 dialog.Close();
                 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);
+                btn.Text = trait.GetValueText() + trait.GetUintString();
+
+                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 = temp.GetValueText() + "%";
+                }
             };
             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);
+                btn.Text= trait.GetValueText() + trait.GetUintString();
+
+                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 = temp.GetValueText() + "%";
+                }
             };
 
         }
@@ -478,16 +550,16 @@
             };
             for (int i = 16; i <= 32; i += 1)
             {
-                pickerItems.Add(i.ToString() + FunctionList.List.GetUintString(trait.key));
+                pickerItems.Add(i.ToString() + trait.GetUintString());
             }
             uIPickerView.setNPicker(pickerItems, null, null);
             optionBaseView.AddChidren(uIPickerView);
             uIPickerView.setCurrentItems(pickerItems.IndexOf(trait.value.ToString()), 4, 5);
 
             string selectItem = pickerItems[0];
-            if (pickerItems.Contains(trait.value + FunctionList.List.GetUintString(trait.key)))
+            if (pickerItems.Contains(trait.value + trait.GetUintString()))
             {
-                selectItem = trait.value.ToString() + FunctionList.List.GetUintString(trait.key);
+                selectItem = trait.value.ToString() + trait.GetUintString();
             }
 
             dialog.Show();
@@ -506,7 +578,7 @@
                 dialog.Close();
                 btn.Text = selectItem;
                 //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.value.ToString() ;
-                trait.value = selectItem.Replace(FunctionList.List.GetUintString(trait.key),"");
+                trait.value = selectItem.Replace(trait.GetUintString(),"");
             };
 
         }
@@ -560,7 +632,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 TextAlignment = TextAlignment.Center,
                 Width = Application.GetRealWidth(100),
-                Text = FunctionList.List.GetNameText(trait.key),
+                Text = trait.GetNameText(),
                 IsBold = true,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
@@ -649,7 +721,7 @@
             {
                 dialog.Close();
                 trait.value = controlBar.Progress.ToString();
-                btn.Text = trait.value + FunctionList.List.GetUintString(trait.key);
+                btn.Text = trait.value + trait.GetUintString();
 
                 var temp = sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff);
                 if (temp != null)
@@ -662,11 +734,159 @@
                     {
                         temp.value = "off";
                     }
-                    btnOnText.Text = FunctionList.List.GetValueText(temp.key, temp.value);
+                    btnOnText.Text = temp.GetValueText();
                 }
             };
         }
- 
+
+
+        /// <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 = trait.GetNameText(),
+                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 + trait.GetUintString();
+            };
+        }
+
+
         /// <summary>
         /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥
         /// </summary>
@@ -711,7 +931,7 @@
                 Gravity = Gravity.CenterHorizontal,
                 TextAlignment = TextAlignment.Center,
                 Width = Application.GetRealWidth(100),
-                Text = FunctionList.List.GetNameText(trait.key),
+                Text = trait.GetNameText(),
                 IsBold = true,
                 TextColor = CSS_Color.FirstLevelTitleColor,
                 TextSize = CSS_FontSize.SubheadingFontSize,
@@ -783,7 +1003,7 @@
                     TextColor = CSS_Color.FirstLevelTitleColor,
                     TextSize = CSS_FontSize.TextFontSize,
                     Tag = m,
-                    Text = FunctionList.List.GetValueText(trait.key, m)
+                    Text = trait.GetValueText()
                 };
                 row.AddChidren(btnPropertyTitle);
 

--
Gitblit v1.8.0