New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Shared.Common; |
| | | using Shared.Phone.UserView; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter.DoorLock |
| | | { |
| | | public class FunctionSetting : DoorLockCommonLayout |
| | | { |
| | | #region 构造函数 |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="doorLock"></param> |
| | | public FunctionSetting(Room room, CommonDevice doorLock) |
| | | { |
| | | this.doorLock = doorLock as ZigBee.Device.DoorLock; |
| | | currentRoom = room; |
| | | deviceUI = doorLock; |
| | | listNewDevice.Add(doorLock); |
| | | BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor; |
| | | } |
| | | #endregion |
| | | |
| | | #region 变量申明 |
| | | public ZigBee.Device.DoorLock doorLock = null; |
| | | /// <summary> |
| | | /// 当前房间 |
| | | /// </summary> |
| | | Room currentRoom; |
| | | /// <summary> |
| | | /// 设备UI对象 |
| | | /// </summary> |
| | | CommonDevice deviceUI; |
| | | /// <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; |
| | | /// <summary> |
| | | /// 设备对象 |
| | | /// </summary> |
| | | private List<CommonDevice> listNewDevice = new List<CommonDevice> { }; |
| | | Action action; |
| | | Action actionNone; |
| | | string modifyDeviceName = ""; |
| | | bool IsModifyName = true; |
| | | public Action<string> devicNameAction; |
| | | private VerticalListControl listview = null;//功能列表 |
| | | FrameLayout bottomFrameLayout; |
| | | #endregion |
| | | |
| | | #region UI显示 |
| | | /// <summary>
|
| | | /// UI显示 |
| | | /// </summary> |
| | | public void Show() |
| | | { |
| | | this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.DoorLockFunctionSetting)); |
| | | |
| | | EventHandler<MouseEventArgs> eHandlerBack = (sender, e) => |
| | | { |
| | | RemoveFromParent(); |
| | | }; |
| | | this.btnBack.MouseUpEventHandler += eHandlerBack; |
| | | this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack; |
| | | this.MidFrameLayout(this); |
| | | |
| | | MidFrameLayoutContent(); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 中部显示 |
| | | public void MidFrameLayoutContent() |
| | | { |
| | | //图片 |
| | | var btnPic = new DeviceInfoIconControl(); |
| | | btnPic.Y = Application.GetRealHeight(92); |
| | | btnPic.Gravity = Gravity.CenterHorizontal; |
| | | this.midFrameLayout.AddChidren(btnPic); |
| | | btnPic.InitControl(doorLock); |
| | | |
| | | 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(); |
| | | } |
| | | #endregion |
| | | |
| | | #region 底部显示 |
| | | public void BottomFrameLayout() |
| | | { |
| | | #region UI |
| | | bottomFrameLayout = new FrameLayout() |
| | | { |
| | | Height = Application.GetRealHeight(1319), |
| | | Y = Application.GetRealHeight(418), |
| | | BackgroundColor = ZigbeeColor.Current.XMWhite, |
| | | }; |
| | | this.midFrameLayout.AddChidren(bottomFrameLayout); |
| | | bottomFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); |
| | | |
| | | 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, |
| | | }; |
| | | bottomFrameLayout.AddChidren(informationEdit); |
| | | |
| | | listview = new VerticalListControl() |
| | | { |
| | | Height = Application.GetRealHeight(1319 - 141), |
| | | Y = Application.GetRealHeight(170), |
| | | }; |
| | | bottomFrameLayout.AddChidren(listview); |
| | | #endregion |
| | | |
| | | FunctionDetail(doorLock); |
| | | } |
| | | #endregion |
| | | |
| | | #region 功能显示 |
| | | void FunctionDetail(ZigBee.Device.DoorLock doorLock) |
| | | { |
| | | listview.RemoveAll(); |
| | | //设备备注 |
| | | string caption = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm); |
| | | string deviceName = Common.LocalDevice.Current.GetDeviceMacName(doorLock); |
| | | var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2); |
| | | listview.AddChidren(btnNote); |
| | | btnNote.InitControl(); |
| | | //划线 |
| | | btnNote.AddBottomLine(); |
| | | btnNote.txtInput.FinishInputEvent += () => |
| | | { |
| | | string oldName = Common.LocalDevice.Current.GetDeviceMacName(doorLock); |
| | | if (btnNote.Text == string.Empty) |
| | | { |
| | | btnNote.Text = oldName; |
| | | } |
| | | if (oldName != btnNote.Text) |
| | | { |
| | | //修改名字 |
| | | this.DeviceReName(btnNote.Text, false); |
| | | } |
| | | }; |
| | | |
| | | //所属区域 |
| | | var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2); |
| | | listview.AddChidren(rowBeloneArea); |
| | | rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), this.listNewDevice); |
| | | //底线 |
| | | rowBeloneArea.AddBottomLine(); |
| | | |
| | | var listCheck = new List<string>(); |
| | | rowBeloneArea.SelectRoomEvent += (roomKeys) => |
| | | { |
| | | //选择未分配时,清空
|
| | | if (roomKeys == string.Empty) { listCheck = new List<string>(); } |
| | | foreach (var device in this.listNewDevice) |
| | | {
|
| | | if (roomKeys == string.Empty)
|
| | | {
|
| | | //如果选择的是未分配,则它的全部回路无条件全部清空房间
|
| | | HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
|
| | | continue;
|
| | | } |
| | | var room = HdlRoomLogic.Current.GetRoomByDevice(device); |
| | | string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | if (room == null) |
| | | { |
| | | //这里有点特殊,如果回路没有设置有区域的时候,才设置 |
| | | listCheck.Add(mainKeys); |
| | | HdlRoomLogic.Current.ChangedRoom(device, roomKeys); |
| | | } |
| | | else if (listCheck.Contains(mainKeys) == true) |
| | | { |
| | | //如果这个回路之前都还没有区域,在本界面还没有关闭之前,可以无条件随便变更 |
| | | HdlRoomLogic.Current.ChangedRoom(device, roomKeys); |
| | | } |
| | | } |
| | | //保存设备房间索引 |
| | | Common.LocalDevice.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys); |
| | | }; |
| | | |
| | | //设备模块 |
| | | caption = Language.StringByID(R.MyInternationalizationString.BelongDevice); |
| | | deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice); |
| | | var btnType = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2); |
| | | btnType.UseClickStatu = false; |
| | | listview.AddChidren(btnType); |
| | | btnType.InitControl(); |
| | | //划线 |
| | | btnType.AddBottomLine(); |
| | | |
| | | //添加全部菜单 |
| | | this.AddAllMenuRow(); |
| | | FinishInitControl(bottomFrameLayout, this.listview); |
| | | //保存 |
| | | var btnFinish = new BottomClickButton(); |
| | | btnFinish.Y = Application.GetRealHeight(1054); |
| | | btnFinish.TextID = R.MyInternationalizationString.uSave; |
| | | bottomFrameLayout.AddChidren(btnFinish); |
| | | btnFinish.ButtonClickEvent += (sender, e) => |
| | | { |
| | | string oldName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]); |
| | | if (btnNote.Text.Trim() == string.Empty) |
| | | { |
| | | btnNote.Text = oldName; |
| | | } |
| | | if (oldName != btnNote.Text.Trim()) |
| | | { |
| | | //修改名字 |
| | | this.DeviceReName(btnNote.Text.Trim(), true); |
| | | } |
| | | else |
| | | { |
| | | //关闭自身 |
| | | this.CloseForm(); |
| | | } |
| | | }; |
| | | } |
| | | #endregion |
| | | |
| | | #region 添加全部菜单 |
| | | /// <summary> |
| | | /// 添加全部菜单 |
| | | /// </summary> |
| | | private void AddAllMenuRow() |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1) |
| | | { |
| | | //添加【临时密码】行 |
| | | this.AddTempPasswordRow(); |
| | | //添加【远程开锁】行 |
| | | this.AddRemoteUnLocksRow(); |
| | | //添加【门锁时间】行 |
| | | this.AddDoorLocksTimeRow(); |
| | | } |
| | | else |
| | | { |
| | | //添加【远程开锁】行 |
| | | this.AddRemoteUnLocksRow(); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 临时密码 |
| | | /// <summary> |
| | | /// 临时密码 |
| | | /// </summary> |
| | | private void AddTempPasswordRow() |
| | | { |
| | | //用户管理 |
| | | string caption = Language.StringByID(R.MyInternationalizationString.TemporaryPassword); |
| | | var btnRow = new FrameRowControl(listview.rowSpace / 2); |
| | | listview.AddChidren(btnRow); |
| | | btnRow.AddLeftCaption(caption, 600); |
| | | //向右图标 |
| | | btnRow.AddRightArrow(); |
| | | //底线 |
| | | btnRow.AddBottomLine(); |
| | | btnRow.ButtonClickEvent += async (sender, e) => |
| | | { |
| | | 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); |
| | | }; |
| | | HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone); |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 远程开锁 |
| | | /// <summary> |
| | | /// 添加【远程开锁】行(门锁专用) |
| | | /// </summary> |
| | | private void AddRemoteUnLocksRow() |
| | | { |
| | | //远程开锁 |
| | | string caption = Language.StringByID(R.MyInternationalizationString.uRemoteUnLocks); |
| | | var btnRow = new FrameRowControl(listview.rowSpace / 2); |
| | | btnRow.UseClickStatu = false; |
| | | listview.AddChidren(btnRow); |
| | | btnRow.AddLeftCaption(caption, 600); |
| | | //开关图标 |
| | | var btnswitch = btnRow.AddMostRightSwitchIcon(); |
| | | //底线 |
| | | btnRow.AddBottomLine(); |
| | | |
| | | var doorLock = (ZigBee.Device.DoorLock)listNewDevice[0]; |
| | | if (string.IsNullOrEmpty(doorLock.RemoteUnlockPassword) == false) |
| | | { |
| | | btnswitch.IsSelected = true; |
| | | } |
| | | |
| | | btnswitch.ButtonClickEvent += async (sender, e) => |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1) |
| | | { |
| | | if (btnswitch.IsSelected == true) |
| | | { |
| | | btnswitch.IsSelected = false; |
| | | doorLock.RemoteUnlockPassword = string.Empty; |
| | | return; |
| | | } |
| | | var frame = new DoorLock.DoorLockCommonLayout(); |
| | | frame.RemotePasswordDialog((ZigBee.Device.DoorLock)listNewDevice[0], btnswitch.btnIcon); |
| | | frame = null; |
| | | } |
| | | else |
| | | { |
| | | 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) |
| | | { |
| | | if (btnswitch.IsSelected == true) |
| | | { |
| | | btnswitch.IsSelected = false; |
| | | doorLock.RemoteUnlockPassword = string.Empty; |
| | | return; |
| | | } |
| | | var frame = new DoorLock.DoorLockCommonLayout(); |
| | | frame.RemotePasswordDialog((ZigBee.Device.DoorLock)listNewDevice[0], btnswitch.btnIcon); |
| | | frame = null; |
| | | } |
| | | else |
| | | { |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.NoAccess)); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed)); |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 门锁时间 |
| | | |
| | | /// <summary> |
| | | /// 添加【门锁时间】行(门锁专用) |
| | | /// </summary> |
| | | private void AddDoorLocksTimeRow() |
| | | { |
| | | //门锁时间 |
| | | string caption = Language.StringByID(R.MyInternationalizationString.uDoorLocksTime); |
| | | var btnRow = new FrameRowControl(listview.rowSpace / 2); |
| | | listview.AddChidren(btnRow); |
| | | btnRow.AddLeftCaption(caption, 600); |
| | | //向右图标 |
| | | btnRow.AddRightArrow(); |
| | | //底线 |
| | | btnRow.AddBottomLine(); |
| | | var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock; |
| | | btnRow.ButtonClickEvent += async (sender, e) => |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 1) |
| | | { |
| | | 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 |
| | | { |
| | | 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 |
| | | { |
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AccountIsFreezed)); |
| | | } |
| | | } |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 设备重命名 |
| | | /// <summary> |
| | | /// 设备重命名 |
| | | /// </summary> |
| | | /// <param name="i_deviceName">deviceName.</param> |
| | | private void DeviceReName(string i_deviceName, bool closeForm) |
| | | { |
| | | //开启进度条 |
| | | this.ShowProgressBar(); |
| | | |
| | | //修改MAC名 |
| | | string deviceName = i_deviceName.Trim(); |
| | | var result = Common.LocalDevice.Current.ReMacName(listNewDevice, deviceName); |
| | | //关闭进度条 |
| | | this.CloseProgressBar(); |
| | | |
| | | if (result == false) |
| | | { |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | if (devicNameAction != null) |
| | | { |
| | | devicNameAction(deviceName); |
| | | } |
| | | } |
| | | if (closeForm == true) |
| | | { |
| | | //关闭界面 |
| | | this.CloseForm(); |
| | | } |
| | | else |
| | | { |
| | | //设备备注修改成功! |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeviceReNoteSuccess); |
| | | this.ShowMassage(ShowMsgType.Tip, msg); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 行数超过容器时,补一个空白FrameLayout |
| | | /// <summary> |
| | | /// 行数超过容器时,补一个空白FrameLayout,使之能滑动 |
| | | /// </summary> |
| | | void FinishInitControl(FrameLayout bodyFrameLayout, VerticalListControl listview) |
| | | { |
| | | if (listview.ChildrenCount > 0) |
| | | { |
| | | var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount; |
| | | |
| | | if (bodyFrameLayout.Height - Application.GetRealHeight(1054) + realHeight > listview.Height) |
| | | { |
| | | //促使被挡住的菜单能够向上滑动 |
| | | var frameTemp = new FrameLayout(); |
| | | frameTemp.Height = bodyFrameLayout.Height - Application.GetRealHeight(1054) + Application.GetRealHeight(115); |
| | | listview.AddChidren(frameTemp); |
| | | } |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 移除方法 |
| | | /// <summary> |
| | | /// 重写移除方法 |
| | | /// </summary> |
| | | public override void RemoveFromParent() |
| | | { |
| | | base.RemoveFromParent(); |
| | | } |
| | | #endregion |
| | | } |
| | | } |
| | | |
| | | |