Пример #1
0
        void UpdateNode(MemberNode node)
        {
            if (!Room.Members.SafeContains(node.UserID))
            {
                if (node.IsLoopRoot)
                {
                    node.Text = "Trust Loop";
                }

                return;
            }

            // get if node is connected
            bool connected = (Room.Active &&
                              (node.UserID == Core.UserID || Chat.Network.RudpControl.GetActiveSessions(node.UserID).Count > 0));

            // get away status
            bool away = false;


            foreach (ClientInfo info in Core.Locations.GetClients(node.UserID))
            {
                if (info != null && info.Data.Away)
                {
                    away = true;
                }
            }


            node.Text = Core.GetName(node.UserID);

            if (away)
            {
                node.Text += " [away]";
            }


            // bold if local
            if (node.UserID == Core.UserID)
            {
                node.Font = new Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            }


            // color based on connect status
            Color foreColor = connected ? Color.Black : Color.Gray;

            if (node.ForeColor == foreColor)
            {
                MemberTree.Invalidate();
                return; // no change
            }

            /*if (!node.Unset) // on first run don't show everyone as joined
             * {
             *  string message = "";
             *
             *  if (connected)
             *      message = Core.GetName(node.UserID) + " has joined the room";
             *  else
             *      message = Core.GetName(node.UserID) + " has left the room";
             *
             *
             *  // dont log
             *  Chat_Update(new ChatMessage(Core, message, true));
             * }*/

            node.Unset = false;

            node.ForeColor = foreColor;
            MemberTree.Invalidate();
        }
Пример #2
0
        private void MemberTree_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            MemberNode node = MemberTree.GetNodeAt(e.Location) as MemberNode;

            if (node == null)
            {
                return;
            }

            if (Core.Trust != null)
            {
                Core.Trust.Research(node.UserID, 0, false);
            }

            Core.Locations.Research(node.UserID);

            ContextMenuStripEx treeMenu = new ContextMenuStripEx();

            // views
            List <MenuItemInfo> quickMenus = new List <MenuItemInfo>();
            List <MenuItemInfo> extMenus   = new List <MenuItemInfo>();

            foreach (var service in ParentView.UI.Services.Values)
            {
                if (service is TrustService || service is BuddyService)
                {
                    continue;
                }

                service.GetMenuInfo(InterfaceMenuType.Quick, quickMenus, node.UserID, Room.ProjectID);

                service.GetMenuInfo(InterfaceMenuType.External, extMenus, node.UserID, Room.ProjectID);
            }

            if (quickMenus.Count > 0 || extMenus.Count > 0)
            {
                if (treeMenu.Items.Count > 0)
                {
                    treeMenu.Items.Add("-");
                }
            }

            foreach (MenuItemInfo info in quickMenus)
            {
                treeMenu.Items.Add(new OpMenuItem(node.UserID, Room.ProjectID, info.Path, info));
            }

            if (extMenus.Count > 0)
            {
                ToolStripMenuItem viewItem = new ToolStripMenuItem("Views", InterfaceRes.views);

                foreach (MenuItemInfo info in extMenus)
                {
                    viewItem.DropDownItems.SortedAdd(new OpMenuItem(node.UserID, Room.ProjectID, info.Path, info));
                }

                treeMenu.Items.Add(viewItem);
            }

            // add trust/buddy options at bottom
            quickMenus.Clear();

            ParentView.UI.Services[ServiceIDs.Buddy].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, node.UserID, Room.ProjectID);

            if (ParentView.UI.Services.ContainsKey(ServiceIDs.Trust))
            {
                ParentView.UI.Services[ServiceIDs.Trust].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, node.UserID, Room.ProjectID);
            }

            if (quickMenus.Count > 0)
            {
                treeMenu.Items.Add("-");
                foreach (MenuItemInfo info in quickMenus)
                {
                    treeMenu.Items.Add(new OpMenuItem(node.UserID, Room.ProjectID, info.Path, info));
                }
            }

            // show
            if (treeMenu.Items.Count > 0)
            {
                treeMenu.Show(MemberTree, e.Location);
            }
        }
Пример #3
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);
            }
        }