From a100ed2898468add96398ae069080a103c355c08 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 17 七月 2023 16:41:41 +0800
Subject: [PATCH] 视频门锁优化

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs |  212 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 204 insertions(+), 8 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
index fda1210..cfa8765 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
@@ -12,6 +12,15 @@
         FrameLayout bodyView;
 
         Function device;
+
+        /// <summary>
+        /// 闂ㄩ搩绯荤粺闊抽噺
+        /// </summary>
+        int doorlockSystemSound = 0;
+        /// <summary>
+        /// 闂ㄩ搩闊抽噺
+        /// </summary>
+        int doorbelVol = 0;
         public VideoDoorlockAudioSetupPage(Function function)
         {
             device = function;
@@ -65,7 +74,7 @@
 
             btnDoorlockSystemVolumeText.MouseUpEventHandler = (sender, e) =>
             {
-
+                LoadEditDialog(StringId.DoorlockSystemVolume, 3-doorlockSystemSound, btnDoorlockSystemVolumeStateText);
             };
             #endregion
 
@@ -115,6 +124,7 @@
 
             btnDoorbellVolumeText.MouseUpEventHandler = (sender, e) =>
             {
+                LoadEditDialog(StringId.DoorbellVolume, doorbelVol, btnDoorbellVolumeStateText);
 
             };
             #endregion
@@ -145,15 +155,19 @@
                                 switch (doorLockSystemSound.sound)
                                 {
                                     case 0:
+                                        doorlockSystemSound = 0;
                                         btnDoorlockSystemVolumeStateText.TextID = StringId.Mute;
                                         break;
                                     case 1:
+                                        doorlockSystemSound = 1;
                                         btnDoorlockSystemVolumeStateText.TextID = StringId.Low;
                                         break;
                                     case 2:
+                                        doorlockSystemSound = 2;
                                         btnDoorlockSystemVolumeStateText.TextID = StringId.Moderate;
                                         break;
                                     case 3:
+                                        doorlockSystemSound = 3;
                                         btnDoorlockSystemVolumeStateText.TextID = StringId.High;
                                         break;
                                 }
@@ -191,18 +205,22 @@
                             {
                                 if (doorbellTone.volume == 0)
                                 {
+                                    doorbelVol = 3;
                                     btnDoorbellVolumeStateText.TextID = StringId.Mute;
                                 }
                                 else if (doorbellTone.volume > 0 && doorbellTone.volume < 35)
                                 {
+                                    doorbelVol = 2;
                                     btnDoorbellVolumeStateText.TextID = StringId.Low;
                                 }
                                 else if (doorbellTone.volume > 35 && doorbellTone.volume < 70)
                                 {
+                                    doorbelVol = 1;
                                     btnDoorbellVolumeStateText.TextID = StringId.Moderate;
                                 }
                                 else if (doorbellTone.volume > 70)
                                 {
+                                    doorbelVol = 0;
                                     btnDoorbellVolumeStateText.TextID = StringId.High;
                                 }
                             }
@@ -253,7 +271,7 @@
         /// <summary>
         /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥
         /// </summary>
-        void LoadEditDialog_FunctionPar(int titleId, int index, Button btn)
+        void LoadEditDialog(int titleId, int index, Button btn)
         {
             Button lastButton = new Button();
             var lastData = "";
@@ -314,7 +332,8 @@
 
             var btnConfrim = new Button()
             {
-                Width = Application.GetRealWidth(320),
+                X = Application.GetRealWidth(200),
+                Width = Application.GetRealWidth(120),
                 TextAlignment = TextAlignment.CenterRight,
                 TextColor = CSS_Color.MainColor,
                 TextSize = CSS_FontSize.TextFontSize,
@@ -349,7 +368,6 @@
                         Height = 1,
                     });
                 }
-                hei++;
 
                 var btnChoose = new Button()
                 {
@@ -373,7 +391,7 @@
                     TextAlignment = TextAlignment.CenterLeft,
                     TextColor = CSS_Color.FirstLevelTitleColor,
                     TextSize = CSS_FontSize.TextFontSize,
-                    Tag = index,
+                    Tag = hei-1,
                     Text = m
                 };
                 row.AddChidren(btnPropertyTitle);
@@ -388,6 +406,7 @@
                     lastData = btnPropertyTitle.Tag.ToString();
                     lastText = btnPropertyTitle.Text;
                 };
+                hei++;
             }
 
 
