using System; using System.Collections.Generic; using Shared.Common; using ZigBee.Device; namespace Shared.Phone.UserCenter.DoorLock { public class FunctionSetting : DoorLockCommonLayout, ZigBee.Common.IStatus { /// /// 构造函数 /// /// public FunctionSetting(ZigBee.Device.DoorLock doorLock) { this.doorLock = doorLock; BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; ZigBee.Device.ZbGateway.StatusList.Add(this); } #region ◆ 变量申明__________________________ ZigBee.Device.DoorLock doorLock; /// /// 设备需要保存的设备名字 /// private Dictionary dicDeviceSaveName = new Dictionary(); /// /// 当前选择的设备 /// private CommonDevice nowSelectDevice = null; /// /// 设备备注的控件 /// private FrameCaptionInputControl btnDeviceName = null; /// /// 设备的某一回路 /// private CommonDevice deviceObj = null; #endregion /// /// UI显示 /// public void Show() { this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLockFunctionSetting)); EventHandler eHandlerBack = (sender, e) => { RemoveFromParent(); }; this.btnBack.MouseUpEventHandler += eHandlerBack; this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; this.MidFrameLayout(this); MidFrameLayoutContent(); } public void MidFrameLayoutContent() { var MidTopFrameLayout = new FrameLayout() { X = Application.GetRealWidth(449), Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(184), Height = Application.GetRealHeight(184), BackgroundImagePath = "DoorLock/DoorlockPicture.png", }; this.midFrameLayout.AddChidren(MidTopFrameLayout); 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 bottomFrameLayout2 = new FrameLayout() { Height = Application.GetRealHeight(1054), Y = Application.GetRealHeight(418), }; this.midFrameLayout.AddChidren(bottomFrameLayout2); var informationEdit = new Button() { Height = Application.GetRealHeight(60), X = Application.GetRealWidth(58), Y = Application.GetRealHeight(81), Text = Language.StringByID(R.MyInternationalizationString.InformationEdit), TextColor = Shared.Common.ZigbeeColor.Current.XMBlack, TextAlignment = TextAlignment.CenterLeft, TextSize = 15, }; bottomFrameLayout2.AddChidren(informationEdit); for (int i = 0; i < 6; i++) { var bottomRowLayout = new FrameLayout() { Height = Application.GetRealHeight(58), }; bottomFrameLayout2.AddChidren(bottomRowLayout); var btnName = new Button() { Width = Application.GetRealWidth(233), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(58), TextColor = Shared.Common.ZigbeeColor.Current.XMTopTitleText, TextAlignment = TextAlignment.CenterLeft, TextSize = 14, }; bottomRowLayout.AddChidren(btnName); var btnNextFrameLayout = new FrameLayout() { Width = Application.GetRealWidth(104), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(861 + 58), }; bottomRowLayout.AddChidren(btnNextFrameLayout); var btnNext = new Button() { Width = Application.GetRealWidth(58), Height = Application.GetRealHeight(58), X = Application.GetRealWidth(46) }; btnNextFrameLayout.AddChidren(btnNext); var btnLine = new FrameLayout() { Width = Application.GetRealWidth(965), Height = 1, X = Application.GetRealWidth(58), BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine, Visible = false, }; bottomFrameLayout2.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; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(303); } else if (i == 1) { bottomRowLayout.Y = Application.GetRealHeight(312); bottomRowLayout.Height = Application.GetRealHeight(127); btnName.Width = Application.GetRealWidth(0); btnNextFrameLayout.Width = Application.GetRealWidth(0); //所属区域 var rowBeloneArea = new BelongAreaControl(0); bottomRowLayout.AddChidren(rowBeloneArea); rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), doorLock); //底线 rowBeloneArea.AddBottomLine(); rowBeloneArea.SelectRoomEvent += (roomKeys) => { //变更房间 Common.Room.CurrentRoom.ChangedRoom(doorLock, roomKeys); }; btnLine.Visible = false; } else if (i == 2) { 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); btnNext.TextAlignment = TextAlignment.CenterLeft; btnNext.Height = Application.GetRealHeight(58); btnNext.Text = doorLock.DeviceName; btnNext.TextColor = Shared.Common.ZigbeeColor.Current.XMGray3; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(575); } else if (i == 3) { bottomRowLayout.Y = Application.GetRealHeight(585 + 35); btnName.Text = Language.StringByID(R.MyInternationalizationString.TemporaryPassword); btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png"; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(714); } else if (i == 4) { bottomRowLayout.Y = Application.GetRealHeight(723 + 35); btnNext.X = Application.GetRealWidth(0); btnName.Text = Language.StringByID(R.MyInternationalizationString.RemotelyUnlock); btnNext.Width = Application.GetRealWidth(104); btnNext.Height = Application.GetRealHeight(63); btnNext.UnSelectedImagePath = "DoorLock/Switch.png"; btnNext.SelectedImagePath = "DoorLock/SwitchOn.png"; btnLine.Visible = true; btnLine.Y = Application.GetRealHeight(853); if (doorLock.RemoteUnlockPassword == "") { btnNext.IsSelected = false; } else { btnNext.IsSelected = true; } } else if (i == 5) { bottomRowLayout.Y = Application.GetRealHeight(861 + 35); btnName.Text = Language.StringByID(R.MyInternationalizationString.DoorLockTime); btnNextFrameLayout.Y = btnName.Y; btnNext.UnSelectedImagePath = "DoorLock/RightIcon.png"; 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 eHandler = async (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(); } else if (currentIndex == 3) { var result = await Shared.Phone.UserCenter.DoorLock.DoorLockCommonInfo.GetDoorLockOperateAccess(doorLock, Shared.Common.Config.Instance.Guid); if (result == false) { 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 { new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.AccountIsFreezed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(this.btnTip); } } 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.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 { 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.Up, CloseTime = 1 }.Show(this.btnTip); } } }; 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); //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(); //}; } #region ◆ 接口实现__________________________ /// /// 处理变化事件 --将弃用 改用DeviceInfoChange() /// /// The changed. /// Common. public void Changed(CommonDevice common) { } /// /// 处理变化事件 /// /// /// public void DeviceInfoChange(CommonDevice common, string typeTag) { } /// /// Changeds the IL ogic status. /// /// Logic. public void ChangedILogicStatus(ZigBee.Device.Logic logic) { } /// /// Changeds the IS cene status. /// /// Scene. public void ChangedISceneStatus(Scene scene) { } #endregion } }