private void RecvMessage() { try { string strTemp = chat.ReceiveMessage(lblUserName.Text); if (strTemp.Trim().Length > 0) { if (strTemp.Substring(0, 7) == "Ser@ver") { NotifyWindow nw; nw = new NotifyWindow(strTemp.Substring(8, strTemp.Length - 9).ToString()); nw.Font = new Font("Verdana", 8.25F); nw.SetDimensions(strTemp.Length + 210, 50); nw.Notify(); //if (Form1.bNoAlert == false) // speech.Speak(strTemp.Substring(8, strTemp.Length - 9).ToString(), SpFlags); } else { strMess = strTemp; string[] strUser = strMess.Split(':'); userFlag = true; for (int i = 0; i < arrOUsers.Count; i++) { if (strUser[0] == arrOUsers[i].ToString()) userFlag = false; } if (userFlag == true) { arrOUsers.Add(strUser[0]); Form f = new PrivateMessage(strUser[0], strMess); f.Show(); } } } } catch (Exception ex) { //MessageBox.Show("Error in connecting to the chat server."); } }
private void lstUsers_DoubleClick(object sender, EventArgs e) { try { userFlag = true; // To check whether the chat window for this user is already open. for (int i = 0; i < arrOUsers.Count; i++) { if (lstUsers.FocusedItem.Text.ToString() == arrOUsers[i].ToString()) userFlag = false; } if (userFlag == true) { arrOUsers.Add(lstUsers.FocusedItem.Text.ToString()); Form f = new PrivateMessage(lstUsers.FocusedItem.Text.ToString()); f.Show(); } } catch (Exception ex) { MessageBox.Show("Error in connecting to the chat server. Please try again."); } }