private Dictionary<UserInfo, long> userTimeouts; // for removing expired users #endregion Fields #region Constructors public LobbyForm(Lobby lobby) { InitializeComponent(); this.lobby = lobby; this.userGames = new Dictionary<UserInfo, ICollection<String>>(); this.nicknameTextBox.Text = Options.nickname; this.currentUser = new UserInfo(Options.nickname); this.lobby.OnMessageReveived += lobby_OnMessageReveived; // GUI Config tabPageAll = new ChatTabPage("Broadcast"); tabPageAll.Text = "All:"; this.tabControlChat.TabPages.Add(tabPageAll); this.messageTextBox.KeyDown += new KeyEventHandler(delegate(object o, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { sendMessageButton.PerformClick(); } }); this.gamesListBox.ContextMenu = new ContextMenu(); this.gamesListBox.ContextMenu.MenuItems.Add(0, new MenuItem("Join Game Channel", delegate(object o, EventArgs e) { ChatTabPage t = joinChannel(this.gamesListBox.SelectedItem.ToString()); t.Select(); })); /****************************************************************************************** * Check every second for expiring users *****************************************************************************************/ /* this.expiringTimer = new Timer(); this.expiringTimer.Interval = Options.EXPIRING_INTERVAL_CHECK; this.expiringTimer.Tick += delegate(object o, EventArgs e) { userTimeouts. foreach(KeyValuePair<UserInfo, long> k in userTimeouts) { if (k.Value > CurrentMillis.Millis) { userTimeouts. } } }; this.expiringTimer.Start(); */ }
private ChatTabPage joinChannel(string channel) { ChatTabPage chatTabPage = null; // get existing tab page foreach(TabPage t in tabControlChat.TabPages) { if (((ChatTabPage)t).Channel == channel) { chatTabPage = (ChatTabPage)t; break; } } // or create a new one if (chatTabPage == null) { chatTabPage = new ChatTabPage(channel); this.tabControlChat.TabPages.Add(chatTabPage); } return chatTabPage; }
private void AddChat(int chatId, List<User> users) { CurrentChats.Invoke((MethodInvoker)(() => { ChatTabPage chat = new ChatTabPage(chatId, users, CurrentClient.ClientName); chat.MessageCreated += chat_MessageCreated; chat.ChatRequestCreated += chat_ChatRequestCreated; chat.UserNameChanged += UsernameChangeRequest; chat.BackColor = ColorTranslator.FromHtml("#6B260B"); CurrentChats.TabPages.Add(chat); chat.UserList.Columns[0].Width = chat.UserList.ClientRectangle.Width; if (chatId == 1) { //CurrentLobby.AcceptButton = chat.SendButton; chat.IsVisible = true; } if (users == null) { CurrentClient.Send("userlist<" + chatId + ">:"); } else { chat.RefreshUserList(); } })); }