@@ -404,9 +423,186 @@
             };
             btnConfrim.MouseUpEventHandler = (sender, e) => {
                 dialog.Close();
-                trait.value = lastData;
-                //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ;
-                btn.Text = lastText;
+                if(titleId == StringId.DoorlockSystemVolume)
+                {
+
+                    var waitPage = new Loading();
+                    bodyView.AddChidren(waitPage);
+                    waitPage.Start("");
+
+                    new System.Threading.Thread(() => {
+                        try
+                        {
+                            int sound = 0;
+                            /// 0-闈欓煶 1-浣庨煶 2-涓煶 3-楂橀煶 4-鑷姩
+
+                            switch (lastData)
+                            {
+                                case "0":
+                                    sound = 3;
+                                    break;
+                                case "1":
+                                    sound = 2;
+                                    break;
+                                case "2":
+                                    sound = 1;
+                                    break;
+                                case "3":
+                                    sound = 0;
+                                    break;
+                            }
+
+
+                            var pack = ApiUtlis.Ins.HttpRequest.SetDoorLockSystemSound(device.deviceId,sound);
+                            if (pack != null && pack.Code == StateCode.SUCCESS)
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    //鏇存柊鐣岄潰
+                                    switch (sound)
+                                    {
+                                        case 0:
+                                            btn.TextID = StringId.Mute;
+                                            break;
+                                        case 1:
+                                            btn.TextID = StringId.Low;
+                                            break;
+                                        case 2:
+                                            btn.TextID = StringId.Moderate;
+                                            break;
+                                        case 3:
+                                            btn.TextID = StringId.High;
+                                            break;
+                                    }
+                                });
+                            }
+                            else
+                            {
+                                //澶辫触鎻愮ず
+                                Application.RunOnMainThread(() =>
+                                {
+                                    if (!string.IsNullOrEmpty(pack.message))
+                                    {
+                                        var tip = new Tip()
+                                        {
+                                            MaxWidth = Application.GetRealWidth(300),
+                                            Text = $"{pack.message}({pack.Code})",
+                                            CloseTime = 3,
+                                            Direction = AMPopTipDirection.None
+                                        };
+                                        tip.Show(MainPage.BaseView);
+                                    }
+                                });
+                            }
+
+                        }
+                        catch (Exception ex)
+                        {
+                            MainPage.Log($"{this.GetType()} error 4: {ex.Message}");
+                        }
+                        finally
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                waitPage.Hide();
+                            });
+                        }
+
+                    })
+                    { IsBackground = true }.Start();
+
+
+
+                }
+                else
+                {
+
+                    var waitPage = new Loading();
+                    bodyView.AddChidren(waitPage);
+                    waitPage.Start("");
+
+                    new System.Threading.Thread(() => {
+                        try
+                        {
+                            int Vol = 0;
+                            switch (lastData)
+                            {
+                                case "0":
+                                    Vol = 100;
+                                    break;
+                                case "1":
+                                    Vol = 70;
+                                    break;
+                                case "2":
+                                    Vol = 30;
+                                    break;
+                                case "3":
+                                    Vol = 0;
+                                    break;
+                            }
+
+                            var pack = ApiUtlis.Ins.HttpRequest.SetDoorBellTone(device.deviceId,Vol);
+                            if (pack != null && pack.Code == StateCode.SUCCESS)
+                            {
+                                Application.RunOnMainThread(() =>
+                                {
+                                    //鏇存柊鐣岄潰
+                                    switch (lastData)
+                                    {
+                                        case "0":
+                                            btn.TextID = StringId.High;
+                                            break;
+                                        case "1":
+                                            btn.TextID = StringId.Moderate;
+                                            break;
+                                        case "2":
+                                            btn.TextID = StringId.Low;
+                                            break;
+                                        case "3":
+                                            btn.TextID = StringId.Mute;
+                                            break;
+                                    }
+                                });
+                            }
+                            else
+                            {
+                                //澶辫触鎻愮ず
+                                Application.RunOnMainThread(() =>
+                                {
+                                    if (!string.IsNullOrEmpty(pack.message))
+                                    {
+                                        var tip = new Tip()
+                                        {
+                                            MaxWidth = Application.GetRealWidth(300),
+                                            Text = $"{pack.message}({pack.Code})",
+                                            CloseTime = 3,
+                                            Direction = AMPopTipDirection.None
+                                        };
+                                        tip.Show(MainPage.BaseView);
+                                    }
+                                });
+                            }
+
+
+                        }
+                        catch (Exception ex)
+                        {
+                            MainPage.Log($"{this.GetType()} error 5 : {ex.Message}");
+                        }
+                        finally
+                        {
+                            Application.RunOnMainThread(() =>
+                            {
+                                waitPage.Hide();
+                            });
+                        }
+
+                    })
+                    { IsBackground = true }.Start();
+
+
+
+                }
             };
 
         }

--
Gitblit v1.8.0