private void listaContactos_DoubleClick(object sender, EventArgs e) { KeyValuePair <string, bool> contactSelected = (KeyValuePair <string, bool>)listaContactos.SelectedItems[0].Tag; if (contactSelected.Value) { VentanaDeChat vt = CreateChatWindow(contactSelected.Key); vt.Show(); } else { MessageBox.Show("No es posible chatear con " + contactSelected.Key + ", esta desconectado.", "Contacto Desconectado", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
void EventChatMessageReceived(object sender, ChatMessageEventArgs e) { this.BeginInvoke((Action)(delegate { if (this.chatWindows.ContainsKey(e.ClientFrom)) { //ya estaba chateando con ese cliente chatWindows[e.ClientFrom].WriteMessage(e); } else { //una nueva ventana de chat VentanaDeChat vt = CreateChatWindow(e.ClientFrom); vt.WriteMessage(e); vt.Show(); } })); }
private VentanaDeChat CreateChatWindow(string chattingWith) { VentanaDeChat vt; if (chatWindows.ContainsKey(chattingWith)) { vt = chatWindows[chattingWith]; } else { vt = new VentanaDeChat(chattingWith, this); chatWindows.Add(chattingWith, vt); } if (vt != null) { vt.Focus(); } return(vt); }