| | |
| | | /// </summary>
|
| | | public string RoomKey = string.Empty;
|
| | | /// <summary>
|
| | | /// 当前选择的楼层主键(没必要公开出去)
|
| | | /// 显示文本
|
| | | /// </summary>
|
| | | private string FloorKey = string.Empty;
|
| | | /// <summary>
|
| | | /// 楼层列表名字
|
| | | /// </summary>
|
| | | private List<string> listFloorName = new List<string>();
|
| | | /// <summary>
|
| | | /// 楼层列表主键
|
| | | /// </summary>
|
| | | private List<string> listFloorKeys = new List<string>();
|
| | | /// <summary>
|
| | | /// 房间名字
|
| | | /// </summary>
|
| | | private List<List<string>> listRoomName = new List<List<string>>();
|
| | | /// <summary>
|
| | | /// 房间主键
|
| | | /// </summary>
|
| | | private List<List<string>> listRoomKeys = new List<List<string>>();
|
| | | private NormalViewControl btnTextView = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
|
| | | public BelongAreaControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
|
| | | {
|
| | | //初始化数据
|
| | | this.InitData();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | {
|
| | | string roomName = i_Room.Name;
|
| | | this.RoomKey = i_Room.Id;
|
| | | this.FloorKey = i_Room.FloorId;
|
| | | if (Common.Config.Instance.Home.FloorDics.ContainsKey(i_Room.FloorId) == true)
|
| | | {
|
| | | //楼层+房间
|
| | |
| | | this.AddChidren(btnCaption, ChidrenBindMode.BindEvent);
|
| | |
|
| | | //显示框
|
| | | var txtView = new NormalViewControl(700, true);
|
| | | txtView.X = Application.GetRealWidth(294);
|
| | | txtView.Gravity = Gravity.CenterVertical;
|
| | | txtView.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | txtView.Text = i_RoomName;
|
| | | this.AddChidren(txtView, 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;
|
| | | txtView.Y += chidrenYaxis;
|
| | | btnTextView.Y += chidrenYaxis;
|
| | | }
|
| | |
|
| | | if (IsSharedRoom == true)
|
| | |
| | | this.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | | if (this.listFloorKeys.Count == 0 && listRoomKeys.Count == 0)
|
| | | {
|
| | | //或者根本就没有创建房间,则不允许更改
|
| | | this.UseClickStatu = false;
|
| | | return;
|
| | | }
|
| | |
|
| | | //右箭头
|
| | | this.AddRightArrow();
|
| | |
|
| | | this.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //区域选择
|
| | | this.ShowSelectRoom(txtView, i_caption);
|
| | | this.ShowSelectRoom(btnTextView, i_caption);
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化数据
|
| | | /// </summary>
|
| | | private void InitData()
|
| | | {
|
| | | var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
|
| | | if (dicFloor.Count == 0)
|
| | | {
|
| | | //第一位默认添加未分配
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { Language.StringByID(R.MyInternationalizationString.uUndistributed) };
|
| | | //房间名字和主键收集
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(string.Empty, false);
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | else
|
| | | {
|
| | | //第一位默认添加未分配(未分配放在楼层那个菜单)
|
| | | var listKeys = new List<string>() { "" };
|
| | | var listName = new List<string>() { "" };
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | this.listFloorKeys.Add("");
|
| | | this.listFloorName.Add(Language.StringByID(R.MyInternationalizationString.uUndistributed));
|
| | |
|
| | | foreach (string fKeys in dicFloor.Keys)
|
| | | {
|
| | | var listRoom = HdlRoomLogic.Current.GetFloorSortRoom(fKeys, false);
|
| | | if (listRoom.Count > 0)
|
| | | {
|
| | | //楼层名字和主键收集
|
| | | this.listFloorKeys.Add(fKeys);
|
| | | this.listFloorName.Add(dicFloor[fKeys]);
|
| | | //房间名字和主键收集
|
| | | listName = new List<string>();
|
| | | listKeys = new List<string>();
|
| | | foreach (var myRoom in listRoom)
|
| | | {
|
| | | listName.Add(myRoom.Name);
|
| | | listKeys.Add(myRoom.Id);
|
| | | }
|
| | | listRoomName.Add(listName);
|
| | | listRoomKeys.Add(listKeys);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="i_caption"></param>
|
| | | private void ShowSelectRoom(NormalViewControl txtView, string i_caption)
|
| | | {
|
| | | int index1 = this.listFloorKeys.IndexOf(FloorKey);
|
| | | if (index1 == -1) { index1 = 0; }
|
| | | int index2 = this.listRoomKeys[index1].IndexOf(RoomKey);
|
| | | if (index2 == -1) { index2 = 0; }
|
| | |
|
| | | if (this.listFloorKeys.Count == 0)
|
| | | //显示底部弹窗的房间列表
|
| | | var result = HdlControlLogic.Current.ShowBottomListRoomView(this.RoomKey, i_caption, (selectId, selectName) =>
|
| | | {
|
| | | //无楼层模式
|
| | | PickerView.Show(this.listRoomName[0], (value) =>
|
| | | {
|
| | | RoomKey = this.listRoomKeys[0][value];
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //房间
|
| | | txtView.Text = this.listRoomName[0][value];
|
| | | }
|
| | | else
|
| | | {
|
| | | txtView.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | |
|
| | | }, index2, i_caption,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | }
|
| | | else
|
| | | this.RoomKey = selectId;
|
| | | txtView.Text = selectName;
|
| | | //调用回调函数
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | | });
|
| | | if (result == false)
|
| | | {
|
| | | //有楼层模式
|
| | | PickerView.ShowSecondary(this.listFloorName, this.listRoomName, (value1, value2) =>
|
| | | {
|
| | | FloorKey = this.listFloorKeys[value1];
|
| | | RoomKey = this.listRoomKeys[value1][value2];
|
| | | if (RoomKey != string.Empty)
|
| | | {
|
| | | //楼层+房间
|
| | | txtView.Text = this.listFloorName[value1] + " " + this.listRoomName[value1][value2];
|
| | | }
|
| | | else
|
| | | {
|
| | | txtView.Text = Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
|
| | | }
|
| | | this.SelectRoomEvent?.Invoke(RoomKey);
|
| | |
|
| | | }, index1, index2, i_caption,
|
| | | Language.StringByID(R.MyInternationalizationString.uFinish),
|
| | | Language.StringByID(R.MyInternationalizationString.uCancel));
|
| | | //或者根本就没有创建房间,则不允许更改
|
| | | 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>
|