From cbc156bc38d8b8eae7aef60cb186ab2b52fa701f Mon Sep 17 00:00:00 2001 From: wxr <wxr@hdlchina.com.cn> Date: 星期二, 16 七月 2024 13:59:56 +0800 Subject: [PATCH] 增加全部挂断 --- HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs | 321 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 300 insertions(+), 21 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs index fda1210..6c0595b 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs @@ -12,8 +12,17 @@ FrameLayout bodyView; Function device; + /// <summary> + /// 闂ㄩ攣绯荤粺闊抽噺 + /// </summary> + DoorLockSystemSound doorLockSystemSound; + /// <summary> + /// 闂ㄩ搩闊抽噺 + /// </summary> + int doorbellVol = 0; public VideoDoorlockAudioSetupPage(Function function) { + doorLockSystemSound = new DoorLockSystemSound(); device = function; bodyView = this; } @@ -65,7 +74,7 @@ btnDoorlockSystemVolumeText.MouseUpEventHandler = (sender, e) => { - + LoadEditDialog(StringId.DoorlockSystemVolume, btnDoorlockSystemVolumeStateText,true); }; #endregion @@ -115,6 +124,7 @@ btnDoorbellVolumeText.MouseUpEventHandler = (sender, e) => { + LoadEditDialog(StringId.DoorbellVolume, btnDoorbellVolumeStateText,false); }; #endregion @@ -139,7 +149,7 @@ 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) @@ -165,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() { @@ -191,18 +205,22 @@ { if (doorbellTone.volume == 0) { + doorbellVol = 0; btnDoorbellVolumeStateText.TextID = StringId.Mute; } else if (doorbellTone.volume > 0 && doorbellTone.volume < 35) { + doorbellVol = 1; btnDoorbellVolumeStateText.TextID = StringId.Low; } else if (doorbellTone.volume > 35 && doorbellTone.volume < 70) { + doorbellVol = 2; btnDoorbellVolumeStateText.TextID = StringId.Moderate; } else if (doorbellTone.volume > 70) { + doorbellVol = 3; btnDoorbellVolumeStateText.TextID = StringId.High; } } @@ -213,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() { @@ -253,10 +274,10 @@ /// <summary> /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥 /// </summary> - void LoadEditDialog_FunctionPar(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(); @@ -293,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, @@ -314,14 +335,15 @@ 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, TextID = StringId.Complete, }; topView.AddChidren(btnConfrim); - int hei = 1; + int index = 1; var statusList = new List<string> { Language.StringByID(StringId.High), @@ -334,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() { @@ -349,7 +371,6 @@ Height = 1, }); } - hei++; var btnChoose = new Button() { @@ -359,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() { @@ -373,21 +457,24 @@ TextAlignment = TextAlignment.CenterLeft, TextColor = CSS_Color.FirstLevelTitleColor, TextSize = CSS_FontSize.TextFontSize, - Tag = index, 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; }; + index++; } @@ -404,9 +491,201 @@ }; btnConfrim.MouseUpEventHandler = (sender, e) => { dialog.Close(); - trait.value = lastData; - //sceneFunction.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff).value = trait.curValue.ToString() ; - btn.Text = lastText; + var lastData = lastButton.Tag.ToString(); + + if (isDoorlockSystemVolume) + { + + 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: + 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; + } + }); + } + else + { + //澶辫触鎻愮ず + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(pack.message)) + { + pack.message = Language.StringByID(StringId.OperationFailed); + } + { + 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": + 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; + } + }); + } + else + { + //澶辫触鎻愮ず + Application.RunOnMainThread(() => + { + if (string.IsNullOrEmpty(pack.message)) + { + pack.message = Language.StringByID(StringId.OperationFailed); + } + { + 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