From bd46c57c77c276014db3192a4e2cc96e23c93202 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 21 二月 2020 13:08:47 +0800 Subject: [PATCH] 先上传个版本吧 --- ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs | 256 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 177 insertions(+), 79 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs index 4044118..da5c1cc 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/DoorLock/UserDoorLockPage.cs @@ -6,19 +6,45 @@ { public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus { - public UserDoorLockPage(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj) + /// <summary> + /// 鏋勯�犲嚱鏁� + /// </summary> + /// <param name="room"></param> + /// <param name="doorLock"></param> + public UserDoorLockPage(Shared.Common.Room room, DeviceUI doorLock) { - this.doorLock = doorLock; - //currentRoom = room;Shared.Common.Room room, + this.doorLock = doorLock.CommonDevice as ZigBee.Device.DoorLock; + currentRoom = room; + deviceUI = doorLock; BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; ZigBee.Device.ZbGateway.StatusList.Add(this); } - #region 鈼� 鍙橀噺鐢虫槑__________________________ + #region 鍙橀噺鐢虫槑 + /// <summary> + /// 褰撳墠闂ㄩ攣 + /// </summary> ZigBee.Device.DoorLock doorLock; + /// <summary> + /// 搴曢儴甯冨眬 + /// </summary> FrameLayout bottomFrameLayout; + /// <summary> + /// 褰撳墠鎴块棿 + /// </summary> Shared.Common.Room currentRoom; + /// <summary> + /// 璁惧UI瀵硅薄 + /// </summary> + DeviceUI deviceUI; + /// <summary> + /// 璁剧疆浜屾楠岃瘉Action + /// </summary> Action action; + /// <summary> + /// 涓儴甯冨眬涓棬閿佸悕绉版樉绀� + /// </summary> + Button btnDoorLockTitle; #endregion /// <summary> @@ -26,62 +52,64 @@ /// </summary> public void Show() { - this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLock)); - + this.TopFrameLayout(this, ""); EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => { RemoveFromParent(); }; this.btnBack.MouseUpEventHandler += eHandlerBack; this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; - this.MidFrameLayout(this); + this.MidFrameLayout(this); var btnShare = new Button { X = Application.GetRealWidth(850 - 116), Height = Application.GetRealHeight(69), - Width = Application.GetRealWidth(69), + Width = Application.GetRealWidth(0), }; this.titleFrameLayout.AddChidren(btnShare); + var btnFuncSetFrameLayout = new FrameLayout + { + X = Application.GetRealWidth(850 - 116), + Height = Application.GetRealHeight(69), + Width = Application.GetRealWidth(69 * 2 + 58), + }; + this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout); + var btnFuncSet = new Button { - X = Application.GetRealWidth(953 - 116), + X = Application.GetRealWidth(103), Height = Application.GetRealHeight(69), Width = Application.GetRealWidth(69), UnSelectedImagePath = "DoorLock/SettingIcon.png", }; - this.titleFrameLayout.AddChidren(btnFuncSet); - btnFuncSet.MouseDownEventHandler += (sender, e) => + btnFuncSetFrameLayout.AddChidren(btnFuncSet); + EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) => { - if (UserCenterResourse.UserInfo.AuthorityNo == 1) - { - var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock); - Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage); - Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - userDoorLockPage.Show(); - } - else - { - var userDoorLockPage = new Shared.Phone.UserCenter.DoorLock.FunctionSettingSub(doorLock); - Shared.Phone.UserView.HomePage.Instance.AddChidren(userDoorLockPage); - Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - userDoorLockPage.Show(); - } - }; - - btnShare.MouseDownEventHandler += (sender, e) => - { - var doorLock = new ZigBee.Device.DoorLock(); - var memberManagement = new Shared.Phone.UserCenter.DoorLock.MemberManagement(doorLock); - Shared.Phone.UserView.HomePage.Instance.AddChidren(memberManagement); + var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(doorLock); + Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting); Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - memberManagement.Show(); + functionSetting.Show(); + functionSetting.devicNameAction += (deviceRename) => + { + if (!string.IsNullOrEmpty(deviceRename)) + { + btnDoorLockTitle.Text = deviceRename; + //鏀规埧闂� + Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); + deviceUI.CommonDevice.ReSave(); + } + }; }; - + btnFuncSetFrameLayout.MouseDownEventHandler += btnFuncSetHander; + btnFuncSet.MouseDownEventHandler += btnFuncSetHander; + MidFrameLayoutContent(); } - + /// <summary> + /// 涓儴甯冨眬 + /// </summary> public void MidFrameLayoutContent() { #region UI @@ -92,63 +120,91 @@ Height = Application.GetRealHeight(1238), Width = Application.GetRealWidth(965), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, + Radius = 6, }; this.midFrameLayout.AddChidren(midTopFrameLayout); - var btnDoorLockTitle = new Button() + btnDoorLockTitle = new Button() { Width = Application.GetRealWidth(250), Height = Application.GetRealHeight(60), X = Application.GetRealWidth(372), Y = Application.GetRealHeight(46), - TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, - Text = Language.StringByID(R.MyInternationalizationString.SmartDoorLock), + TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextSize = 15, TextAlignment = TextAlignment.Center, + IsBold = true, }; midTopFrameLayout.AddChidren(btnDoorLockTitle); + //鑾峰彇Mac鍚嶅瓧 + btnDoorLockTitle.Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock); + + var btnRecordFrameLayout = new FrameLayout() + { + Width = Application.GetRealWidth(69+15+46), + Height = Application.GetRealHeight(69+46 * 2), + X = Application.GetRealWidth(752-46), + }; + midTopFrameLayout.AddChidren(btnRecordFrameLayout); var btnRecord = new Button() { Width = Application.GetRealWidth(69), Height = Application.GetRealHeight(69), - X = Application.GetRealWidth(752), + X = Application.GetRealWidth(46), Y = Application.GetRealHeight(46), UnSelectedImagePath = "DoorLock/RecordIcon.png", }; - midTopFrameLayout.AddChidren(btnRecord); - btnRecord.MouseDownEventHandler += (sender, e) => + btnRecordFrameLayout.AddChidren(btnRecord); + EventHandler<MouseEventArgs> handerRecord = (sender, e) => { - var doorLock = new ZigBee.Device.DoorLock(); - var doorLockRecord = new Shared.Phone.UserCenter.DoorLock.HistoryRecordPage(doorLock); - Shared.Phone.UserView.HomePage.Instance.AddChidren(doorLockRecord); - Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; - doorLockRecord.Show(); + //鍘嗗彶璁板綍 ---- stan + var form = new DeviceDoorLock.DoorLockHistoryLogForm(); + form.AddForm(this.doorLock.DeviceAddr); }; + btnRecordFrameLayout.MouseDownEventHandler += handerRecord; + btnRecord.MouseDownEventHandler += handerRecord; + var btnCollectFrameLayout = new FrameLayout() + { + Width = Application.GetRealWidth(69+15+46), + Height = Application.GetRealHeight(69+46*2), + X = Application.GetRealWidth(850-15), + }; + midTopFrameLayout.AddChidren(btnCollectFrameLayout); var btnCollect = new Button() { Width = Application.GetRealWidth(69), Height = Application.GetRealHeight(69), - X = Application.GetRealWidth(850), + X = Application.GetRealWidth(15), Y = Application.GetRealHeight(46), UnSelectedImagePath = "Item/Collection.png", SelectedImagePath = "Item/CollectionSelected.png" }; - midTopFrameLayout.AddChidren(btnCollect); - btnCollect.MouseDownEventHandler += (sender, e) => + btnCollectFrameLayout.AddChidren(btnCollect); + var de = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == deviceUI.FileName); + if (de == null) + { + btnCollect.IsSelected = false; + } + else + { + btnCollect.IsSelected = true; + } + EventHandler < MouseEventArgs > handerCollect = (sender, e) => { btnCollect.IsSelected = !btnCollect.IsSelected; if (btnCollect.IsSelected) { - // Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(doorLock.FileName); //鍙栨秷鏀惰棌 + Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(deviceUI.FileName);//鏀惰棌 } else - { - //Shared.Common.Room.CurrentRoom.GetLoveRoom().AddDevice(doorLock.FileName);//鏀惰棌 + { + Shared.Common.Room.CurrentRoom.GetLoveRoom().DeleteDevice(deviceUI.FileName); //鍙栨秷鏀惰棌 } }; - + btnCollectFrameLayout.MouseDownEventHandler += handerCollect; + btnCollect.MouseDownEventHandler += handerCollect; var btnCurrentText = new Button() { Width = Application.GetRealWidth(100), @@ -188,7 +244,7 @@ var btnFrameLayout = new FrameLayout() { - Width = Application.GetRealWidth(420 - 46),//639-35 + Width = Application.GetRealWidth(420 - 46), Height = Application.GetRealHeight(446), X = btnDoorLockPic.Right, Y = Application.GetRealHeight(354), @@ -254,12 +310,22 @@ }; closeFrameLayout.AddChidren(btnDoorClosePic); + var btnCurrentTopFrameLayout = new FrameLayout() + { + Height = Application.GetRealHeight(50), + Width = Application.GetRealWidth(965), + BackgroundColor = ZigbeeColor.Current.XMBlack, + Y = Application.GetRealHeight(1100), + }; + midTopFrameLayout.AddChidren(btnCurrentTopFrameLayout); + var btnCurrentFrameLayout = new FrameLayout() { Width = Application.GetRealWidth(965), Height = Application.GetRealHeight(138), Y = Application.GetRealHeight(1100), BackgroundColor = ZigbeeColor.Current.XMBlack, + Radius = 6, }; midTopFrameLayout.AddChidren(btnCurrentFrameLayout); @@ -279,7 +345,7 @@ Height = Application.GetRealHeight(49), X = Application.GetRealWidth(150), Y = Application.GetRealHeight(46), - // Text = currentRoom.Name, + Text = currentRoom.Name, TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, TextSize = 12, TextAlignment = TextAlignment.CenterLeft, @@ -287,33 +353,64 @@ btnCurrentFrameLayout.AddChidren(btnCurrentRoomName); #endregion + #region 鏁版嵁澶勭悊 EventHandler<MouseEventArgs> hander1 = async (sender, e) => - { - if (UserCenterResourse.UserInfo.AuthorityNo != 1) - { - var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); - if (result == false) + { + openFrameLayout.Enable = false; + btnDoorOpenPic.Enable = false; + 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) + { + RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle); + devicNameSecAction += (deviceRename) => + { + if (!string.IsNullOrEmpty(deviceRename)) + { + btnDoorLockTitle.Text = deviceRename; + //鏀规埧闂� + Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); + deviceUI.CommonDevice.ReSave(); + } + }; + openFrameLayout.Enable = true; + btnDoorOpenPic.Enable = true; + } + else + { + this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess)); + openFrameLayout.Enable = true; + btnDoorOpenPic.Enable = true; + } + } + else + { + this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed)); + openFrameLayout.Enable = true; + btnDoorOpenPic.Enable = true; + } + } + else + { + RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle); + devicNameSecAction += (deviceRename) => { - var result1 = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid); - if (result1 == true) + if (!string.IsNullOrEmpty(deviceRename)) { - RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus); + btnDoorLockTitle.Text = deviceRename; + //鏀规埧闂� + Shared.Common.Room.CurrentRoom.ChangedRoom(deviceUI.CommonDevice, currentRoom.Id); + deviceUI.CommonDevice.ReSave(); } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.NoAccess), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); - } - } - else - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); - } - } - else - { - RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus); - } - }; + }; + openFrameLayout.Enable = true; + btnDoorOpenPic.Enable = true; + } + }; openFrameLayout.MouseUpEventHandler += hander1; btnDoorOpenPic.MouseUpEventHandler += hander1; EventHandler<MouseEventArgs> hander2 = (sender, e) => @@ -323,9 +420,10 @@ }; closeFrameLayout.MouseUpEventHandler += hander2; btnDoorClosePic.MouseUpEventHandler += hander2; + #endregion } - #region 鈼� 鎺ュ彛瀹炵幇__________________________ + #region 鎺ュ彛瀹炵幇 /// <summary> /// 澶勭悊鍙樺寲浜嬩欢 --灏嗗純鐢� 鏀圭敤DeviceInfoChange() /// </summary> -- Gitblit v1.8.0