Esempio n. 1
0
        /// <summary>
        /// Convert item to node.
        /// </summary>
        /// <returns>The node.</returns>
        /// <param name="item">Item.</param>
        protected virtual TreeNode <UInvitePlayGameTreeItemData> Item2Node(UInvitePlayGameTreeViewDataSource item)
        {
            var nodeItem = new UInvitePlayGameTreeItemData(item.Name, item.Icon);

            nodeItem.Tag         = item.Tag;
            nodeItem.Name        = item.Name;
            nodeItem.nUserID     = item.nUserID;
            nodeItem.nGroupID    = item.nGroupID;
            nodeItem.isSelected  = false;
            nodeItem.nGameState  = item.nGameState;
            nodeItem.nHeadIconID = item.nHeadIconID;
            nodeItem.nRank       = item.nRank;
            nodeItem.RankName    = item.RankName;
            nodeItem.nSex        = item.nSex;
            nodeItem.isInvited   = item.bIsInvited;
            nodeItem.isCanInvite = item.isCanInvite;

            return(new TreeNode <UInvitePlayGameTreeItemData>(nodeItem, new ObservableList <TreeNode <UInvitePlayGameTreeItemData> >(), item.IsExpanded, item.IsVisible));
        }
Esempio n. 2
0
        /// <summary>
        /// 显示主面板
        /// </summary>
        public void updateContent()
        {
            // 设置好友列表内容
            Data.Clear();

            Dictionary <string, List <InvitePlayGamePlayerInfo> > groups = new Dictionary <string, List <InvitePlayGamePlayerInfo> >();

            // 在线好友
            int nTotal = 0, nCanInvite = 0;
            List <InvitePlayGamePlayerInfo> group1 = new List <InvitePlayGamePlayerInfo>();

            foreach (var item in LogicDataCenter.snsDataManager.getOnlineBuddy())
            {
                string actorName = getBuddyName(item);

                if (isMatchSearchName(actorName) == false)
                {
                    continue;
                }

                InvitePlayGamePlayerInfo info = new InvitePlayGamePlayerInfo();
                info.nGroupID    = (int)InvitePlayGameGroup.emBuddyGroup;
                info.nUserID     = item.Info.nUserID;
                info.nGameState  = item.Info.nStatus;
                info.ActorName   = actorName;
                info.nHeadIconID = item.Info.dwHeadID;
                info.nRankIconID = item.Info.nRankIconID;
                info.RankName    = item.Info.szRankName;
                info.nSex        = item.Info.nSex;
                info.isInvited   = isInvitedPlayer(info.nUserID);
                info.isCanInvite = isCanInvite(info);

                if (info.isCanInvite)
                {
                    nCanInvite++;
                }
                nTotal++;

                group1.Add(info);
            }
            string groupName1 = String.Format("{0} {1}/{2}", ULocalizationService.Instance.Get("UIView", "Common", "OnlineBuddy"), nCanInvite, nTotal);

            group1.Sort();
            groups.Add(groupName1, group1);

            // 战队
            nTotal = nCanInvite = 0;
            List <InvitePlayGamePlayerInfo> group2 = new List <InvitePlayGamePlayerInfo>();

            foreach (var item in LogicDataCenter.kinDataManager.KinMemberList)
            {
                if (item.dwPDBID == 0)
                {
                    continue;
                }

                // 排除自己
                if (item.dwPDBID == EntityUtil.getMainHeroPdbid())
                {
                    continue;
                }

                // 排除离线
                if (item.bIsOnline == 0)
                {
                    continue;
                }

                string actorName = item.szName;

                if (isMatchSearchName(actorName) == false)
                {
                    continue;
                }

                InvitePlayGamePlayerInfo info = new InvitePlayGamePlayerInfo();
                info.nUserID     = item.dwUDBID;
                info.nGroupID    = (int)InvitePlayGameGroup.emKinGroup;
                info.nGameState  = item.byGameState;
                info.ActorName   = actorName;
                info.nHeadIconID = item.nFaceID;
                info.nRankIconID = 0;
                info.RankName    = item.szGradeName;
                info.nSex        = item.nSex;
                info.isInvited   = isInvitedPlayer(info.nUserID);
                info.isCanInvite = isCanInvite(info);

                if (info.isCanInvite)
                {
                    nCanInvite++;
                }
                nTotal++;

                group2.Add(info);
            }
            string groupName2 = String.Format("{0} {1}/{2}", ULocalizationService.Instance.Get("UIView", "Common", "Team"), nCanInvite, nTotal);

            group2.Sort();
            groups.Add(groupName2, group2);

            // 附近的人
            nTotal = nCanInvite = 0;
            List <InvitePlayGamePlayerInfo> group3 = new List <InvitePlayGamePlayerInfo>();

            foreach (var item in LogicDataCenter.snsDataManager.getNearbyPlayer())
            {
                string actorName = item.Info.szName;

                if (isMatchSearchName(actorName) == false)
                {
                    continue;
                }

                InvitePlayGamePlayerInfo info = new InvitePlayGamePlayerInfo();
                info.nGroupID    = (int)InvitePlayGameGroup.emNearbyGroup;
                info.nUserID     = item.Info.nUserID;
                info.nGameState  = item.Info.nStatus;
                info.ActorName   = item.Info.szName;
                info.nHeadIconID = item.Info.dwHeadID;
                info.nRankIconID = item.Info.nRankIconID;
                info.RankName    = item.Info.szRankName;
                info.nSex        = item.Info.nSex;
                info.isInvited   = isInvitedPlayer(info.nUserID);
                info.isCanInvite = isCanInvite(info);

                if (info.isCanInvite)
                {
                    nCanInvite++;
                }
                nTotal++;

                group3.Add(info);
            }
            string groupName3 = String.Format("{0} {1}/{2}", ULocalizationService.Instance.Get("UIView", "Common", "NearbyPeople"), nCanInvite, nTotal);

            group3.Sort();
            groups.Add(groupName3, group3);

            foreach (var group in groups)
            {
                // 添加一个分组
                UInvitePlayGameTreeViewDataSource data = new UInvitePlayGameTreeViewDataSource();
                data.Depth      = 0;
                data.IsExpanded = true;
                data.Name       = group.Key;

                Data.Add(data);

                // 添加该分组的玩家
                foreach (var player in group.Value)
                {
                    data             = new UInvitePlayGameTreeViewDataSource();
                    data.Depth       = 1;
                    data.nGroupID    = player.nGroupID;
                    data.nUserID     = player.nUserID;
                    data.nGameState  = player.nGameState;
                    data.Name        = player.ActorName;
                    data.nHeadIconID = player.nHeadIconID;
                    data.nRank       = player.nRankIconID;
                    data.RankName    = player.RankName;
                    data.nSex        = player.nSex;
                    data.bIsInvited  = player.isInvited;
                    data.isCanInvite = player.isCanInvite;

                    Data.Add(data);
                }
            }

            setInvitePlayGameTreeViewDataSource();
        }