From 3037541d683de2f9dd775870055d244ba15839f2 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期四, 03 十二月 2020 20:23:06 +0800
Subject: [PATCH] 2020-12-03-3

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs |  117 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 84 insertions(+), 33 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
index b6e8ab6..8fa2108 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -73,18 +73,19 @@
                             switchView.btnOn.MouseUpEventHandler += (sender2, e2) =>
                             {
                                 LogicMethod.dictionary(dic, "value", "on");
-                                RemView(frame);
                                 lightSwitchView.btnState.TextID = StringId.onLogic;
                                 selectedState = device.functionType + "_on";
                                 AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
                             };
                             switchView.btnOff.MouseUpEventHandler += (sender3, e3) =>
                             {
                                 LogicMethod.dictionary(dic, "value", "off");
-                                RemView(frame);
                                 lightSwitchView.btnState.TextID = StringId.offLogic;
                                 selectedState = device.functionType + "_off";
                                 AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
+
                             };
                             if (lightSwitchView.btnState.Text != "")
                             {
@@ -106,44 +107,59 @@
                                 BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                             };
                             this.AddChidren(frame);
+                            int brightnesValue =0;
                             Dictionary<string, string> dic = new Dictionary<string, string>();
-                            LogicMethod.dictionary(dic, "key", "on_off");
-                            keyVlaue = "on_off";
+                            LogicMethod.dictionary(dic, "key", "brightness");
+                            keyVlaue = "brightness";
                             LogicView.BrightnessView brightness = new LogicView.BrightnessView();
                             brightness.btnTitle.TextID = StringId.brightnesLogic;
                             brightness.FLayoutView(frame);
-                            brightness.btn_subtract.MouseUpEventHandler += (sender2, e2) =>
+                            brightness.btn_subtract_click.MouseUpEventHandler += (sender2, e2) =>
                             {
-                                LogicMethod.dictionary(dic, "value", "on");
-                                RemView(frame);
-                                lightSwitchView.btnState.TextID = StringId.onLogic;
-                                selectedState = device.functionType + "_on";
-                                AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                if (brightnesValue > 0)
+                                {
+                                    brightnesValue -= 1;
+                                    brightness.seekBarVol.Progress = brightnesValue;
+                                }
                             };
-                            brightness.btn_add.MouseUpEventHandler += (sender3, e3) =>
+                            brightness.btn_add_click.MouseUpEventHandler += (sende2, e2) =>
                             {
-                                LogicMethod.dictionary(dic, "value", "off");
-                                RemView(frame);
-                                lightSwitchView.btnState.TextID = StringId.offLogic;
-                                selectedState = device.functionType + "_off";
-                                AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                if (brightnesValue < 100)
+                                {
+                                    brightnesValue += 1;
+                                    brightness.seekBarVol.Progress = brightnesValue;
+
+                                }
                             };
-                            if (lightSwitchView.btnState.Text != "")
+                            EventHandler<int> progressclick = (sender2, e2) =>
                             {
-                                //if (lightSwitchView.btnState.Text == switchView.btnOn.Text)
-                                //{
-                                //    switchView.btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
-                                //}
-                                //else
-                                //{
-                                //    switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
-                                //}
+                                brightnesValue = brightness.seekBarVol.Progress;
+                            };
+                            brightness.seekBarVol.OnProgressChangedEvent += progressclick;
+                            brightness.seekBarVol.OnStopTrackingTouchEvent += progressclick;
+                            brightness.btnConfirm.MouseUpEventHandler += (sende2, e2) =>
+                            {
+                                if (brightnesValue ==0)
+                                {
+                                    return;
+                                }
+
+                                LogicMethod.dictionary(dic, "value", brightnesValue.ToString());
+                                selectedState = device.functionType + brightnesValue.ToString();
+                                AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                brightnessView.btnState.Text = brightnesValue.ToString();
+                                RemView(frame);
+
+                            };
+                            if (brightnessView.btnState.Text != "")
+                            {
+                                brightnesValue = int.Parse(brightnessView.btnState.Text);
+                                brightness.seekBarVol.Progress = brightnesValue;
                             }
                         };
-
                         if (edit)
                         {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
+                            GetEditState(device, index, lightSwitchView.btnState, brightnessView.btnState, null, null);
                         }
                         #endregion
                     }
@@ -174,18 +190,19 @@
                             switchView.btnOn.MouseUpEventHandler += (sender2, e2) =>
                             {
                                 LogicMethod.dictionary(dic, "value", "on");
-                                RemView(frame);
                                 lightSwitchView.btnState.TextID = StringId.onLogic;
                                 selectedState = device.functionType + "_on";
                                 AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
                             };
                             switchView.btnOff.MouseUpEventHandler += (sender3, e3) =>
                             {
                                 LogicMethod.dictionary(dic, "value", "off");
-                                RemView(frame);
                                 lightSwitchView.btnState.TextID = StringId.offLogic;
                                 selectedState = device.functionType + "_off";
                                 AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
+
                             };
                             if (lightSwitchView.btnState.Text != "")
                             {
@@ -201,7 +218,7 @@
                         };
                         if (edit)
                         {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
+                            GetEditState(device, index, lightSwitchView.btnState, null, null, null);
                         }
                     }
                     break;
@@ -270,17 +287,22 @@
         /// 鏄剧ず缂栬緫涔嬪墠鐨勮澶囩姸鎬�
         /// </summary>
         /// <param name="device">缂栬緫璁惧</param>
-        /// <param name="edit">缂栬緫鐘舵��</param>
         /// <param name="index">缂栬緫鏁版嵁鐨勭储寮�</param>
         /// <param name="button1">鏄剧ずBtn</param>
         /// <param name="button2">鏄剧ずBtn</param>
         /// <param name="button3">鏄剧ずBtn</param>
         /// <param name="button4">鏄剧ずBtn</param>
-        private void GetEditState(Entity.Function device, bool edit, int index, Button button1, Button button2, Button button3, Button button4)
+        private void GetEditState(Entity.Function device, int index, Button button1, Button button2, Button button3, Button button4)
         {
             Output outputs = Logic.currlogic.output[index];
             var dicList = outputs.status as List<Dictionary<string, string>>;
-
+            //娓呴櫎涔嬪墠鏃ф暟鎹�
+            dicSateteList.Clear();
+            if (dicList.Count != 0)
+            {
+                //鏈夋暟鎹噸鏂拌祴鍊�
+                dicSateteList = dicList;
+            }
             switch (device.functionType)
             {
                 //寮�鍏崇伅鍏�
@@ -300,7 +322,36 @@
                         }
                     }
                     break;
+                case FunctionType.Dimmer:
+                    {
+                        foreach (var dic in dicList)
+                        {
+                            string value = dic["value"];
+                            switch (dic["key"])
+                            {
+                                case "on_off":
+                                    {
+                                        if (value == "on")
+                                        {
+                                            button1.Text = Language.StringByID(StringId.onLogic);
+                                        }
+                                        else
+                                        {
+                                            button1.Text = Language.StringByID(StringId.offLogic);
+                                        }
+                                    }
+                                    break;
+                                case "brightness":
+                                    {
 
+                                        button2.Text = value;
+                                    }
+                                    break;
+                            }
+
+                        }
+                    }
+                    break;
             }
 
         }

--
Gitblit v1.8.0