From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs |  151 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 117 insertions(+), 34 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
index cfa8765..6c0595b 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs
@@ -12,17 +12,17 @@
         FrameLayout bodyView;
 
         Function device;
-
         /// <summary>
-        /// 闂ㄩ搩绯荤粺闊抽噺
+        /// 闂ㄩ攣绯荤粺闊抽噺
         /// </summary>
-        int doorlockSystemSound = 0;
+        DoorLockSystemSound doorLockSystemSound;
         /// <summary>
         /// 闂ㄩ搩闊抽噺
         /// </summary>
-        int doorbelVol = 0;
+        int doorbellVol = 0;
         public VideoDoorlockAudioSetupPage(Function function)
         {
+            doorLockSystemSound = new DoorLockSystemSound();
             device = function;
             bodyView = this;
         }
@@ -74,7 +74,7 @@
 
             btnDoorlockSystemVolumeText.MouseUpEventHandler = (sender, e) =>
             {
-                LoadEditDialog(StringId.DoorlockSystemVolume, 3-doorlockSystemSound, btnDoorlockSystemVolumeStateText);
+                LoadEditDialog(StringId.DoorlockSystemVolume, btnDoorlockSystemVolumeStateText,true);
             };
             #endregion
 
@@ -124,7 +124,7 @@
 
             btnDoorbellVolumeText.MouseUpEventHandler = (sender, e) =>
             {
-                LoadEditDialog(StringId.DoorbellVolume, doorbelVol, btnDoorbellVolumeStateText);
+                LoadEditDialog(StringId.DoorbellVolume, btnDoorbellVolumeStateText,false);
 
             };
             #endregion
