Beispiel #1
0
 /// <summary>
 /// 加载并显示用户列表信息
 /// </summary>
 /// <param name="listUserInfo">需要显示的信息集合</param>
 public void LoadAndShowUserListInfo(IList <UserData> listUserInfo)
 {
     // 清空列表信息
     ClearItems();
     // 实例化与显示列表信息
     foreach (UserData userdata in listUserInfo)
     {
         UserList_Item tmp = InitUserInfo(); // 克隆预设体
         tmp.DisplayUserItem(userdata);      // 预设体显示信息
         _userInfoList.Add(tmp);
     }
     // 统计数量
     _txtUsersCount.text = _userInfoList.Count.ToString();
 }
Beispiel #2
0
        /// <summary>
        /// 实例化用户信息 克隆信息的载体
        /// </summary>
        /// <returns></returns>
        private UserList_Item InitUserInfo()
        {
            UserList_Item tmp = null;

            if (_userInfoPrefab != null)
            {
                // 实例化
                tmp = GameObject.Instantiate <UserList_Item>(_userInfoPrefab, Vector3.zero, Quaternion.identity, _userInfoParent);
                tmp.transform.localScale = Vector3.one;
                tmp.gameObject.SetActive(true);
                tmp.GetComponent <Toggle>().group = _userInfoParent.GetComponent <ToggleGroup>();
            }
            return(tmp);
        }
Beispiel #3
0
        /// <summary>
        /// 处理所有关注的 “消息”
        /// </summary>
        /// <param name="notification"></param>
        public override void HandleNotification(INotification notification)
        {
            switch (notification.Name)
            {
            // 调用初始化方法
            case Proconst.MSG_INIT_USERLIST_MEDIATOR:
            {
                UserList tmp = notification.Body as UserList;
                InitUserListMediator(tmp);
                break;
            }

            // 处理用户选择 “用户记录”
            case Proconst.MSG_SELECT_USERINFO_TO_USERLIST_MEDIATOR:
            {
                UserList_Item tmp = notification.Body as UserList_Item;
                HandlerSelectUserInfo(tmp);
                break;
            }

            // 处理 从 UserForm 发来的消息:增加新用户
            case Proconst.MSG_ADDNEWUSERIBFO_TOUSERLIST_MEDIATOR:
            {
                UserData tmp = notification.Body as UserData;
                SubmitNewUserInfo(tmp);
                UserList.FreezeDeleteBtn();
                break;
            }

            // 处理 从 UserForm 发来的消息:更新用户信息
            case Proconst.MSG_UPDATEUSERINFO_TOUSERLIST_MEDIATOR:
            {
                UserData tmp = notification.Body as UserData;
                SubmitUpdateUserInfo(tmp);
                UserList.FreezeDeleteBtn();
                break;
            }

            case Proconst.MSG_DONT_SELECT:
            {
                UserList.FreezeDeleteBtn();
                SendNotification(Proconst.MSG_SDDD);
                break;
            }

            default:
                break;
            }
        }
Beispiel #4
0
 /// <summary>
 /// 处理 “选择用户操作”
 /// </summary>
 private void HandlerSelectUserInfo(UserList_Item userItem)
 {
     if (userItem == null)
     {
         return;
     }
     // 保存当前选择的用户信息
     _currentUserItem = userItem;
     // 显示窗体 “删除” 按钮
     UserList.ShowFreezeDeleteBtn();
     // 发送消息到显示 “用户窗体” 的类  这里相当于一个中转站
     if (_currentUserItem.CurrentData == null)
     {
         return;
     }
     // 消息和执行体是绑定注册的,所以发送没有注册的消息,是没有任何作用的
     SendNotification(Proconst.MSG_SELECT_USERINFO_TO_USERFORM_MEDIATOR, _currentUserItem.CurrentData);
 }
Beispiel #5
0
        void Awake()
        {
            // 加载预设
            _userInfoPrefab = Resources.Load <GameObject>(Proconst.PATH_UIPREFABS + "/" + Proconst.PATH_TOGGLE)
                              .GetComponent <UserList_Item>();
            // 初始化父对象
            _userInfoParent = UnityHelper.FindTheChildNode(this.gameObject, Proconst.GRID_INFO);
            _txtUsersCount  = UnityHelper.FindTheChildNode(this.gameObject, Proconst.TXT_USER_COUNT).GetComponent <Text>();
            _btn_New        = UnityHelper.FindTheChildNode(this.gameObject, Proconst.BTN_NEW_USER).GetComponent <Button>();
            _btn_Delete     = UnityHelper.FindTheChildNode(this.gameObject, Proconst.BTN_DELETE_USER).GetComponent <Button>();
            // 初始化字段
            _txtUsersCount.text = "0";

            // 按钮事件
            _btn_New.onClick.AddListener(ClickBtn_New);
            _btn_Delete.onClick.AddListener(ClickBtn_Delete);

            // 初始化按钮的显示
            FreezeDeleteBtn();
        }