From fa6bcb2e9907772480f99205f36ec2a1ce735a22 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 09 一月 2020 14:11:07 +0800 Subject: [PATCH] 合并代码 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs | 273 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 158 insertions(+), 115 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs index ecffb1c..49c6b4d 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs @@ -36,6 +36,11 @@ /// 璁惧鐨勬煇涓�鍥炶矾 /// </summary> private CommonDevice deviceObj = null; + Action action; + Action actionNone; + string modifyDeviceName = ""; + bool IsModifyName = true; + public Action<string> devicNameAction; #endregion /// <summary> @@ -59,7 +64,6 @@ public void MidFrameLayoutContent() { - var MidTopFrameLayout = new FrameLayout() { X = Application.GetRealWidth(449), @@ -69,35 +73,49 @@ BackgroundImagePath = "DoorLock/DoorlockPicture.png", }; this.midFrameLayout.AddChidren(MidTopFrameLayout); + + var btnDeviceText = new Button() + { + Y = Application.GetRealHeight(288), + Height = Application.GetRealHeight(60), + Gravity = Gravity.CenterHorizontal, + TextColor = ZigbeeColor.Current.XMBlack, + TextSize = 15, + Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock), + }; + this.midFrameLayout.AddChidren(btnDeviceText); + BottomFrameLayout(); } public void BottomFrameLayout() { #region UI + //var bottomFrameLayout = new FrameLayout() + //{ + // Height = Application.GetRealHeight(100), + // Y = Application.GetRealHeight(418), + // Radius = 17, + // BackgroundColor = ZigbeeColor.Current.XMWhite, + //}; + //this.midFrameLayout.AddChidren(bottomFrameLayout); + + //var bottomFrameLayout1 = new FrameLayout() + //{ + // Height = Application.GetRealHeight(1319 - 50), + // Y = Application.GetRealHeight(418 + 48), + // BackgroundColor = ZigbeeColor.Current.XMWhite, + //}; + //this.midFrameLayout.AddChidren(bottomFrameLayout1); + var bottomFrameLayout = new FrameLayout() { - Height = Application.GetRealHeight(100), + Height = Application.GetRealHeight(1319), Y = Application.GetRealHeight(418), - Radius = 17, BackgroundColor = ZigbeeColor.Current.XMWhite, }; this.midFrameLayout.AddChidren(bottomFrameLayout); - - var bottomFrameLayout1 = new FrameLayout() - { - Height = Application.GetRealHeight(1319 - 50), - Y = Application.GetRealHeight(418 + 48), - BackgroundColor = ZigbeeColor.Current.XMWhite, - }; - this.midFrameLayout.AddChidren(bottomFrameLayout1); - - var bottomFrameLayout2 = new FrameLayout() - { - Height = Application.GetRealHeight(1054), - Y = Application.GetRealHeight(418), - }; - this.midFrameLayout.AddChidren(bottomFrameLayout2); + bottomFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); var informationEdit = new Button() { @@ -109,7 +127,7 @@ TextAlignment = TextAlignment.CenterLeft, TextSize = 15, }; - bottomFrameLayout2.AddChidren(informationEdit); + bottomFrameLayout.AddChidren(informationEdit); for (int i = 0; i < 6; i++) { @@ -117,7 +135,7 @@ { Height = Application.GetRealHeight(58), }; - bottomFrameLayout2.AddChidren(bottomRowLayout); + bottomFrameLayout.AddChidren(bottomRowLayout); var btnName = new Button() { @@ -154,19 +172,62 @@ BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, Visible = false, }; - bottomFrameLayout2.AddChidren(btnLine); + bottomFrameLayout.AddChidren(btnLine); if (i == 0) { bottomRowLayout.Y = Application.GetRealHeight(220); btnName.Text = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm) + ":"; - btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58); - btnNextFrameLayout.X = Application.GetRealWidth(233); - btnNext.TextAlignment = TextAlignment.CenterLeft; - btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; - btnNext.Text = doorLock.DeviceName; + btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58 - 20); + btnNextFrameLayout.X = Application.GetRealWidth(233 + 20); + var btnDeviceNameEditText = new EditText() + { + X = Application.GetRealWidth(46), + Width = Application.GetRealWidth(731), + Height = Application.GetRealHeight(58), + TextColor = ZigbeeColor.Current.XMGray3, + TextSize = 14, + PlaceholderTextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor2, + TextAlignment = TextAlignment.CenterLeft, + Text = string.IsNullOrEmpty(doorLock.DeviceName) ? Language.StringByID(R.MyInternationalizationString.UNKnown) : doorLock.DeviceName, + }; + btnNextFrameLayout.AddChidren(btnDeviceNameEditText); + + btnDeviceNameEditText.TextChangeEventHandler += (sender, e) => + { + modifyDeviceName = btnDeviceNameEditText.Text; + }; + Action<Shared.View> actionEdit = async (obj) => + { + try + { + Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); }); + var doorLockDeviceList = new List<CommonDevice> { }; + doorLockDeviceList.Add(doorLock); + var result = await Common.LocalDevice.Current.ReMacName(doorLockDeviceList, btnDeviceNameEditText.Text); + if (result) + { + IsModifyName = false; + } + else + { + IsModifyName = true; + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Hide(); + }); + } + }; + btnDeviceNameEditText.EditorEnterAction += actionEdit; + btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(303); + } else if (i == 1) { @@ -192,14 +253,13 @@ { bottomRowLayout.Y = Application.GetRealHeight(481); btnName.Text = Language.StringByID(R.MyInternationalizationString.BelongModel) + ":"; - btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58); - btnNextFrameLayout.X = Application.GetRealWidth(233); - + btnNextFrameLayout.Width = btnNext.Width = Application.GetRealWidth(789 - 58 - 20); + btnNextFrameLayout.X = Application.GetRealWidth(253); btnNext.TextAlignment = TextAlignment.CenterLeft; btnNext.Height = Application.GetRealHeight(58); btnNext.Text = doorLock.DeviceName; btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; - + btnNext.TextSize = 14; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(575); } @@ -224,7 +284,7 @@ btnNext.SelectedImagePath = "DoorLock/SwitchOn.png"; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(853); - if (doorLock.RemoteUnlockPassword == "") + if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword)) { btnNext.IsSelected = false; } @@ -239,49 +299,26 @@ btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockTime); btnNextFrameLayout.Y = btnName.Y; btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png"; - btnLine.Visible = false; + btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(992); } - //else if (i == 6) - //{ - // bottomRowLayout.Y = Application.GetRealHeight(999 + 35); - // btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockShare); - // btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png"; - // btnLine.Visible = true; - // btnLine.Y = Application.GetRealHeight(1131); - //} int currentIndex = i; EventHandler<MouseEventArgs> eHandler = async (sender, e) => { - if (currentIndex == 1) + if (currentIndex == 3) { - //鑾峰彇璁惧鎵�灞炴埧闂� - var aa = Common.Room.CurrentRoom.GetRoomByDevice(doorLock); - //鑾峰彇璁惧鎵�鍦ㄦゼ灞� - var bb = aa.FloorId; - //鑾峰彇璁惧鎵�鍦ㄦゼ灞� - var cc = aa.FloorId; - //鑾峰彇妤煎眰鐨勫悕瀛� - var dd = Common.Config.Instance.Home.GetFloorNameById(cc); - //if (Common.Config.Instance.Home.FloorDics.Count == 0)//杩欎釜鏄棤妤煎眰妯″紡 - - var listCheck = new List<string>(); - } - else if (currentIndex == 3) - { - var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); - if (result == false) + action = async () => { var temporaryPassword = new Shared.Phone.UserCenter.DoorLock.TemporaryPassword(doorLock); Shared.Phone.UserView.HomePage.Instance.AddChidren(temporaryPassword); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; temporaryPassword.Show(); - } - else + }; + actionNone = async () => { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); - } - + Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action); + }; + HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone); } else if (currentIndex == 4) { @@ -296,7 +333,7 @@ btnNext.IsSelected = !btnNext.IsSelected; if (btnNext.IsSelected) { - if (doorLock.RemoteUnlockPassword == "") + if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword)) { RemotePasswordDialog(doorLock, btnNext); } @@ -308,12 +345,12 @@ } else { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); } } else { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); } } else @@ -321,7 +358,7 @@ btnNext.IsSelected = !btnNext.IsSelected; if (btnNext.IsSelected) { - if (doorLock.RemoteUnlockPassword == "") + if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword)) { RemotePasswordDialog(doorLock, btnNext); } @@ -344,63 +381,69 @@ } else { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); + new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); } } }; - bottomRowLayout.MouseDownEventHandler += eHandler; btnNext.MouseDownEventHandler += eHandler; - btnName.MouseDownEventHandler += eHandler; - btnNextFrameLayout.MouseDownEventHandler += eHandler; + if (i != 4) + { + bottomRowLayout.MouseDownEventHandler += eHandler; + btnName.MouseDownEventHandler += eHandler; + btnNextFrameLayout.MouseDownEventHandler += eHandler; + } #endregion } //淇濆瓨 - //var btnFinifh = new Button() - //{ - // Width = Application.GetRealWidth(907), - // Height = Application.GetRealHeight(127), - // Y = Application.GetRealHeight(1472), - // Gravity = Gravity.CenterHorizontal, - // Radius = (uint)Application.GetRealHeight(127) / 2, - // TextID = R.MyInternationalizationString.Save, - // BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack, - // TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, - // TextSize = 16, - //}; - //this.midFrameLayout.AddChidren(btnFinifh); - //btnFinish.MouseUpEventHandler += async (sender, e) => - //{ - // //璁板綍璧峰綋鍓嶆鍦ㄦ搷浣滅殑鍥炶矾鍚嶅瓧 - // dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim(); - // //寮�鍚繘搴︽潯 - // this.ShowProgressBar(); - // foreach (var epoint in dicDeviceSaveName.Keys) - // { - // var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint); - // if (device == null || dicDeviceSaveName[epoint] == string.Empty) - // { - // //涓嶈兘鍏佽绌虹櫧鍚嶅瓧 - // continue; - // } - // string newName = dicDeviceSaveName[epoint]; - // string oldName = Common.LocalDevice.Current.GetDeviceEpointName(device); - // if (oldName != newName) - // { - // //璁惧鍚嶇О淇敼 - // var result = await Common.LocalDevice.Current.ReName(device, newName); - // if (result == false) - // { - // //鍏抽棴 - // this.CloseProgressBar(); - // return; - // } - // } - // } - // this.CloseProgressBar(); - // //鍏抽棴鑷韩 - // this.CloseForm(); - //}; + var btnFinifh = new Button() + { + Width = Application.GetRealWidth(907), + Height = Application.GetRealHeight(127), + Y = Application.GetRealHeight(1472), + Gravity = Gravity.CenterHorizontal, + Radius = (uint)Application.GetRealHeight(127) / 2, + TextID = R.MyInternationalizationString.Save, + BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack, + TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, + TextSize = 16, + IsBold = true, + }; + this.midFrameLayout.AddChidren(btnFinifh); + btnFinifh.MouseUpEventHandler += (sender, e) => + { + System.Threading.Tasks.Task.Run(async () => + { + Application.RunOnMainThread(() => { CommonPage.Loading.Start("Loading..."); }); + try + { + if (IsModifyName) + { + var doorLockDeviceList = new List<CommonDevice> { }; + doorLockDeviceList.Add(doorLock); + var result = await Common.LocalDevice.Current.ReMacName(doorLockDeviceList, modifyDeviceName); + if (result) + { + if (devicNameAction != null) + { + devicNameAction(modifyDeviceName); + } + } + } + } + catch (Exception ex) + { + var mess = ex.Message; + } + finally + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Hide(); + }); + } + }); + }; } #region 鈼� 鎺ュ彛瀹炵幇__________________________ -- Gitblit v1.8.0