コード例 #1
0
        //handles when a ContactControl is clicked, the controller will load the message history
        public void contactPanelClicked(object sender, EventArgs e)
        {
            showMessagePanel();
            ContactControl contact   = (ContactControl)sender; //typecast sender
            int            contactID = contact.ID;             //get iD from control

            controller.loadMessages(contactID);                //sends ID to controller so it can load message history and create ClientComponent
            //Console.WriteLine($"contact clicked: ID {contactID}");
        }
コード例 #2
0
        //form controls (called by controller) //

        //takes a list of contacts and creates panels to display them in the contactsPanel
        public void displayContacts(List <Contact> contacts)
        {
            int contactControlCount = 0;

            contactsPanel.Controls.Clear();       //clears and then recreates
            foreach (Contact contact in contacts) //iterate over contact objects
            {
                ContactControl newContact = new ContactControl(contact.ID, contact.contactName);
                newContact.Click += new EventHandler(contactPanelClicked); //sets event handler

                newContact.Size = new Size(300, 100);

                newContact.Location = new Point(30, contactControlCount * 110); //moves each successive control down so they don't overlap
                contactControlCount++;

                contactsPanel.Controls.Add(newContact);
            }
        }