wxr
2023-07-17 a100ed2898468add96398ae069080a103c355c08
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();
                }
            };
        }