New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 所属区域的控件
|
| | | /// </summary>
|
| | | public class BelongAreaControl : FrameRowControl
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 选择房间的事件(房间主键)
|
| | | /// </summary>
|
| | | public Action<string> SelectRoomEvent = null;
|
| | | /// <summary>
|
| | | /// 当前选择的房间的主键(楼层主键可以无视)
|
| | | /// </summary>
|
| | | public string RoomKey = string.Empty;
|
| | | /// <summary>
|
| | | /// 显示文本
|
| | | /// </summary>
|
| | | private NormalViewControl btnTextView = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 所属区域的控件
|
| | | /// </summary>
|
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
| | | public BelongAreaControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
| | | {
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件(针对的是场景)
|
| | | /// </summary>
|
| | | /// <param name="i_caption">标题文本</param>
|
| | | /// <param name="i_roomId">房间ID</param>
|
| | | public void InitControl(string i_caption, string i_roomId)
|
| | | {
|
| | | var room = HdlRoomLogic.Current.GetRoomById(i_roomId);
|
| | | this.DoInitControl(i_caption, room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件(针对的是网关)
|
| | | /// </summary>
|
| | | /// <param name="i_caption">标题文本</param>
|
| | | /// <param name="i_gateway">网关对象</param>
|
| | | public void InitControl(string i_caption, ZigBee.Device.ZbGateway i_gateway)
|
| | | {
|
| | | var room = HdlGatewayLogic.Current.GetRoomByGateway(i_gateway);
|
| | | this.DoInitControl(i_caption, room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件(针对的是回路)
|
| | | /// </summary>
|
| | | /// <param name="i_caption">标题文本</param>
|
| | | /// <param name="i_device">设备对象</param>
|
| | | public void InitControl(string i_caption, ZigBee.Device.CommonDevice i_device)
|
| | | {
|
| | | var room = HdlRoomLogic.Current.GetRoomByDevice(i_device);
|
| | | this.DoInitControl(i_caption, room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件(针对的是整个设备)
|
| | | /// </summary>
|
| | | /// <param name="i_caption">标题文本</param>
|
| | | /// <param name="i_listDevice">设备对象</param>
|
| | | public void InitControl(string i_caption, List<ZigBee.Device.CommonDevice> i_listDevice)
|
| | | {
|
| | | var room = Common.LocalDevice.Current.GeteRealDeviceRoom(i_listDevice[0]);
|
| | | this.DoInitControl(i_caption, room);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件
|
| | | /// </summary>
|
| | | /// <param name="i_caption"></param>
|
| | | /// <param name="i_Room"></param>
|
| | | private void DoInitControl(string i_caption, Common.Room i_Room)
|
| | | {
|
| | | if (i_Room == null)
|
| | | {
|
| | | //未分配区域
|
| | | this.InitControl(i_caption, Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom), false);
|
| | | }
|
| | | else
|
| | | {
|
| | | string roomName = i_Room.Name;
|
| | | this.RoomKey = i_Room.Id;
|
| | | if (Common.Config.Instance.Home.FloorDics.ContainsKey(i_Room.FloorId) == true)
|
| | | {
|
| | | //楼层+房间
|
| | | roomName = Common.Config.Instance.Home.FloorDics[i_Room.FloorId] + " " + roomName;
|
| | | }
|
| | | this.InitControl(i_caption, roomName, i_Room.IsSharedRoom);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化控件
|
| | | /// </summary>
|
| | | /// <param name="i_caption">标题文本</param>
|
| | | /// <param name="i_RoomName">房间名字</param>
|
| | | /// <param name="IsSharedRoom">房间是否是分享的</param>
|
| | | private void InitControl(string i_caption, string i_RoomName, bool IsSharedRoom)
|
| | | {
|
| | | //标题
|
| | | var btnCaption = new NormalViewControl(270, 58, true);
|
| | | btnCaption.X = ControlCommonResourse.XXLeft;
|
| | | btnCaption.Gravity = Gravity.CenterVertical;
|
| | | btnCaption.Text = i_caption + ":";
|
| | | this.AddChidren(btnCaption, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //显示框
|
| | | this.btnTextView = new NormalViewControl(700, true);
|
| | | btnTextView.X = Application.GetRealWidth(294);
|
| | | btnTextView.Gravity = Gravity.CenterVertical;
|
| | | btnTextView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnTextView.Text = i_RoomName;
|
| | | this.AddChidren(btnTextView, ChidrenBindMode.BindEvent);
|
| | |
|
| | | if (chidrenYaxis != 0)
|
| | | {
|
| | | btnCaption.Y += chidrenYaxis;
|
| | | btnTextView.Y += chidrenYaxis;
|
| | | }
|
| | |
|
| | | if (IsSharedRoom == true)
|
| | | {
|
| | | //如果这个设备位于分享的房间
|
| | | this.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | |
|
| | | //右箭头
|
| | | this.AddRightArrow();
|
| | |
|
| | | //如果当前是展示模板,则需要处理
|
| | | if (Common.Config.Instance.Home.IsShowTemplate == false)
|
| | | {
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //区域选择
|
| | | this.ShowSelectRoom(btnTextView, i_caption);
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 区域选择___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 区域选择
|
| | | /// </summary>
|
| | | /// <param name="txtView"></param>
|
| | | /// <param name="i_caption"></param>
|
| | | private void ShowSelectRoom(NormalViewControl txtView, string i_caption)
|
| | | {
|
| | | //显示底部弹窗的房间列表
|
| | | var result = HdlControlLogic.Current.ShowBottomListRoomView(this.RoomKey, i_caption, (selectId, selectName) =>
|
| | | {
|
| | | this.RoomKey = selectId;
|
| | | txtView.Text = selectName;
|
| | | //调用回调函数
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | | });
|
| | | if (result == false)
|
| | | {
|
| | | //或者根本就没有创建房间,则不允许更改
|
| | | this.UseClickStatu = false;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 刷新控件___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 重新刷新控件
|
| | | /// </summary>
|
| | | /// <param name="i_RoomId">指定以哪个房间ID刷新控件</param>
|
| | | public void RefreshControl(string i_RoomId)
|
| | | {
|
| | | this.RoomKey = i_RoomId;
|
| | |
|
| | | var room = HdlRoomLogic.Current.GetRoomById(i_RoomId);
|
| | | this.btnTextView.Text = HdlRoomLogic.Current.GetRoomName(room);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 控件摧毁___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 控件摧毁
|
| | | /// </summary>
|
| | | public override void RemoveFromParent()
|
| | | {
|
| | | this.SelectRoomEvent = null;
|
| | |
|
| | | base.RemoveFromParent();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|