| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text.RegularExpressions; |
| | | using Shared.Common; |
| | | using ZigBee.Device; |
| | | |
| | |
| | | { |
| | | public class UserDoorLockPage : DoorLockCommonLayout, ZigBee.Common.IStatus |
| | | { |
| | | public UserDoorLockPage(ZigBee.Device.DoorLock doorLock, Shared.Phone.UserCenter.MemberInfoRes accountObj) |
| | | #region 界面 |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="room"></param> |
| | | /// <param name="doorLock"></param> |
| | | public UserDoorLockPage(Room room, CommonDevice doorLock) |
| | | { |
| | | this.doorLock = doorLock; |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; |
| | | ZigBee.Device.ZbGateway.StatusList.Add(this); |
| | | //徐梅的门锁界面打开(网关全局接收时使用) |
| | | //ControlCommonResourse.IsDoorLockPageOpen = true; |
| | | this.doorLock = doorLock as ZigBee.Device.DoorLock; |
| | | currentRoom = room; |
| | | deviceUI = doorLock; |
| | | BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor; |
| | | ZbGateway.StatusList.Add(this); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction += (DoorlockKey, status) => |
| | | { |
| | | var key = doorLock.DeviceAddr; |
| | | if (DoorlockKey == key) |
| | | { |
| | | DoorLockCommonInfo.NormallyOpenModeValue(this.doorLock, status); |
| | | UpdateNomallyOpenStatus(); |
| | | } |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | #region ◆ 变量申明__________________________ |
| | | #region 变量申明 |
| | | /// <summary> |
| | | /// 当前门锁 |
| | | /// </summary> |
| | | ZigBee.Device.DoorLock doorLock; |
| | | FrameLayout bottomFrameLayout; |
| | | /// <summary> |
| | | /// 音量数据 |
| | | /// </summary> |
| | | ZigBee.Device.DoorLock.VolumeResponseData volumeData = null; |
| | | /// <summary> |
| | | /// 等待获取电量的等待时间 |
| | | /// </summary> |
| | | DateTime waitGetDoorLockPower = DateTime.MaxValue; |
| | | /// <summary> |
| | | /// 逻辑中是否有常开模式 |
| | | /// </summary> |
| | | private bool haveLogicNormallyOpenMode = false; |
| | | |
| | | /// <summary> |
| | | /// 当前电量 |
| | | /// </summary> |
| | | bool canVolume = false; |
| | | /// <summary> |
| | | /// 是否支持常开 |
| | | /// </summary> |
| | | bool canOpenNormallyMode = false; |
| | | /// <summary> |
| | | /// IsDrawerLockMode[主页左滑] |
| | | /// </summary> |
| | | public bool IsDrawerLockMode; |
| | | /// <summary> |
| | | /// 当前电量 |
| | | /// </summary> |
| | | int currentPower = 0; |
| | | /// <summary> |
| | | /// 保留上一次音量 |
| | | /// </summary> |
| | | int oldVolume = -1; |
| | | /// <summary> |
| | | /// 当前房间 |
| | | /// </summary> |
| | | Room currentRoom; |
| | | /// <summary> |
| | | /// 设备UI对象 |
| | | /// </summary> |
| | | CommonDevice deviceUI; |
| | | /// <summary> |
| | | /// 设置二次验证Action |
| | | /// </summary> |
| | | Action action; |
| | | /// <summary> |
| | | /// 中部布局中门锁名称显示 |
| | | /// </summary> |
| | | NormalViewControl btnDoorLockTitle; |
| | | /// <summary> |
| | | /// 分享 |
| | | /// </summary> |
| | | Button btnShare; |
| | | /// <summary> |
| | | /// 设置 |
| | | /// </summary> |
| | | Button btnFuncSet; |
| | | /// <summary> |
| | | /// 设置FrameLayout |
| | | /// </summary> |
| | | FrameLayout btnFuncSetFrameLayout; |
| | | FrameLayout progressFrameLayoutMatch; |
| | | /// <summary> |
| | | /// 点击开布局 |
| | | /// </summary> |
| | | private FrameLayout openFrameLayout; |
| | | /// <summary> |
| | | /// 点击关布局 |
| | | /// </summary> |
| | | private FrameLayout closeFrameLayout; |
| | | /// <summary> |
| | | /// 打开图片 |
| | | /// </summary> |
| | | Button btnDoorOpenPic; |
| | | /// <summary> |
| | | /// 搜藏UI |
| | | /// </summary> |
| | | FrameLayout btnCollectFrameLayout; |
| | | /// <summary> |
| | | /// 搜藏 |
| | | /// </summary> |
| | | Button btnCollect; |
| | | /// <summary> |
| | | /// 记录UI |
| | | /// </summary> |
| | | FrameLayout btnRecordFrameLayout; |
| | | /// <summary> |
| | | /// 记录按钮 |
| | | /// </summary> |
| | | Button btnRecord; |
| | | /// <summary> |
| | | /// 当前状态 |
| | | /// </summary> |
| | | Button btnStatus; |
| | | /// <summary> |
| | | /// 当前电量文本 |
| | | /// </summary> |
| | | Button btnCurrentPowerText; |
| | | /// <summary> |
| | | /// 进度按钮 |
| | | /// </summary> |
| | | Button progressButton; |
| | | /// <summary> |
| | | /// 进度 |
| | | /// </summary> |
| | | DiyImageVerticalSeekBar diyImageVerticalSeekBar; |
| | | /// <summary> |
| | | /// 进度文本 |
| | | /// </summary> |
| | | Button progressText; |
| | | /// <summary> |
| | | /// 门锁关图片 |
| | | /// </summary> |
| | | Button btnDoorClosePic; |
| | | /// <summary> |
| | | /// 门锁开/关图片 |
| | | /// </summary> |
| | | Button btnDoorLockPic; |
| | | /// <summary> |
| | | /// 电量 |
| | | /// </summary> |
| | | Button btnPower; |
| | | /// <summary> |
| | | /// 常开 |
| | | /// </summary> |
| | | Button btnNormallyOpen; |
| | | /// <summary> |
| | | /// 音量 |
| | | /// </summary> |
| | | Button btnVolume; |
| | | /// <summary> |
| | | /// 常开FrameLayout |
| | | /// </summary> |
| | | FrameLayout btnNormallyOpenFrameLayout; |
| | | /// <summary> |
| | | /// 音量FrameLayout |
| | | /// </summary> |
| | | FrameLayout btnVolumeFrameLayout; |
| | | /// <summary> |
| | | /// 当前音量 |
| | | /// </summary> |
| | | int currentVolume = -1; |
| | | /// <summary> |
| | | /// waitClickTime |
| | | /// </summary> |
| | | DateTime waitClickTime = DateTime.MaxValue; |
| | | /// <summary> |
| | | /// IsClick |
| | | /// </summary> |
| | | bool IsClick = true; |
| | | #endregion |
| | | |
| | | /// <summary>
|
| | | /// UI显示 |
| | | /// <summary> |
| | | /// UI显示 |
| | | /// </summary> |
| | | public void Show() |
| | | { |
| | | this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLock)); |
| | | |
| | | EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | this.btnBack.MouseUpEventHandler += eHandlerBack; |
| | | this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; |
| | | this.TopFrameLayout(this, ""); |
| | | this.MidFrameLayout(this); |
| | | |
| | | var btnShare = new Button |
| | | btnShare = new Button |
| | | { |
| | | X = Application.GetRealWidth(850), |
| | | X = Application.GetRealWidth(850 - 116), |
| | | Height = Application.GetRealHeight(69), |
| | | Width = Application.GetRealWidth(69), |
| | | UnSelectedImagePath = "DoorLock/ShareIcon.png", |
| | | Width = Application.GetRealWidth(0), |
| | | }; |
| | | this.titleFrameLayout.AddChidren(btnShare); |
| | | |
| | | var btnFuncSet = new Button |
| | | btnFuncSetFrameLayout = new FrameLayout |
| | | { |
| | | X = Application.GetRealWidth(953), |
| | | X = Application.GetRealWidth(850 - 116), |
| | | Height = Application.GetRealHeight(69), |
| | | Width = Application.GetRealWidth(69), |
| | | Width = Application.GetRealWidth(69 * 2 + 58), |
| | | }; |
| | | this.titleFrameLayout.AddChidren(btnFuncSetFrameLayout); |
| | | |
| | | btnFuncSet = new Button |
| | | { |
| | | X = Application.GetRealWidth(103), |
| | | Height = Application.GetMinReal(69), |
| | | Width = Application.GetMinReal(69), |
| | | UnSelectedImagePath = "DoorLock/SettingIcon.png", |
| | | }; |
| | | this.titleFrameLayout.AddChidren(btnFuncSet); |
| | | btnFuncSet.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3) |
| | | { |
| | | 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(); |
| | | } |
| | | else |
| | | { |
| | | 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(); |
| | | } |
| | | }; |
| | | btnFuncSetFrameLayout.AddChidren(btnFuncSet); |
| | | |
| | | 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); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | memberManagement.Show(); |
| | | }; |
| | | MidFrameLayoutUI(); |
| | | |
| | | MidFrameLayoutContent(); |
| | | ClickHandle(); |
| | | |
| | | if (HdlDeviceCommonLogic.Current.CheckDeviceIsOnline(doorLock) == true) |
| | | { |
| | | ReadDoorLockUserInfo(); |
| | | } |
| | | else |
| | | { |
| | | string msg1 = Language.StringByID(R.MyInternationalizationString.DoorLockOffLine); |
| | | this.ShowTipMsg(msg1); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | public void MidFrameLayoutContent() |
| | | /// <summary> |
| | | /// 中部布局 |
| | | /// </summary> |
| | | public void MidFrameLayoutUI() |
| | | { |
| | | #region UI |
| | | var midTopFrameLayout = new FrameLayout() |
| | | { |
| | | X = Application.GetRealWidth(58), |
| | |
| | | Height = Application.GetRealHeight(1238), |
| | | Width = Application.GetRealWidth(965), |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite, |
| | | Radius = 6, |
| | | }; |
| | | this.midFrameLayout.AddChidren(midTopFrameLayout); |
| | | |
| | | var 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), |
| | | TextSize = 15, |
| | | TextAlignment = TextAlignment.Center, |
| | | }; |
| | | //设备名称 |
| | | btnDoorLockTitle = new NormalViewControl(100, 60, true); |
| | | btnDoorLockTitle.Y = Application.GetRealHeight(46); |
| | | btnDoorLockTitle.TextSize = 15; |
| | | btnDoorLockTitle.IsBold = true; |
| | | btnDoorLockTitle.Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock); |
| | | btnDoorLockTitle.Width = btnDoorLockTitle.GetRealWidthByText(); |
| | | btnDoorLockTitle.TextAlignment = TextAlignment.Center; |
| | | btnDoorLockTitle.Gravity = Gravity.CenterHorizontal; |
| | | midTopFrameLayout.AddChidren(btnDoorLockTitle); |
| | | |
| | | var btnRecord = new Button() |
| | | //记录 |
| | | btnRecordFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(69), |
| | | Height = Application.GetRealHeight(69), |
| | | X = Application.GetRealWidth(752), |
| | | Width = Application.GetRealWidth(69 + 15 + 46), |
| | | Height = Application.GetRealHeight(69 + 46 * 2), |
| | | X = Application.GetRealWidth(752 - 46), |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnRecordFrameLayout); |
| | | btnRecord = new Button() |
| | | { |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | X = Application.GetRealWidth(46), |
| | | Y = Application.GetRealHeight(46), |
| | | UnSelectedImagePath = "DoorLock/RecordIcon.png", |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnRecord); |
| | | btnRecord.MouseDownEventHandler += (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(); |
| | | }; |
| | | btnRecordFrameLayout.AddChidren(btnRecord); |
| | | |
| | | var btnCollect = new Button() |
| | | //搜藏UI |
| | | btnCollectFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(69), |
| | | Height = Application.GetRealHeight(69), |
| | | X = Application.GetRealWidth(850), |
| | | Width = Application.GetRealWidth(69 + 15 + 46), |
| | | Height = Application.GetRealHeight(69 + 46 * 2), |
| | | X = Application.GetRealWidth(850 - 15), |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnCollectFrameLayout); |
| | | btnCollect = new Button() |
| | | { |
| | | Width = Application.GetMinReal(69), |
| | | Height = Application.GetMinReal(69), |
| | | X = Application.GetRealWidth(15), |
| | | Y = Application.GetRealHeight(46), |
| | | UnSelectedImagePath = "DoorLock/FavoriteIcon.png", |
| | | UnSelectedImagePath = "Item/Collection.png", |
| | | SelectedImagePath = "Item/CollectionSelected.png" |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnCollect); |
| | | btnCollect.MouseDownEventHandler += (sender, e) => |
| | | { |
| | | }; |
| | | btnCollectFrameLayout.AddChidren(btnCollect); |
| | | |
| | | var btnCurrentText = new Button() |
| | | //当前状态 |
| | | btnStatus = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(100), |
| | | Width = Application.GetRealWidth(132 + 351), |
| | | Height = Application.GetRealHeight(40), |
| | | X = Application.GetRealWidth(415), |
| | | Y = Application.GetRealHeight(118), |
| | | Text = Language.StringByID(R.MyInternationalizationString.Current), |
| | | Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | TextSize = 10, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnCurrentText); |
| | | |
| | | var btnStatus = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(200), |
| | | Height = Application.GetRealHeight(40), |
| | | X = btnCurrentText.Right, |
| | | Y = Application.GetRealHeight(118), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | Text = Language.StringByID(R.MyInternationalizationString.CLose), |
| | | TextSize = 10, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnStatus); |
| | | |
| | | var btnDoorLockPic = new Button() |
| | | //当前电量 |
| | | btnCurrentPowerText = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(383), |
| | | Height = Application.GetRealHeight(343), |
| | | Width = Application.GetRealWidth(133 + 348), |
| | | Height = Application.GetRealHeight(40), |
| | | X = btnStatus.Right, |
| | | Y = Application.GetRealHeight(118), |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMGray3, |
| | | Text = Language.StringByID(R.MyInternationalizationString.DoorLockPower) + "%", |
| | | TextSize = 10, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnCurrentPowerText); |
| | | #if Android |
| | | btnCurrentPowerText.X = btnStatus.Right + Application.GetRealWidth(20); |
| | | #endif |
| | | |
| | | //门锁开/关图片 |
| | | btnDoorLockPic = new Button() |
| | | { |
| | | Width = Application.GetMinReal(383), |
| | | Height = Application.GetMinReal(343), |
| | | X = Application.GetRealWidth(161), |
| | | Y = Application.GetRealHeight(415), |
| | | UnSelectedImagePath = "DoorLock/DoorLockPicClose.png", |
| | |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnDoorLockPic); |
| | | |
| | | #region 开/关点击布局 |
| | | 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), |
| | |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnFrameLayout); |
| | | |
| | | var openFrameLayout = new FrameLayout() |
| | | openFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(420),//639-35 |
| | | Height = Application.GetRealHeight(446 / 2), |
| | |
| | | }; |
| | | btnFrameLayout.AddChidren(openFrameLayout); |
| | | |
| | | var closeFrameLayout = new FrameLayout() |
| | | closeFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(420),//639-35 |
| | | Height = Application.GetRealHeight(446 / 2), |
| | |
| | | }; |
| | | btnFrameLayout.AddChidren(closeFrameLayout); |
| | | |
| | | progressFrameLayoutMatch = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealHeight(84),//639-35 |
| | | Height = Application.GetRealHeight(446), |
| | | X = Application.GetMinReal(51), |
| | | BackgroundColor = ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | btnFrameLayout.AddChidren(progressFrameLayoutMatch); |
| | | |
| | | var progressFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(9),//639-35 |
| | | Height = Application.GetRealHeight(446), |
| | | X = Application.GetRealWidth(95), |
| | | Y = Application.GetRealHeight(0), |
| | | Width = Application.GetRealHeight(17),//639-35 |
| | | Gravity = Gravity.CenterHorizontal, |
| | | BackgroundColor = ZigbeeColor.Current.XMVerticalSeekBar, |
| | | }; |
| | | btnFrameLayout.AddChidren(progressFrameLayout); |
| | | progressFrameLayoutMatch.AddChidren(progressFrameLayout); |
| | | |
| | | var progressButton = new Button() |
| | | progressButton = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(81),//639-35 |
| | | Height = Application.GetRealHeight(89), |
| | | X = Application.GetRealWidth(58), |
| | | Width = Application.GetMinReal(84),//639-35 |
| | | Height = Application.GetMinReal(93), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Y = Application.GetRealHeight(347), |
| | | UnSelectedImagePath = "DoorLock/UnLockButton.png", |
| | | SelectedImagePath = "DoorLock/UnLockButton.png", |
| | | }; |
| | | btnFrameLayout.AddChidren(progressButton); |
| | | progressFrameLayoutMatch.AddChidren(progressButton); |
| | | |
| | | var btnDoorOpenPic = new Button() |
| | | btnDoorOpenPic = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(81), |
| | | Height = Application.GetRealHeight(81), |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(164), |
| | | Y = Application.GetRealHeight(6), |
| | | UnSelectedImagePath = "DoorLock/DoorLockOpen.png", |
| | | }; |
| | | openFrameLayout.AddChidren(btnDoorOpenPic); |
| | | |
| | | var btnDoorClosePic = new Button() |
| | | btnDoorClosePic = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(81), |
| | | Height = Application.GetRealHeight(81), |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(164), |
| | | Y = Application.GetRealHeight(117), |
| | | UnSelectedImagePath = "DoorLock/DoorLockClose.png", |
| | | }; |
| | | closeFrameLayout.AddChidren(btnDoorClosePic); |
| | | #endregion |
| | | |
| | | //电量 |
| | | btnPower = new Button() |
| | | { |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(253), |
| | | Y = Application.GetRealHeight(994), |
| | | UnSelectedImagePath = "DoorLock/PowerOffline.png", |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnPower); |
| | | |
| | | //音量 |
| | | btnVolumeFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(81 + 80), |
| | | Height = Application.GetRealHeight(81 + 80), |
| | | X = Application.GetRealWidth(444 - 40), |
| | | Y = Application.GetRealHeight(994 - 40), |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnVolumeFrameLayout); |
| | | btnVolume = new Button() |
| | | { |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(40), |
| | | Y = Application.GetRealHeight(40), |
| | | UnSelectedImagePath = "DoorLock/VolumeIcon.png", |
| | | SelectedImagePath = "DoorLock/VolumeIconOn.png", |
| | | }; |
| | | btnVolumeFrameLayout.AddChidren(btnVolume); |
| | | |
| | | //常开 |
| | | btnNormallyOpenFrameLayout = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(81 + 80), |
| | | Height = Application.GetRealHeight(81 + 80), |
| | | X = Application.GetRealWidth(631 - 40), |
| | | Y = Application.GetRealHeight(994 - 40), |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnNormallyOpenFrameLayout); |
| | | btnNormallyOpen = new Button() |
| | | { |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(40), |
| | | Y = Application.GetRealHeight(40), |
| | | UnSelectedImagePath = "DoorLock/NormallyOpen.png", |
| | | SelectedImagePath = "DoorLock/NormallyOpenOn.png", |
| | | }; |
| | | btnNormallyOpenFrameLayout.AddChidren(btnNormallyOpen); |
| | | |
| | | #region 背景圆角设置 |
| | | 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() |
| | | { |
| | |
| | | Height = Application.GetRealHeight(138), |
| | | Y = Application.GetRealHeight(1100), |
| | | BackgroundColor = ZigbeeColor.Current.XMBlack, |
| | | Radius = 6, |
| | | }; |
| | | midTopFrameLayout.AddChidren(btnCurrentFrameLayout); |
| | | #endregion |
| | | |
| | | #region 当前房间 |
| | | var btnCurrentRoomPic = new Button() |
| | | { |
| | | Width = Application.GetRealWidth(81), |
| | | Height = Application.GetRealHeight(81), |
| | | Width = Application.GetMinReal(81), |
| | | Height = Application.GetMinReal(81), |
| | | X = Application.GetRealWidth(58), |
| | | Y = Application.GetRealHeight(29), |
| | | UnSelectedImagePath = "DoorLock/RoomPic.png", |
| | |
| | | Height = Application.GetRealHeight(49), |
| | | X = Application.GetRealWidth(150), |
| | | Y = Application.GetRealHeight(46), |
| | | Text = "客厅", |
| | | Text = currentRoom.Name, |
| | | TextColor = Shared.Common.ZigbeeColor.Current.XMWhite, |
| | | TextSize = 12, |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | }; |
| | | btnCurrentFrameLayout.AddChidren(btnCurrentRoomName); |
| | | #endregion |
| | | |
| | | EventHandler<MouseEventArgs> hander1 = async (sender, e) => |
| | | { |
| | | RemoteUnlockRequest(doorLock, action, progressButton, btnDoorLockPic, btnStatus); |
| | | }; |
| | | openFrameLayout.MouseUpEventHandler += hander1; |
| | | btnDoorOpenPic.MouseUpEventHandler += hander1; |
| | | EventHandler<MouseEventArgs> hander2 = (sender, e) => |
| | | { |
| | | //new Tip() { MaxWidth = 150, Text = "不支持远程关锁", Direction = AMPopTipDirection.Down, CloseTime = 2 }.Show(openFrameLayout); |
| | | btnDoorLockPic.IsSelected = false; |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | }; |
| | | closeFrameLayout.MouseUpEventHandler += hander2; |
| | | btnDoorClosePic.MouseUpEventHandler += hander2; |
| | | #endregion |
| | | } |
| | | |
| | | #region ◆ 接口实现__________________________ |
| | | #region 音量弹窗 |
| | | /// <summary> |
| | | /// 处理变化事件 --将弃用 改用DeviceInfoChange() |
| | | /// 进度条 |
| | | /// </summary> |
| | | /// <returns>The changed.</returns> |
| | | /// <param name="common">Common.</param> |
| | | public void Changed(CommonDevice common) |
| | | private void VolumeDialog(Button progressText, DiyImageVerticalSeekBar diyImageVerticalSeekBar) |
| | | { |
| | | var dialog = new Dialog { }; |
| | | dialog.Show(); |
| | | var flMain = new FrameLayout { BackgroundColor = 0x00000000 }; |
| | | dialog.AddChidren(flMain); |
| | | flMain.MouseUpEventHandler += (sender11, e11) => |
| | | { |
| | | dialog.Close(); |
| | | |
| | | //设置音量 |
| | | if (currentVolume != oldVolume) |
| | | { |
| | | SetVolume(currentVolume); |
| | | } |
| | | }; |
| | | |
| | | var progressBackground = new FrameLayout() |
| | | { |
| | | Width = Application.GetRealWidth(271), |
| | | Height = Application.GetRealHeight(700), |
| | | X = Application.GetRealWidth(403), |
| | | Y = Application.GetRealHeight(582), |
| | | BackgroundImagePath = "DoorLock/ProgressBackground.png", |
| | | }; |
| | | flMain.AddChidren(progressBackground); |
| | | |
| | | //var progressValue = (currentVolume * (Convert.ToInt32(((float)100 / 15) * 100))) / 100; |
| | | progressText = new Button() |
| | | { |
| | | Height = Application.GetRealHeight(58), |
| | | Y = Application.GetRealHeight(89), |
| | | TextColor = ZigbeeColor.Current.XMGray2, |
| | | TextAlignment = TextAlignment.Center, |
| | | Text = currentVolume.ToString() + "%", |
| | | }; |
| | | |
| | | diyImageVerticalSeekBar = new DiyImageVerticalSeekBar() |
| | | { |
| | | Width = Application.GetRealWidth(271), |
| | | Height = Application.GetRealHeight(447 + 63), |
| | | Y = Application.GetRealHeight(155), |
| | | IsProgressTextShow = false,//显示百分比 |
| | | ProgressBarColor = ZigbeeColor.Current.XMProgressBarColor,//选中进度条颜色 |
| | | SeekBarBackgroundColor = ZigbeeColor.Current.XMSeekBarBackgroundColor,//选中进度条颜色 |
| | | ThumbImagePath = "DoorLock/UnLockButton.png",//进度条按钮图标 |
| | | ThumbImageHeight = Application.GetRealHeight(81),//进度条按钮图标的高度(默认正方形:宽和高一样) |
| | | ProgressTextColor = ZigbeeColor.Current.LogicBtnCancelColor, |
| | | ProgressTextSize = 12,//显示百分比字体大小 |
| | | SeekBarViewHeight = Application.GetRealHeight(17),//进度条的宽度 |
| | | Progress = currentVolume, |
| | | }; |
| | | progressBackground.AddChidren(progressText); |
| | | progressBackground.AddChidren(diyImageVerticalSeekBar); |
| | | diyImageVerticalSeekBar.OnProgressChangedEvent += (sender, e) => |
| | | { |
| | | int curVolume = -1; |
| | | curVolume = e; |
| | | currentVolume = curVolume; |
| | | progressText.Text = e.ToString() + "%"; |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 处理接口数据 |
| | | /// <summary> |
| | | /// 处理变化事件 |
| | | /// </summary> |
| | | /// <param name="common"></param> |
| | | /// <param name="typeTag"></param> |
| | | public void DeviceInfoChange(CommonDevice common, string typeTag) |
| | | public void DeviceInfoChange(CommonDevice tempDevice, string typeTag) |
| | | { |
| | | //机械开锁上报。处理常开状态,开关状态 |
| | | if (typeTag == "DoorLockProgrammingEventNotificationCommand" && tempDevice != null) |
| | | { |
| | | var tempDoor = (ZigBee.Device.DoorLock)tempDevice; |
| | | if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint |
| | | && tempDevice.DeviceAddr == doorLock.DeviceAddr) |
| | | { |
| | | if (tempDoor.doorLockOperatingEventNotificationCommand != null) |
| | | { |
| | | //非主人不弹这个窗口 |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1) |
| | | { |
| | | return; |
| | | } |
| | | if (doorLock.IsDoorLockNormallyMode) |
| | | { |
| | | if (canOpenNormallyMode) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Action<bool> action = (obj) => |
| | | { |
| | | UpdateNomallyOpenStatus(); |
| | | }; |
| | | DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.ServicePush, haveLogicNormallyOpenMode, action); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (typeTag == "DeviceStatusReport" && tempDevice != null) |
| | | { |
| | | if (tempDevice != null) |
| | | { |
| | | if (tempDevice.DeviceEpoint == doorLock.DeviceEpoint |
| | | && tempDevice.DeviceAddr == doorLock.DeviceAddr) |
| | | { |
| | | if (tempDevice.DeviceStatusReport != null && tempDevice.DeviceStatusReport.AttriBute != null) |
| | | { |
| | | var dataReport = tempDevice.DeviceStatusReport.AttriBute[0]; |
| | | if (tempDevice.DeviceStatusReport.CluterID == 1 && dataReport.AttributeId == 33) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | currentPower = dataReport.AttriButeData; |
| | | UpdatePower(); |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Changeds the IL ogic status. |
| | | /// 初始化数据 |
| | | /// </summary> |
| | | /// <param name="logic">Logic.</param> |
| | | public void ChangedILogicStatus(ZigBee.Device.Logic logic) |
| | | void ReadDoorLockUserInfo() |
| | | { |
| | | System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | |
| | | //是否支持常开 |
| | | canOpenNormallyMode = DoorLockCommonInfo.CanNormallyOpen(doorLock); |
| | | if (canOpenNormallyMode) |
| | | { |
| | | //1、获取门锁常开模式 |
| | | var resultRes = await DoorLockCommonInfo.GetNormallyOpenMode(doorLock); |
| | | if (resultRes == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnNormallyOpen.UnSelectedImagePath = "DoorLock/NormallyOpenOffline.png"; |
| | | btnNormallyOpen.Enable = false; |
| | | string msg = Language.StringByID(R.MyInternationalizationString.GetNormallyOpenModeFailed); |
| | | this.ShowTipMsg(msg); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | var tempRes = false; |
| | | if (resultRes == true) |
| | | { |
| | | tempRes = true; |
| | | } |
| | | else |
| | | { |
| | | tempRes = false; |
| | | } |
| | | DoorLockCommonInfo.NormallyOpenModeValue(doorLock, tempRes); |
| | | |
| | | Application.RunOnMainThread(async () => |
| | | { |
| | | var resTemp = await Shared.Phone.Device.Logic.SkipView.Exist(2, doorLock); |
| | | if (resTemp == 0) |
| | | { |
| | | haveLogicNormallyOpenMode = false; |
| | | } |
| | | else |
| | | { |
| | | haveLogicNormallyOpenMode = true; |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnNormallyOpenFrameLayout.Width = Application.GetRealWidth(0); |
| | | }); |
| | | } |
| | | |
| | | //是否支持音量 |
| | | canVolume = DoorLockCommonInfo.CanVolume(doorLock); |
| | | if (canVolume) |
| | | { |
| | | //2、读取音量 |
| | | var resultRes = await doorLock.GetVolumeAsync(); |
| | | if (resultRes == null || resultRes.volumeResponseData == null) |
| | | { |
| | | var listDevice = new List<CommonDevice> { }; |
| | | listDevice.Add(doorLock); |
| | | var devTemp = HdlDeviceCommonLogic.Current.GetMyDeviceEnumInfo(listDevice); |
| | | if (devTemp.ConcreteType == DeviceConcreteType.IntelligentLocks_Sone) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var volumeMsg = Language.StringByID(R.MyInternationalizationString.GetVolumeFailed); |
| | | this.ShowTipMsg(volumeMsg); |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | volumeData = resultRes.volumeResponseData; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UpdateVolume(); |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | btnVolumeFrameLayout.Width = Application.GetRealWidth(0); |
| | | btnPower.X = Application.GetRealWidth(444); |
| | | }); |
| | | } |
| | | |
| | | //3、读取门锁电量:簇ID:1 属性ID 33 |
| | | doorLock.ReadAttri(Cluster_ID.Power, AttriButeId.DoorLockPower); |
| | | //上报电量等1秒 |
| | | System.Threading.Thread.Sleep(1000); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | var mess = ex.Message; |
| | | } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | UpdateNomallyOpenStatus(); |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 公共事件处理 |
| | | /// <summary> |
| | | /// Changeds the IS cene status. |
| | | /// 事件处理 |
| | | /// </summary> |
| | | /// <param name="scene">Scene.</param> |
| | | public void ChangedISceneStatus(Scene scene) |
| | | public void ClickHandle() |
| | | { |
| | | //门锁标题 |
| | | btnDoorLockTitle.Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock); |
| | | |
| | | //返回 |
| | | EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | this.btnBack.MouseUpEventHandler += eHandlerBack; |
| | | this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; |
| | | |
| | | //设置 |
| | | EventHandler<MouseEventArgs> btnFuncSetHander = (sender, e) => |
| | | { |
| | | var functionSetting = new Shared.Phone.UserCenter.DoorLock.FunctionSetting(currentRoom, doorLock); |
| | | Shared.Phone.UserView.HomePage.Instance.AddChidren(functionSetting); |
| | | Shared.Phone.UserView.HomePage.Instance.PageIndex += 1; |
| | | functionSetting.Show(); |
| | | //DoorLockCommonInfo.canShowDialog = false; |
| | | functionSetting.devicNameAction += (deviceRename) => |
| | | { |
| | | if (!string.IsNullOrEmpty(deviceRename)) |
| | | { |
| | | btnDoorLockTitle.Text = deviceRename; |
| | | //改房间 |
| | | HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); |
| | | deviceUI.ReSave(); |
| | | } |
| | | }; |
| | | }; |
| | | btnFuncSetFrameLayout.MouseDownEventHandler += btnFuncSetHander; |
| | | btnFuncSet.MouseDownEventHandler += btnFuncSetHander; |
| | | |
| | | //搜藏状态 |
| | | if (HdlRoomLogic.Current.IsCollectInRoom(deviceUI) == false) |
| | | { |
| | | btnCollect.IsSelected = false; |
| | | } |
| | | else |
| | | { |
| | | btnCollect.IsSelected = true; |
| | | } |
| | | |
| | | //历史记录点击事件 |
| | | EventHandler<MouseEventArgs> handerRecord = (sender, e) => |
| | | { |
| | | //历史记录 ---- stan |
| | | var form = new DeviceDoorLock.DoorLockHistoryLogForm(); |
| | | form.AddForm(this.doorLock.DeviceAddr); |
| | | //DoorLockCommonInfo.canShowDialog = false; |
| | | }; |
| | | btnRecordFrameLayout.MouseDownEventHandler += handerRecord; |
| | | btnRecord.MouseDownEventHandler += handerRecord; |
| | | |
| | | //收藏点击事件 |
| | | EventHandler<MouseEventArgs> handerCollect = (sender, e) => |
| | | { |
| | | btnCollect.IsSelected = !btnCollect.IsSelected; |
| | | if (btnCollect.IsSelected) |
| | | { |
| | | HdlRoomLogic.Current.AddLoveDevice(deviceUI);//收藏 |
| | | } |
| | | else |
| | | { |
| | | HdlRoomLogic.Current.DeleteLoveDevice(deviceUI);//取消收藏 |
| | | } |
| | | }; |
| | | btnCollectFrameLayout.MouseDownEventHandler += handerCollect; |
| | | btnCollect.MouseDownEventHandler += handerCollect; |
| | | |
| | | //开锁事件 |
| | | EventHandler<MouseEventArgs> hander1 = async (sender, e) => |
| | | { |
| | | if (doorLock.IsDoorLockNormallyMode) |
| | | { |
| | | if (canOpenNormallyMode) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Action<bool> action = (obj) => |
| | | { |
| | | UpdateNomallyOpenStatus(); |
| | | }; |
| | | DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action); |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | OpenDoorLockHandle(progressButton, btnDoorLockPic, btnStatus); |
| | | } |
| | | }; |
| | | openFrameLayout.MouseUpEventHandler += hander1; |
| | | btnDoorOpenPic.MouseUpEventHandler += hander1; |
| | | if (progressButton.Y == Application.GetRealHeight(10)) |
| | | { |
| | | progressFrameLayoutMatch.MouseUpEventHandler += hander1; |
| | | } |
| | | |
| | | //关锁事件 |
| | | EventHandler<MouseEventArgs> hander2 = (sender, e) => |
| | | { |
| | | if (canOpenNormallyMode) |
| | | { |
| | | if (doorLock.IsDoorLockNormallyMode) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Action<bool> action = (obj) => |
| | | { |
| | | UpdateNomallyOpenStatus(); |
| | | }; |
| | | DoorLockCommonInfo.NomallyOpenModeInvalidDialog(doorLock, DoorLockCommonInfo.DoorLockMessType.AppOperate, haveLogicNormallyOpenMode, action); |
| | | }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | btnDoorLockPic.IsSelected = false; |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | } |
| | | }; |
| | | closeFrameLayout.MouseUpEventHandler += hander2; |
| | | btnDoorClosePic.MouseUpEventHandler += hander2; |
| | | |
| | | //音量点击事件 |
| | | EventHandler<MouseEventArgs> handerVolume = (sender, e) => |
| | | { |
| | | if (canVolume) |
| | | { |
| | | VolumeDialog(progressText, diyImageVerticalSeekBar); |
| | | } |
| | | }; |
| | | btnVolumeFrameLayout.MouseDownEventHandler += handerVolume; |
| | | btnVolume.MouseDownEventHandler += handerVolume; |
| | | |
| | | |
| | | //常开模式点击事件 |
| | | EventHandler<MouseEventArgs> handerNormallyOpen = (sender, e) => |
| | | { |
| | | NomallyOpenDialog(); |
| | | }; |
| | | btnNormallyOpenFrameLayout.MouseUpEventHandler += handerNormallyOpen; |
| | | btnNormallyOpen.MouseUpEventHandler += handerNormallyOpen; |
| | | } |
| | | #endregion |
| | | |
| | | #region 电量显示 |
| | | /// <summary> |
| | | /// 电量更新 |
| | | /// </summary> |
| | | private void UpdatePower() |
| | | { |
| | | btnCurrentPowerText.Text = Language.StringByID(R.MyInternationalizationString.DoorLockPower) + currentPower + "%"; |
| | | if (currentPower <= 20 && currentPower >= 0) |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/LowPower.png"; |
| | | } |
| | | else if (currentPower <= 40 && currentPower > 20) |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/Power40.png"; |
| | | } |
| | | else if (currentPower <= 60 && currentPower > 40) |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/Power60.png"; |
| | | } |
| | | else if (currentPower <= 80 && currentPower > 60) |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/Power80.png"; |
| | | } |
| | | else if (currentPower <= 100 && currentPower > 80) |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/Power100.png"; |
| | | } |
| | | else |
| | | { |
| | | btnPower.UnSelectedImagePath = "DoorLock/PowerOffline.png"; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 音量 |
| | | /// <summary> |
| | | /// 更新音量 |
| | | /// </summary> |
| | | private void UpdateVolume() |
| | | { |
| | | if (volumeData != null) |
| | | { |
| | | int curVol = 0; |
| | | btnVolume.IsSelected = true; |
| | | if (volumeData.command == "eb") |
| | | { |
| | | curVol = 0; |
| | | } |
| | | else |
| | | { |
| | | curVol = volumeData.value; |
| | | } |
| | | oldVolume = currentVolume = curVol; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置音量 |
| | | /// </summary> |
| | | private void SetVolume(int volume) |
| | | { |
| | | System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | try |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | CommonPage.Loading.Start(""); |
| | | }); |
| | | var resultRes = await doorLock.SetVolumeAsync(volume); |
| | | if (resultRes == null || resultRes.defaultControlResponseData == null) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var volumeMsg = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime); |
| | | this.ShowTipMsg(volumeMsg); |
| | | currentVolume = oldVolume; |
| | | CommonPage.Loading.Hide(); |
| | | |
| | | }); |
| | | return; |
| | | } |
| | | if (resultRes.defaultControlResponseData.status != 0) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var volumeMsg = Language.StringByID(R.MyInternationalizationString.SetVolumeFailed); |
| | | this.ShowTipMsg(volumeMsg); |
| | | currentVolume = oldVolume; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | return; |
| | | } |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var volumeMsg = Language.StringByID(R.MyInternationalizationString.SetVolumeSuccess); |
| | | this.ShowTipMsg(volumeMsg); |
| | | oldVolume = currentVolume; |
| | | CommonPage.Loading.Hide(); |
| | | }); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | var mes = ex.Message; |
| | | } |
| | | }); |
| | | } |
| | | #endregion |
| | | |
| | | #region 常开模式 |
| | | /// <summary> |
| | | /// 常开模式处理 |
| | | /// </summary> |
| | | private async void NomallyOpenDialog() |
| | | { |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1) |
| | | { |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.OnlyMasterOperate)); |
| | | return; |
| | | } |
| | | |
| | | if (!HdlUserCenterResourse.AccountOption.DoorUnLockByRemote) |
| | | { |
| | | SystemSecondAuthentication(); |
| | | return; |
| | | } |
| | | |
| | | action = () => |
| | | { |
| | | //WJC的代码:系统密码支持操作门锁后,调用温居城的界面【常开自动化】 |
| | | if (doorLock == null) |
| | | { |
| | | ///防止抛异常 |
| | | return; |
| | | } |
| | | ///备注:WJC的 |
| | | Shared.Phone.Device.Logic.Send.CurrentDoorLock = doorLock; |
| | | ///进来刷新一次设备列表; |
| | | Common.Logic.LogicDviceList.Clear(); |
| | | if (Common.Logic.LogicDviceList.Count == 0) |
| | | { |
| | | Common.Logic.LogicDviceList.AddRange(HdlDeviceCommonLogic.Current.listAllDevice.ToArray()); |
| | | } |
| | | var addLogicPage = new Shared.Phone.Device.Logic.SoneLogicList(); |
| | | UserView.HomePage.Instance.AddChidren(addLogicPage); |
| | | UserView.HomePage.Instance.PageIndex += 1; |
| | | addLogicPage.Show(); |
| | | addLogicPage.action += async (w) => |
| | | { |
| | | DoorLockCommonInfo.NormallyOpenModeValue(doorLock, w); |
| | | UpdateNomallyOpenStatus(); |
| | | //返回按键清空当前逻辑定义的LogicAction |
| | | UserCenter.DoorLock.DoorLockCommonInfo.LogicAction = null; |
| | | //是否存在常开模式 |
| | | var resTemp = Shared.Common.Logic.SoneLogicList; |
| | | if (resTemp.Count == 0) |
| | | { |
| | | haveLogicNormallyOpenMode = false; |
| | | } |
| | | else |
| | | { |
| | | haveLogicNormallyOpenMode = true; |
| | | } |
| | | |
| | | UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction -= addLogicPage.updateCurrentDoorlockActionTemp; |
| | | }; |
| | | }; |
| | | HdlCheckLogic.Current.CheckSecondarySecurity(action); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 常开模式状态更新 |
| | | /// </summary> |
| | | private void UpdateNomallyOpenStatus() |
| | | { |
| | | if (!canOpenNormallyMode) |
| | | { |
| | | btnNormallyOpenFrameLayout.Width = Application.GetRealWidth(0); |
| | | return; |
| | | } |
| | | if (doorLock.IsDoorLockNormallyMode) |
| | | { |
| | | btnNormallyOpen.IsSelected = true; |
| | | btnDoorLockPic.IsSelected = true; |
| | | progressButton.Y = Application.GetRealHeight(10); |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.DoorLockOpen); |
| | | |
| | | } |
| | | else if (!doorLock.IsDoorLockNormallyMode) |
| | | { |
| | | btnStatus.Text = Language.StringByID(R.MyInternationalizationString.Current) + Language.StringByID(R.MyInternationalizationString.CLose); |
| | | btnDoorLockPic.IsSelected = false; |
| | | btnNormallyOpen.IsSelected = false; |
| | | progressButton.Y = Application.GetRealHeight(347); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 开锁处理 |
| | | /// <summary> |
| | | /// 开锁处理 |
| | | /// </summary> |
| | | /// <param name="progressButton">进度按钮</param> |
| | | /// <param name="btnDoorLockPic">门锁图片</param> |
| | | /// <param name="btnStatus">状态显示</param> |
| | | async void OpenDoorLockHandle(Button progressButton, Button btnDoorLockPic, Button btnStatus) |
| | | { |
| | | openFrameLayout.Enable = false; |
| | | btnDoorOpenPic.Enable = false; |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1) |
| | | { |
| | | var result = await DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); |
| | | if (result == false) |
| | | { |
| | | var result1 = await DoorLockCommonInfo.GetDoorLockUnlockAccess(doorLock, Shared.Common.Config.Instance.Guid); |
| | | if (result1 == true) |
| | | { |
| | | RemoteUnlockRequest(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle); |
| | | devicNameSecAction += (deviceRename) => |
| | | { |
| | | if (!string.IsNullOrEmpty(deviceRename)) |
| | | { |
| | | btnDoorLockTitle.Text = deviceRename; |
| | | //改房间 |
| | | HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); |
| | | deviceUI.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(currentRoom, deviceUI, action, progressButton, btnDoorLockPic, btnStatus, btnDoorLockTitle); |
| | | devicNameSecAction += (deviceRename) => |
| | | { |
| | | if (!string.IsNullOrEmpty(deviceRename)) |
| | | { |
| | | btnDoorLockTitle.Text = deviceRename; |
| | | //改房间 |
| | | HdlRoomLogic.Current.ChangedRoom(deviceUI, currentRoom.Id); |
| | | deviceUI.ReSave(); |
| | | } |
| | | }; |
| | | openFrameLayout.Enable = true; |
| | | btnDoorOpenPic.Enable = true; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 移除方法 |
| | | /// <summary> |
| | | /// 重写移除方法 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | UserCenter.DoorLock.DoorLockCommonInfo.UpdateCurrentDoorlockAction = null; |
| | | if (IsDrawerLockMode) |
| | | { |
| | | CommonPage.Instance.IsDrawerLockMode = false; |
| | | } |
| | | ZbGateway.StatusList.Remove(this); |
| | | DoorLockCommonInfo.LogicAction = null; |
| | | base.RemoveFromParent(); |
| | | } |
| | | #endregion |
| | | } |