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 |  269 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 175 insertions(+), 94 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
index 1880dad..8fa2108 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TargetDeviceFunList.cs
@@ -45,10 +45,19 @@
                 //寮�鍏崇伅鍏� light.Switch
                 case FunctionType.Dimmer:
                     {
+                        #region 鐣岄潰
+                        ///寮�鍏�
                         LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
                         lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
                         fLayout.AddChidren(lightSwitchView.FLayoutView());
+                        ///浜害
+                        LogicView.FunTypeView brightnessView = new LogicView.FunTypeView();
+                        brightnessView.frameLayout.Y = lightSwitchView.frameLayout.Bottom;
+                        brightnessView.btnText.TextID = StringId.brightnesLogic;
+                        fLayout.AddChidren(brightnessView.FLayoutView());
+                        #endregion
+                        #region 鐐瑰嚮浜嬩欢
+                        ///寮�鍏崇偣鍑讳簨浠�
                         lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                         {
                             FrameLayout frame = new FrameLayout
@@ -56,86 +65,115 @@
                                 BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                             };
                             this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
+                            Dictionary<string, string> dic = new Dictionary<string, string>();
+                            LogicMethod.dictionary(dic, "key", "on_off");
+                            keyVlaue = "on_off";
+                            LogicView.SwitchView switchView = new LogicView.SwitchView();
+                            switchView.FLayoutView(frame, 2);
+                            switchView.btnOn.MouseUpEventHandler += (sender2, e2) =>
+                            {
+                                LogicMethod.dictionary(dic, "value", "on");
+                                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");
+                                lightSwitchView.btnState.TextID = StringId.offLogic;
+                                selectedState = device.functionType + "_off";
+                                AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
+
+                            };
+                            if (lightSwitchView.btnState.Text != "")
+                            {
+                                if (lightSwitchView.btnState.Text == switchView.btnOn.Text)
+                                {
+                                    switchView.btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
+                                }
+                                else
+                                {
+                                    switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
+                                }
+                            }
+                        };
+                        ///浜害鐐瑰嚮浜嬩欢
+                        brightnessView.btnClick.MouseUpEventHandler += (sender, e) =>
+                        {
+                            FrameLayout frame = new FrameLayout
+                            {
+                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
+                            };
+                            this.AddChidren(frame);
+                            int brightnesValue =0;
+                            Dictionary<string, string> dic = new Dictionary<string, string>();
+                            LogicMethod.dictionary(dic, "key", "brightness");
+                            keyVlaue = "brightness";
+                            LogicView.BrightnessView brightness = new LogicView.BrightnessView();
+                            brightness.btnTitle.TextID = StringId.brightnesLogic;
+                            brightness.FLayoutView(frame);
+                            brightness.btn_subtract_click.MouseUpEventHandler += (sender2, e2) =>
+                            {
+                                if (brightnesValue > 0)
+                                {
+                                    brightnesValue -= 1;
+                                    brightness.seekBarVol.Progress = brightnesValue;
+                                }
+                            };
+                            brightness.btn_add_click.MouseUpEventHandler += (sende2, e2) =>
+                            {
+                                if (brightnesValue < 100)
+                                {
+                                    brightnesValue += 1;
+                                    brightness.seekBarVol.Progress = brightnesValue;
+
+                                }
+                            };
+                            EventHandler<int> progressclick = (sender2, e2) =>
+                            {
+                                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
                     }
                     break;
                 case FunctionType.RGB:
-                    {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
-                        };
-                        if (edit)
-                        {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
-                        }
-
-                    }
                     break;
                 case FunctionType.RGBW:
-                    {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
-                        };
-                        if (edit)
-                        {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
-                        }
-
-                    }
                     break;
                 case FunctionType.CCT:
-                    {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
-                        };
-                        if (edit)
-                        {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
-                        }
-
-                    }
                     break;
                 case FunctionType.Relay:
                     {
                         LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
                         lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
                         fLayout.AddChidren(lightSwitchView.FLayoutView());
                         lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
                         {
@@ -144,41 +182,50 @@
                                 BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                             };
                             this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
+                            Dictionary<string, string> dic = new Dictionary<string, string>();
+                            LogicMethod.dictionary(dic, "key", "on_off");
+                            keyVlaue = "on_off";
+                            LogicView.SwitchView switchView = new LogicView.SwitchView();
+                            switchView.FLayoutView(frame, 3);
+                            switchView.btnOn.MouseUpEventHandler += (sender2, e2) =>
+                            {
+                                LogicMethod.dictionary(dic, "value", "on");
+                                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");
+                                lightSwitchView.btnState.TextID = StringId.offLogic;
+                                selectedState = device.functionType + "_off";
+                                AddDictionaryData(dicSateteList, keyVlaue, dic);
+                                RemView(frame);
+
+                            };
+                            if (lightSwitchView.btnState.Text != "")
+                            {
+                                if (lightSwitchView.btnState.Text == switchView.btnOn.Text)
+                                {
+                                    switchView.btnOn.TextColor = CSS.CSS_Color.textConfirmColor;
+                                }
+                                else
+                                {
+                                    switchView.btnOff.TextColor = CSS.CSS_Color.textConfirmColor;
+                                }
+                            }
                         };
                         if (edit)
                         {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
+                            GetEditState(device, index, lightSwitchView.btnState, null, null, null);
                         }
-
                     }
                     break;
                 //绐楀笜
                 case FunctionType.Curtain:
-                    {
-                        LogicView.FunTypeView lightSwitchView = new LogicView.FunTypeView();
-                        lightSwitchView.btnText.TextID = StringId.switchLogic;
-                        lightSwitchView.btnState.Text = "";
-                        fLayout.AddChidren(lightSwitchView.FLayoutView());
-                        lightSwitchView.btnClick.MouseUpEventHandler += (sender, e) =>
-                        {
-                            FrameLayout frame = new FrameLayout
-                            {
-                                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
-                            };
-                            this.AddChidren(frame);
-                            SwitchViewMethod(frame, device, lightSwitchView.btnState, 2);
-                        };
-                        if (edit)
-                        {
-                            GetEditState(device, edit, index, lightSwitchView.btnState, null, null, null);
-                        }
-
-                    }
                     break;
             }
-
-
             #region  淇濆瓨
             ///淇濆瓨View
             LogicView.SaveView saveView = new LogicView.SaveView();
@@ -240,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)
             {
                 //寮�鍏崇伅鍏�
@@ -270,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;
             }
 
         }
@@ -344,7 +425,7 @@
         /// <param name="device"></param>
         /// <param name="button"></param>
         /// <param name="len"></param>
-        public void SwitchViewMethod(FrameLayout frame, Entity.Function device, Button button, int len)
+        public void SwitchViewMethod1(FrameLayout frame, Entity.Function device, Button button, int len)
         {
 
             LogicView.SwitchView switchView = new LogicView.SwitchView();

--
Gitblit v1.8.0