@@ -149,25 +149,21 @@
                         Application.RunOnMainThread(() =>
                         {
                             //鏇存柊鐣岄潰
-                            var doorLockSystemSound = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockSystemSound>(pack.Data.ToString());
+                            doorLockSystemSound = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLockSystemSound>(pack.Data.ToString());
                             if(doorLockSystemSound != null)
                             {
                                 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;
                                 }
@@ -179,7 +175,11 @@
                         //澶辫触鎻愮ず
                         Application.RunOnMainThread(() =>
                         {
-                            if (!string.IsNullOrEmpty(pack.message))
+
+                            if (string.IsNullOrEmpty(pack.message))
+                            {
+                                pack.message = Language.StringByID(StringId.OperationFailed);
+                            }
                             {
                                 var tip = new Tip()
                                 {
@@ -205,22 +205,22 @@
                             {
                                 if (doorbellTone.volume == 0)
                                 {
-                                    doorbelVol = 3;
+                                    doorbellVol = 0;
                                     btnDoorbellVolumeStateText.TextID = StringId.Mute;
                                 }
                                 else if (doorbellTone.volume > 0 && doorbellTone.volume < 35)
                                 {
-                                    doorbelVol = 2;
+                                    doorbellVol = 1;
                                     btnDoorbellVolumeStateText.TextID = StringId.Low;
                                 }
                                 else if (doorbellTone.volume > 35 && doorbellTone.volume < 70)
                                 {
-                                    doorbelVol = 1;
+                                    doorbellVol = 2;
                                     btnDoorbellVolumeStateText.TextID = StringId.Moderate;
                                 }
                                 else if (doorbellTone.volume > 70)
                                 {
-                                    doorbelVol = 0;
+                                    doorbellVol = 3;
                                     btnDoorbellVolumeStateText.TextID = StringId.High;
                                 }
                             }
@@ -231,7 +231,10 @@
                         //澶辫触鎻愮ず
                         Application.RunOnMainThread(() =>
                         {
-                            if (!string.IsNullOrEmpty(pack.message))
+                            if (string.IsNullOrEmpty(pack.message))
+                            {
+                                pack.message = Language.StringByID(StringId.OperationFailed);
+                            }
                             {
                                 var tip = new Tip()
                                 {
@@ -271,10 +274,10 @@
         /// <summary>
         /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥
         /// </summary>
-        void LoadEditDialog(int titleId, int index, Button btn)
+        void LoadEditDialog(int titleId, Button btn,bool isDoorlockSystemVolume)
         {
             Button lastButton = new Button();
-            var lastData = "";
+            
             var lastText = "";
             Dialog dialog = new Dialog();
 
@@ -311,7 +314,7 @@
             {
                 Gravity = Gravity.CenterHorizontal,
                 TextAlignment = TextAlignment.Center,
-                Width = Application.GetRealWidth(100),
+                Width = Application.GetRealWidth(150),
                 TextID = titleId,
                 IsBold = true,
                 TextColor = CSS_Color.FirstLevelTitleColor,
@@ -340,7 +343,7 @@
                 TextID = StringId.Complete,
             };
             topView.AddChidren(btnConfrim);
-            int hei = 1;
+            int index = 1;
             var statusList = new List<string>
             {
                 Language.StringByID(StringId.High),
@@ -353,11 +356,11 @@
             {
                 var row = new FrameLayout()
                 {
-                    Y = Application.GetRealHeight(50 * hei),
+                    Y = Application.GetRealHeight(50 * index),
                     Height = Application.GetRealHeight(50),
                 };
                 optionBaseView.AddChidren(row);
-                if (statusList.Count > hei)
+                if (statusList.Count > index)
                 {
                     optionBaseView.AddChidren(new Button()
                     {
@@ -377,13 +380,76 @@
                     Height = Application.GetMinRealAverage(28),
                     UnSelectedImagePath = "Public/ChooseIcon.png",
                     SelectedImagePath = "Public/ChooseOnIcon.png",
-
+                    Tag = index - 1,
                 };
                 row.AddChidren(btnChoose);
-                if (index == hei - 1)
+                if (isDoorlockSystemVolume) {//璁剧疆闂ㄩ攣绯荤粺闊抽噺
+                    switch (doorLockSystemSound.sound)
+                    {
+                        case 0:
+                            if (index == 3 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 1:
+                            if (index == 2 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 2:
+                            if (index == 1 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 3:
+                            if (index == 0 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                    }
+                }
+                else//璁剧疆闂ㄩ搩闊抽噺
                 {
-                    lastButton = btnChoose;
-                    btnChoose.IsSelected = true;
+                    switch (doorbellVol)
+                    {
+                        case 0:
+                            if (index == 3 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 1:
+                            if (index == 2 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 2:
+                            if (index == 1 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                        case 3:
+                            if (index == 0 + 1)
+                            {
+                                lastButton = btnChoose;
+                                btnChoose.IsSelected = true;
+                            }
+                            break;
+                    }
+
                 }
                 var btnPropertyTitle = new Button()
                 {
@@ -391,22 +457,24 @@
                     TextAlignment = TextAlignment.CenterLeft,
                     TextColor = CSS_Color.FirstLevelTitleColor,
                     TextSize = CSS_FontSize.TextFontSize,
-                    Tag = hei-1,
                     Text = m
                 };
                 row.AddChidren(btnPropertyTitle);
 
                 btnPropertyTitle.MouseUpEventHandler = (sender, e) => {
+                    if (btnChoose.IsSelected)
+                    {
+                        return;
+                    }
                     btnChoose.IsSelected = true;
                     if (lastButton != null)
                     {
                         lastButton.IsSelected = false;
                     }
                     lastButton = btnChoose;
-                    lastData = btnPropertyTitle.Tag.ToString();
                     lastText = btnPropertyTitle.Text;
                 };
-                hei++;
+                index++;
             }
 
 
@@ -423,13 +491,14 @@
             };
             btnConfrim.MouseUpEventHandler = (sender, e) => {
                 dialog.Close();
-                if(titleId == StringId.DoorlockSystemVolume)
+                var lastData = lastButton.Tag.ToString();
+
+                if (isDoorlockSystemVolume)
                 {
 
                     var waitPage = new Loading();
                     bodyView.AddChidren(waitPage);
                     waitPage.Start("");
-
                     new System.Threading.Thread(() => {
                         try
                         {
@@ -462,15 +531,19 @@
                                     switch (sound)
                                     {
                                         case 0:
+                                            doorLockSystemSound.sound = 0;
                                             btn.TextID = StringId.Mute;
                                             break;
                                         case 1:
+                                            doorLockSystemSound.sound = 1;
                                             btn.TextID = StringId.Low;
                                             break;
                                         case 2:
+                                            doorLockSystemSound.sound = 2;
                                             btn.TextID = StringId.Moderate;
                                             break;
                                         case 3:
+                                            doorLockSystemSound.sound = 3;
                                             btn.TextID = StringId.High;
                                             break;
                                     }
@@ -481,7 +554,10 @@
                                 //澶辫触鎻愮ず
                                 Application.RunOnMainThread(() =>
                                 {
-                                    if (!string.IsNullOrEmpty(pack.message))
+                                    if (string.IsNullOrEmpty(pack.message))
+                                    {
+                                        pack.message = Language.StringByID(StringId.OperationFailed);
+                                    }
                                     {
                                         var tip = new Tip()
                                         {
@@ -550,15 +626,19 @@
                                     switch (lastData)
                                     {
                                         case "0":
+                                            doorbellVol = 3;
                                             btn.TextID = StringId.High;
                                             break;
                                         case "1":
+                                            doorbellVol = 2;
                                             btn.TextID = StringId.Moderate;
                                             break;
                                         case "2":
+                                            doorbellVol = 1;
                                             btn.TextID = StringId.Low;
                                             break;
                                         case "3":
+                                            doorbellVol = 0;
                                             btn.TextID = StringId.Mute;
                                             break;
                                     }
@@ -569,7 +649,10 @@
                                 //澶辫触鎻愮ず
                                 Application.RunOnMainThread(() =>
                                 {
-                                    if (!string.IsNullOrEmpty(pack.message))
+                                    if (string.IsNullOrEmpty(pack.message))
+                                    {
+                                        pack.message = Language.StringByID(StringId.OperationFailed);
+                                    }
                                     {
                                         var tip = new Tip()
                                         {

--
Gitblit v1.8.0