public ListerControler(MainWindow mainWindow, LocationListerWindow listerWindow, LocationTabControler locationTabControler) : base(mainWindow) { AllDisplayItems = new ObservableCollection <LocationListerDisplayItem>(); CurrentDisplayItem = new LocationListerDisplayItem(); _locationTabControler = locationTabControler; _listerWindow = listerWindow; _listerWindow.LocationListView.ItemsSource = AllDisplayItems; _listerWindow.PhotoPlaceGrid.DataContext = CurrentDisplayItem; ReadData(); }
private void ReadData() { // read all shooting locations if (DataAccess.DataAccessAdapter.ReadAllShootingLocations(out List <ShootingLocation> shootingLocations, out string errorMessage) == DataAccess.PersistenceManager.E_DBReturnCode.no_error) { // loop throw dhoow locations foreach (var shootingLocation in shootingLocations) { // create view model var newDisplayItem = new LocationListerDisplayItem() { ParkingLocationName = shootingLocation.ParkingLocations.ElementAtOrDefault(0)?.Name, ParkingLocationLatitude = shootingLocation.ParkingLocations.ElementAtOrDefault(0)?.Coordinates?.Latitude, ParkingLocationLongitude = shootingLocation.ParkingLocations.ElementAtOrDefault(0)?.Coordinates?.Longitude, ShootingLocationName = shootingLocation.Name, ShootingLocationLatitude = shootingLocation.Coordinates.Latitude, ShootingLocationLongitude = shootingLocation.Coordinates.Longitude, Photo_1 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(0)?.ImageBytes), Photo_2 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(1)?.ImageBytes), Photo_3 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(2)?.ImageBytes), Tag = shootingLocation }; foreach (var subjectLocation in shootingLocation.SubjectLocations) { newDisplayItem.CountryName = subjectLocation.Country.Name; newDisplayItem.SubjectLocationName = subjectLocation.Name; newDisplayItem.AreaName = subjectLocation.Area.Name; newDisplayItem.SubAreaName = subjectLocation.SubArea.Name; newDisplayItem.SubjectLocationLatitude = subjectLocation.Coordinates.Latitude; newDisplayItem.SubjectLocationLongitude = subjectLocation.Coordinates.Longitude; } newDisplayItem.Photo_1 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(0)?.ImageBytes); newDisplayItem.Photo_2 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(1)?.ImageBytes); newDisplayItem.Photo_3 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(2)?.ImageBytes); // add to list which is bound to list view AllDisplayItems.Add(newDisplayItem); } }