private void MessageReceived(string from, string message) { // extract buddy ID string buddyId = parseFrom(from); // check if ChatForm already opened foreach (Form ctrl in Application.OpenForms) { if (ctrl.Name == "ChatForm") { ((ChatForm)ctrl).BuddyName = buddyId; ((ChatForm)ctrl).LastMessage = message; ctrl.Focus(); return; } } // if not, create new instance ChatForm bf = new ChatForm(SipekResources); int id = CBuddyList.getInstance().getBuddyId(buddyId); if (id >= 0) { //_buddyId = id; CBuddyRecord buddy = CBuddyList.getInstance()[id]; //_titleText.Caption = buddy.FirstName + ", " + buddy.LastName; bf.BuddyId = (int)id; } bf.BuddyName = buddyId; bf.LastMessage = message; bf.ShowDialog(); }
private void toolStripMenuItemIM_Click(object sender, EventArgs e) { if (listViewBuddies.SelectedItems.Count > 0) { ListViewItem lvi = listViewBuddies.SelectedItems[0]; ChatForm bf = new ChatForm(SipekResources); bf.BuddyId = ((CBuddyRecord)lvi.Tag).Id; bf.ShowDialog(); } }
private void sendInstantMessageToolStripMenuItem_Click(object sender, EventArgs e) { if (listViewCallRegister.SelectedItems.Count > 0) { ListViewItem lvi = listViewCallRegister.SelectedItems[0]; CCallRecord record = (CCallRecord)lvi.Tag; int id = CBuddyList.getInstance().getBuddyId(record.Number); if (id > 0) { ChatForm bf = new ChatForm(SipekResources); bf.BuddyId = id; bf.ShowDialog(); } } }