private void AddEntryWindowClosed(object sender, EventArgs e, string slotid) { if (VehicleEntry.EntryAdded) { ParkFloorViewModel floorVM = (ParkFloorViewModel)this.DataContext; floorVM.UpdateOccupiedStatusInModel(slotid, true); VehicleEntry.EntryAdded = false; } }
private void ParkingEntryWindowClosed(object sender, EventArgs e, string slotid) { if (ParkingInfo.SlotFreed) { ParkFloorViewModel floorVM = (ParkFloorViewModel)this.DataContext; floorVM.UpdateOccupiedStatusInModel(slotid, false); ParkingInfo.SlotFreed = false; } }
private void Button_Click(object sender, RoutedEventArgs e) { string slotid = ((Button)sender).Content.ToString(); ParkFloorViewModel floorVM = (ParkFloorViewModel)this.DataContext; if (floorVM.SlotOccupied(slotid)) { ParkingInfo.SlotID = slotid; Window detailsWindow = new ParkingInfo(); detailsWindow.Owner = Application.Current.MainWindow; detailsWindow.Show(); detailsWindow.Closed += (sender1, e1) => ParkingEntryWindowClosed(sender1, e1, slotid); } else { ParkingSlotViewModel slotVM = floorVM.GetParkingSlotVM(slotid); Window entryWindow = new VehicleEntry(slotVM); entryWindow.Owner = Application.Current.MainWindow; entryWindow.Show(); entryWindow.Closed += (sender1, e1) => AddEntryWindowClosed(sender1, e1, slotid); } }