Ejemplo n.º 1
0
        private void contactList_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            if (draggingContact != null)
            {
                Point p = new Point(e.X, e.Y);
                p = contactList.PointToClient(p);

                TreeNode node = contactList.GetNodeAt(p.X, p.Y);

                if (node != null && node.Parent == null)
                {
                    ContactGroup group = node.Tag as ContactGroup;

                    if (draggingFromGroup != group)
                    {
                        if (draggingFromGroup != null)
                        {
                            draggingFromGroup.Remove(draggingContact);
                        }
                        if (group != null)
                        {
                            group.Add(draggingContact);
                        }
                    }

                    //node.Expand ();
                }
            }
        }
Ejemplo n.º 2
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) {
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void AddGroupMember(UserModel groupMember)
        {
            if (this.Contains(groupMember))
            {
                return;
            }

            this.nonGroupedMembers.Add(groupMember);

            char firstLetter = char.ToLower(groupMember.Name[0]);

            // show # for numbers
            if (firstLetter >= '0' && firstLetter <= '9')
            {
                firstLetter = '#';
            }

            bool found = false;

            foreach (ContactGroup <UserModel> memberGroup in this.members)
            {
                // create group for letter if it doesn't exist
                if (memberGroup.FirstLetter == firstLetter)
                {
                    found = true;
                    memberGroup.Add(groupMember);
                }
            }

            if (!found)
            {
                var memberGroup = new ContactGroup <UserModel>(firstLetter);
                memberGroup.Add(groupMember);

                this.members.Add(memberGroup);
            }
        }
Ejemplo n.º 4
0
        private void AddGroup(GroupModel group)
        {
            if (this.Contains(group))
            {
                return;
            }

            char firstLetter = char.ToLower(group.Name[0]);

            // show # for numbers
            if (firstLetter >= '0' && firstLetter <= '9')
            {
                firstLetter = '#';
            }

            bool found = false;

            foreach (ContactGroup <GroupModel> alphaGroup in this.groups)
            {
                // create group for letter if it doesn't exist
                if (alphaGroup.FirstLetter == firstLetter)
                {
                    found = true;
                    alphaGroup.Add(group);
                }
            }

            if (!found)
            {
                var alphaGroup = new ContactGroup <GroupModel>(firstLetter);
                this.groups.Add(alphaGroup);

                // create a contact for item and add it to the relevant
                alphaGroup.Add(group);
            }
        }
Ejemplo n.º 5
0
        private void AddGroup(GroupModel group)
        {
            if (this.Contains(group))
            {
                return;
            }

            char firstLetter = char.ToLower(group.Name[0]);

            // show # for numbers
            if (firstLetter >= '0' && firstLetter <= '9')
            {
                firstLetter = '#';
            }

            bool found = false;
            foreach (ContactGroup<GroupModel> alphaGroup in this.groups)
            {
                // create group for letter if it doesn't exist
                if (alphaGroup.FirstLetter == firstLetter)
                {
                    found = true;
                    alphaGroup.Add(group);
                }
            }

            if (!found)
            {
                var alphaGroup = new ContactGroup<GroupModel>(firstLetter);
                this.groups.Add(alphaGroup);

                // create a contact for item and add it to the relevant
                alphaGroup.Add(group);
            }
        }