mac
2024-07-25 3f6685c77beeb12baf840733fb890860f4c26e7c
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()
                                        {