//Start Dinu! TODO improve void ReceiveMessage(string username, string message, DateTime date) { if (Application.OpenForms[0].InvokeRequired) { ReceiveMessageCallback d = new ReceiveMessageCallback(ReceiveMessage); this.Invoke(d, new object[] { username, message, date }); } else { if (username != null && username != "" && message != null && message != "") { foreach (Form OpenForm in Application.OpenForms) { if (OpenForm is Conversation) { Conversation temp = (Conversation)OpenForm; if (username == temp.id) { // OpenForm.TopMost = true; OpenForm.Focus(); temp.Receive_Msg_Auto(message, date); // MessageBox.Show("Found"); return; } } } //TODO send maybe my name and my/other logo rethink Conversation convFriend = new Conversation(_chatClient, username, null, username, "Tmp Status"); //TODO modify convFriend.Show(); convFriend.Receive_Msg_Auto(message, date); // MessageBox.Show("Created new"); } } // Console.WriteLine("Received Message from: {0} \nMessage: {1}", username, message); }
private void DoubleClick_Friend(object sender, EventArgs e) { Conversation pointerToForm = (Conversation)Application.OpenForms["Conversation"]; ListView lw = (ListView)sender; ListViewItem lwi = lw.SelectedItems[0]; ListViewItem.ListViewSubItem lws = lwi.SubItems[1]; foreach (Form OpenForm in Application.OpenForms) { if (OpenForm is Conversation) { Conversation temp = (Conversation)OpenForm; if (lws.Text == temp.id) { OpenForm.Focus(); return; } } } // int ok = 1; // foreach (string temp in idNames) // { // if (temp == lws.Text) // { // ok = 0; // break; // } // } // if (ok == 1) // { // idNames.Add(lws.Text); string name = listView1.SelectedItems[0].SubItems[1].Text; string statusMes = listView1.SelectedItems[0].SubItems[2].Text; Conversation conv = new Conversation(_chatClient, lws.Text, myLogo, name, statusMes); conv.Show(); }