From 1b56157e8edc3f502810820d99b607e3629c7171 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期三, 19 七月 2023 09:42:00 +0800 Subject: [PATCH] Merge branch 'Dev-Branch' into wjc --- HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs | 640 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 640 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs new file mode 100644 index 0000000..cfa8765 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/VideoDoorLock/VideoDoorlockAudioSetupPage.cs @@ -0,0 +1,640 @@ +锘縰sing System; +using System.Collections.Generic; +using HDL_ON.Common; +using HDL_ON.DAL.Server; +using HDL_ON.Entity; +using HDL_ON.UI.CSS; +using Shared; +namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock +{ + public class VideoDoorlockAudioSetupPage : FrameLayout + { + FrameLayout bodyView; + + Function device; + + /// <summary> + /// 闂ㄩ搩绯荤粺闊抽噺 + /// </summary> + int doorlockSystemSound = 0; + /// <summary> + /// 闂ㄩ搩闊抽噺 + /// </summary> + int doorbelVol = 0; + public VideoDoorlockAudioSetupPage(Function function) + { + device = function; + bodyView = this; + } + + public void LoadPage() + { + new TopViewDiv(bodyView, Language.StringByID(StringId.AudioSetup)).LoadTopView(); + bodyView.BackgroundColor = CSS_Color.BackgroundColor; + + + #region 闂ㄩ攣绯荤粺闊抽噺 + var doorlockSystemVolumeView = new FrameLayout() + { + Y = Application.GetRealHeight(64), + Height = Application.GetRealHeight(50), + BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + }; + bodyView.AddChidren(doorlockSystemVolumeView); + + var btnDoorlockSystemVolumeRight = new Button() + { + X = Application.GetRealWidth(339), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + UnSelectedImagePath = "Public/Right.png", + }; + doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeRight); + + var btnDoorlockSystemVolumeStateText = new Button() + { + X = Application.GetRealWidth(100), + Width = Application.GetRealWidth(223), + TextAlignment = TextAlignment.CenterRight, + TextSize = CSS_FontSize.TextFontSize, + TextColor = CSS_Color.PromptingColor1, + }; + doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeStateText); + + var btnDoorlockSystemVolumeText = new Button() + { + X = Application.GetRealWidth(16), + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.CenterLeft, + TextID = StringId.DoorlockSystemVolume, + }; + doorlockSystemVolumeView.AddChidren(btnDoorlockSystemVolumeText); + + btnDoorlockSystemVolumeText.MouseUpEventHandler = (sender, e) => + { + LoadEditDialog(StringId.DoorlockSystemVolume, 3-doorlockSystemSound, btnDoorlockSystemVolumeStateText); + }; + #endregion + + #region 闂ㄩ搩闊抽噺 + var viewDoorbellVolume = new FrameLayout() + { + Y = doorlockSystemVolumeView.Bottom, + Height = Application.GetRealHeight(50), + BackgroundColor = CSS.CSS_Color.MainBackgroundColor, + }; + bodyView.AddChidren(viewDoorbellVolume); + viewDoorbellVolume.AddChidren(new Button + { + Height = 1, + BackgroundColor = CSS_Color.DividingLineColor, + }); + + var btnDoorbellVolumeRight = new Button() + { + X = Application.GetRealWidth(339), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(16), + Height = Application.GetMinRealAverage(16), + UnSelectedImagePath = "Public/Right.png", + }; + viewDoorbellVolume.AddChidren(btnDoorbellVolumeRight); + + var btnDoorbellVolumeStateText = new Button() + { + X = Application.GetRealWidth(100), + Width = Application.GetRealWidth(223), + TextAlignment = TextAlignment.CenterRight, + TextSize = CSS_FontSize.TextFontSize, + TextColor = CSS_Color.PromptingColor1, + }; + viewDoorbellVolume.AddChidren(btnDoorbellVolumeStateText); + + var btnDoorbellVolumeText = new Button() + { + X = Application.GetRealWidth(16), + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.FirstLevelTitleColor, + TextAlignment = TextAlignment.CenterLeft, + TextID = StringId.DoorbellVolume, + }; + viewDoorbellVolume.AddChidren(btnDoorbellVolumeText); + + btnDoorbellVolumeText.MouseUpEventHandler = (sender, e) => + { + LoadEditDialog(StringId.DoorbellVolume, doorbelVol, btnDoorbellVolumeStateText); + + }; + #endregion + + + + + + + + + var waitPage = new Loading(); + bodyView.AddChidren(waitPage); + waitPage.Start(""); + + new System.Threading.Thread(() => { + try + { + var pack = ApiUtlis.Ins.HttpRequest.GetDoorLockSystemSound(device.deviceId); + if (pack != null && pack.Code == StateCode.SUCCESS) + { + Application.RunOnMainThread(() => + { + //鏇存柊鐣岄潰 + var 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; + } + } + }); + } + 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); + } + }); + } + + + pack = ApiUtlis.Ins.HttpRequest.GetDoorBellTone(device.deviceId); + if (pack != null && pack.Code == StateCode.SUCCESS) + { + Application.RunOnMainThread(() => + { + //鏇存柊鐣岄潰 + var doorbellTone = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorBellTone>(pack.Data.ToString()); + if (doorbellTone != null) + { + 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; + } + } + }); + } + 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($"UnlockSettingPage error : {ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => + { + waitPage.Hide(); + }); + } + + }) + { IsBackground = true }.Start(); + + + + } + + + + /// <summary> + /// 鍔犺浇鍔熻兘灞炴�ф暟鎹�夋嫨寮圭獥 + /// </summary> + void LoadEditDialog(int titleId, int index, Button btn) + { + Button lastButton = new Button(); + var lastData = ""; + var lastText = ""; + Dialog dialog = new Dialog(); + + var pView = new FrameLayout() + { + BackgroundColor = CSS_Color.DialogTransparentColor1, + }; + dialog.AddChidren(pView); + + var optionBaseView = new FrameLayout() + { + Y = Application.GetRealHeight(579 - 50 * 4), + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(50 * 4 + 50), + AnimateSpeed = 0.3f, + Animate = Animate.DownToUp, + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealWidth(12), + }; + pView.AddChidren(optionBaseView); + + var topView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(343), + Height = Application.GetRealHeight(50), + BackgroundColor = CSS_Color.MainBackgroundColor, + Radius = (uint)Application.GetRealWidth(12), + }; + optionBaseView.AddChidren(topView); + + var btnTitle = new Button() + { + Gravity = Gravity.CenterHorizontal, + TextAlignment = TextAlignment.Center, + Width = Application.GetRealWidth(100), + TextID = titleId, + IsBold = true, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.SubheadingFontSize, + }; + topView.AddChidren(btnTitle); + + var btnCancel = new Button() + { + X = Application.GetRealWidth(21), + Width = Application.GetRealWidth(100), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.PromptingColor1, + TextSize = CSS_FontSize.TextFontSize, + TextID = StringId.Cancel, + }; + topView.AddChidren(btnCancel); + + var btnConfrim = new Button() + { + 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; + var statusList = new List<string> + { + Language.StringByID(StringId.High), + Language.StringByID(StringId.Moderate), + Language.StringByID(StringId.Low), + Language.StringByID(StringId.Mute), + }; + + foreach (var m in statusList) + { + var row = new FrameLayout() + { + Y = Application.GetRealHeight(50 * hei), + Height = Application.GetRealHeight(50), + }; + optionBaseView.AddChidren(row); + if (statusList.Count > hei) + { + optionBaseView.AddChidren(new Button() + { + Gravity = Gravity.CenterHorizontal, + Y = row.Bottom, + Width = Application.GetRealWidth(343), + BackgroundColor = CSS_Color.DividingLineColor, + Height = 1, + }); + } + + var btnChoose = new Button() + { + X = Application.GetRealWidth(303), + Gravity = Gravity.CenterVertical, + Width = Application.GetMinRealAverage(28), + Height = Application.GetMinRealAverage(28), + UnSelectedImagePath = "Public/ChooseIcon.png", + SelectedImagePath = "Public/ChooseOnIcon.png", + + }; + row.AddChidren(btnChoose); + if (index == hei - 1) + { + lastButton = btnChoose; + btnChoose.IsSelected = true; + } + var btnPropertyTitle = new Button() + { + X = Application.GetRealWidth(16), + TextAlignment = TextAlignment.CenterLeft, + TextColor = CSS_Color.FirstLevelTitleColor, + TextSize = CSS_FontSize.TextFontSize, + Tag = hei-1, + Text = m + }; + row.AddChidren(btnPropertyTitle); + + btnPropertyTitle.MouseUpEventHandler = (sender, e) => { + btnChoose.IsSelected = true; + if (lastButton != null) + { + lastButton.IsSelected = false; + } + lastButton = btnChoose; + lastData = btnPropertyTitle.Tag.ToString(); + lastText = btnPropertyTitle.Text; + }; + hei++; + } + + + + + dialog.Show(); + + pView.MouseUpEventHandler = (sender, e) => { + dialog.Close(); + }; + + btnCancel.MouseUpEventHandler = (sender, e) => { + dialog.Close(); + }; + btnConfrim.MouseUpEventHandler = (sender, e) => { + dialog.Close(); + 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(); + + + + } + }; + + } + + + + + + } + + /// <summary> + /// 闂ㄩ攣绯荤粺澹伴煶 + /// </summary> + public class DoorLockSystemSound + { + /// <summary> + /// 澹伴煶 + /// 0-闈欓煶 1-浣庨煶 2-涓煶 3-楂橀煶 4-鑷姩 + /// </summary> + public int sound = 0; + } + /// <summary> + /// 闂ㄩ搩鎻愮ず闊抽噺 + /// </summary> + public class DoorBellTone + { + /// <summary> + /// 闊抽噺 鑼冨洿0-100 + /// </summary> + public int volume = 0; + } + + + +} -- Gitblit v1.8.0