private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (!isWindowClosing)
            {
                isWindowClosing = true;

                ManageChatWindows.RemoveChatWindow(this);
            }
        }
Example #2
0
        public void RemoveContact(string userID)
        {
            lock (contactListView)
            {
                for (int i = 0; i < contactListView.Items.Count; i++)
                {
                    if (contactListView.Items[i].GetType() == typeof(RichTextBox))
                    {
                        if (((RichTextBox)contactListView.Items[i]).Tag.ToString() == userID)
                        {
                            ManageChatWindows.RemoveChatWindow(userID);

                            contactListView.Items.Remove(((RichTextBox)contactListView.Items[i]));
                            UpdateContactCount();

                            ContactListEntryData contactListData = null;
                            UserInfo             user            = null;
                            foreach (ContactListEntryData contactData in listContacts)
                            {
                                if (contactData.richTextBox.Tag.ToString() == userID)
                                {
                                    contactListData = contactData;
                                    break;
                                }
                            }

                            foreach (UserInfo userData in Personal.USER_CONTACTS)
                            {
                                if (userData.id == userID)
                                {
                                    user = userData;
                                    break;
                                }
                            }

                            if (user != null)
                            {
                                lock (Personal.USER_CONTACTS)
                                {
                                    Personal.USER_CONTACTS.Remove(user);
                                }
                            }

                            if (contactListData != null)
                            {
                                lock (listContacts)
                                {
                                    listContacts.Remove(contactListData);
                                }
                            }

                            UpdateContactCount();
                        }
                    }
                }
            }
        }
        public void CloseWindow()
        {
            if (!isWindowClosing)
            {
                isWindowClosing = true;

                ManageChatWindows.RemoveChatWindow(this);

                this.Close();
            }
        }