Пример #1
0
        void Chat_MembersUpdate()
        {
            MemberTree.BeginUpdate();

            MemberTree.Nodes.Clear();
            NodeMap.Clear();

            List <ulong> users = new List <ulong>();

            Room.Members.LockReading(delegate()
            {
                if (Room.Members.SafeCount == 0)
                {
                    MemberTree.EndUpdate();
                    return;
                }

                users = Room.Members.ToList();

                TreeListNode root = MemberTree.virtualParent;

                if (Room.Host != 0)
                {
                    root = new MemberNode(this, Room.Host);

                    if (Room.IsLoop)
                    {
                        ((MemberNode)root).IsLoopRoot = true;
                    }
                    else
                    {
                        NodeMap[Room.Host] = root as MemberNode;
                    }

                    UpdateNode(root as MemberNode);

                    MemberTree.Nodes.Add(root);
                    root.Expand();
                }

                foreach (ulong id in Room.Members)
                {
                    if (id != Room.Host)
                    {
                        // if they left the room dont show them
                        if (!ChatService.IsCommandRoom(Room.Kind))
                        {
                            if (Room.Members.SafeCount == 0)
                            {
                                continue;
                            }
                        }

                        MemberNode node = new MemberNode(this, id);
                        NodeMap[id]     = node;
                        UpdateNode(node);
                        GuiUtils.InsertSubNode(root, node);
                    }
                }
            });

            MemberTree.EndUpdate();

            if (VoiceButton != null)
            {
                AudioDirection direction = AudioDirection.Both;

                if (ParentView.ViewHigh != null && ParentView.ViewLow != null)
                {
                    if (Room.Kind == RoomKind.Command_High || Room.Kind == RoomKind.Live_High)
                    {
                        direction = AudioDirection.Left;
                    }

                    else if (Room.Kind == RoomKind.Command_Low || Room.Kind == RoomKind.Live_Low)
                    {
                        direction = AudioDirection.Right;
                    }
                }

                VoiceButton.SetUsers(users, direction);
            }
        }