private void addRoomBtn_Click(object sender, EventArgs e) { UnsavedData = true; AddRoomForm arf = new AddRoomForm(); arf.ShowDialog(); LoadRooms(); }
private void AddRoomButton_Click(object sender, EventArgs e) { using (var addRoomForm = new AddRoomForm()) { if (addRoomForm.ShowDialog() == DialogResult.OK) { bool foundExistingRoom = false; foreach (Room room in _ViewModel.Rooms) { if (room.Name.Equals(addRoomForm.RoomName, StringComparison.InvariantCultureIgnoreCase)) { foundExistingRoom = true; } } if (foundExistingRoom == false) { _ViewModel.Rooms.Add(new Room(addRoomForm.RoomName)); if (_ViewModel.StartingLocation == null) { _ViewModel.StartingLocation = addRoomForm.RoomName; _startingLocationList = new List <Room>(_ViewModel.Rooms); startingLocationBox.DataSource = _startingLocationList; startingLocationBox.SelectedIndex = startingLocationBox.FindString(addRoomForm.RoomName); } else { _startingLocationList.Add(new Room(addRoomForm.RoomName)); } startingLocationBox.DataSource = null; startingLocationBox.DataSource = _startingLocationList; InitalizeViewModels(); } else { MessageBox.Show($"Room named \"{addRoomForm.RoomName}\" already exists."); } } } }
private void BtnAdd_Click(object sender, EventArgs e) { AddRoomForm addRoom = new AddRoomForm(); addRoom.ShowDialog(); }