From 944b87b6bcccb095cd73f13f4410fb20faf48f74 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期三, 25 十二月 2019 11:21:06 +0800 Subject: [PATCH] 2019.12.25 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs | 277 +++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 207 insertions(+), 70 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs index 7e1b6b2..0fbe09b 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs @@ -20,6 +20,27 @@ #region 鈼� 鍙橀噺鐢虫槑__________________________ ZigBee.Device.DoorLock doorLock; + /// <summary> + /// 璁惧闇�瑕佷繚瀛樼殑璁惧鍚嶅瓧 + /// </summary> + private Dictionary<int, string> dicDeviceSaveName = new Dictionary<int, string>(); + /// <summary> + /// 褰撳墠閫夋嫨鐨勮澶� + /// </summary> + private CommonDevice nowSelectDevice = null; + /// <summary> + /// 璁惧澶囨敞鐨勬帶浠� + /// </summary> + private FrameCaptionInputControl btnDeviceName = null; + /// <summary> + /// 璁惧鐨勬煇涓�鍥炶矾 + /// </summary> + private CommonDevice deviceObj = null; + Action action; + Action actionNone; + string modifyDeviceName = ""; + bool IsModifyName = true; + public Action<string> devicNameAction; #endregion /// <summary> @@ -27,7 +48,7 @@ /// </summary> public void Show() { - this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.FunctionSetting)); + this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLockFunctionSetting)); EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => { @@ -43,7 +64,6 @@ public void MidFrameLayoutContent() { - var MidTopFrameLayout = new FrameLayout() { X = Application.GetRealWidth(449), @@ -78,7 +98,7 @@ var bottomFrameLayout2 = new FrameLayout() { - Height = Application.GetRealHeight(1319), + Height = Application.GetRealHeight(1000), Y = Application.GetRealHeight(418), }; this.midFrameLayout.AddChidren(bottomFrameLayout2); @@ -91,11 +111,11 @@ Text = Language.StringByID(R.MyInternationalizationString.InformationEdit), TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, + TextSize = 15, }; bottomFrameLayout2.AddChidren(informationEdit); - for (int i = 0; i < 7; i++) + for (int i = 0; i < 6; i++) { var bottomRowLayout = new FrameLayout() { @@ -108,9 +128,9 @@ Width = Application.GetRealWidth(233), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(58), - TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, + TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, TextAlignment = TextAlignment.CenterLeft, - TextSize = 12, + TextSize = 14, }; bottomRowLayout.AddChidren(btnName); @@ -133,7 +153,7 @@ var btnLine = new FrameLayout() { Width = Application.GetRealWidth(965), - Height = Application.GetRealHeight(2), + Height = 1, X = Application.GetRealWidth(58), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, Visible = false, @@ -143,14 +163,57 @@ if (i == 0) { bottomRowLayout.Y = Application.GetRealHeight(220); - btnName.Text = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm) + ":"; + 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; + var btnDeviceNameEditText = new EditText() + { + X = Application.GetRealWidth(46), + Width = Application.GetRealWidth(731), + Height = Application.GetRealHeight(58), + TextColor = ZigbeeColor.Current.XMGray3, + 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) { @@ -208,7 +271,7 @@ btnNext.SelectedImagePath = "DoorLock/SwitchOn.png"; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(853); - if (ZigBee.Device.DoorLock.RemoteUnlockPassword == "") + if (doorLock.RemoteUnlockPassword == "") { btnNext.IsSelected = false; } @@ -223,73 +286,147 @@ btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockTime); btnNextFrameLayout.Y = btnName.Y; btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png"; - btnLine.Visible = true; + btnLine.Visible = false; 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 = (sender, e) => - { - if (currentIndex == 1) - { - //鑾峰彇璁惧鎵�灞炴埧闂� - 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 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 if (currentIndex == 4) - { - btnNext.IsSelected = !btnNext.IsSelected; - if (btnNext.IsSelected) - { - if (ZigBee.Device.DoorLock.RemoteUnlockPassword == "") - { - RemotePasswordDialog(doorLock, btnNext); - } - } - else - { - ZigBee.Device.DoorLock.RemoteUnlockPassword = ""; - } - } - else if (currentIndex == 5) - { - var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime"); - Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage); - Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - tempPage.Show(); - } - else if (currentIndex == 6) - { - } - }; + EventHandler<MouseEventArgs> eHandler = async (sender, e) => + { + if (currentIndex == 3) + { + 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(); + }; + actionNone = async () => + { + Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action); + }; + HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone); + } + else if (currentIndex == 4) + { + if (UserCenterResourse.UserInfo.AuthorityNo != 1) + { + var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); + if (result == false) + { + var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid); + if (result1 == true) + { + btnNext.IsSelected = !btnNext.IsSelected; + if (btnNext.IsSelected) + { + if (doorLock.RemoteUnlockPassword == "") + { + RemotePasswordDialog(doorLock, btnNext); + } + } + else + { + doorLock.RemoteUnlockPassword = ""; + } + } + else + { + 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.None, CloseTime = 1 }.Show(Common.CommonPage.Instance); + } + } + else + { + btnNext.IsSelected = !btnNext.IsSelected; + if (btnNext.IsSelected) + { + if (doorLock.RemoteUnlockPassword == "") + { + RemotePasswordDialog(doorLock, btnNext); + } + } + else + { + doorLock.RemoteUnlockPassword = ""; + } + } + } + else if (currentIndex == 5) + { + var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); + if (result == false) + { + var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime"); + Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage); + Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; + tempPage.Show(); + } + else + { + 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; #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); + 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