Esempio n. 1
0
 private void contactList_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         if (contactList.SelectedNode != null)
         {
             ContactGroup group = contactList.SelectedNode.Tag as ContactGroup;
             if (group != null)
             {
                 cl.Groups.Remove(group);
             }
             else
             {
                 Contact contact = contactList.SelectedNode.Tag as Contact;
                 if (contact != null)
                 {
                     group = contactList.SelectedNode.Parent.Tag as ContactGroup;
                     if (group == null)
                     {
                         cl.Contacts.Remove(contact);
                     }
                     else
                     {
                         group.Remove(contact);
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
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 ();
                }
            }
        }