private void CreateChooseContactWindow(object sender, EventArgs eventArgs) { var nameContact = _newContactWindow.GetName(); var contacts = _connection.AddContact(nameContact); if (contacts.Count == 0) { _newContactWindow.ShowMessage("Таких контактов не найдено"); return; } _chooseContactWindow = _newContactWindow.CreateChooseContactWindow(); var namesContactList = new List <string>(); var onlineContactList = new List <string>(); foreach (var cont in contacts) { namesContactList.Add(cont.Name); if (cont.Online) { onlineContactList.Add(cont.Name); } } _chooseContactWindow.UpdateContacts(namesContactList, onlineContactList); _chooseContactWindow.ChooseContact += AddNewContactFromWindow; _chooseContactWindow.ShowWindow(); _newContactWindow.Close(); }