Пример #1
0
        private void contactList_DoubleClick(object sender, System.EventArgs e)
        {
            TreeNode selectedNode = contactList.SelectedNode;

            if (selectedNode != null)
            {
                if (selectedNode.ForeColor == Color.Green)
                {
                    Contact contact = selectedNode.Tag as Contact;
                    if (contact != null)
                    {
                        ChatForm chatForm = new ChatForm(this, rtp, contact.RealTimeAddress);
                        chatForm.Show();
                    }
                }

                else if (selectedNode.ForeColor == Color.Gray)
                {
                    if (selectedNode.Parent == null)
                    {
                        AddGroupDialog addGroupDialog = new AddGroupDialog();
                        if (addGroupDialog.ShowDialog() == DialogResult.OK)
                        {
                            ContactGroup newGroup = cl.Groups.CreateContactGroup(addGroupDialog.groupName.Text);
                            try {
                                cl.Groups.Add(newGroup);
                            }
                            catch (Exception) {
                            }
                        }
                    }
                    else
                    {
                        ContactGroup     group            = selectedNode.Parent.Tag as ContactGroup;
                        AddContactDialog addContactDialog = new AddContactDialog();
                        if (addContactDialog.ShowDialog() == DialogResult.OK)
                        {
                            Contact newContact = cl.Contacts.CreateContact(addContactDialog.realTimeAddress.Text,
                                                                           addContactDialog.displayName.Text,
                                                                           true);
                            try {
                                cl.Contacts.Add(newContact);
                                if (group != null)
                                {
                                    group.Add(newContact);
                                }
                            }
                            catch (Exception) {
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void rtp_SessionReceived(object sender, System.Collaboration.IncomingSessionEventArgs e)
        {
            ChatForm chatForm = new ChatForm(this, rtp, e.Session);

            chatForm.Show();
        }