private void ShootingLocationNameControl_Leaving(object sender, AutoCompleteTextBoxControlEventArgs e) { // set the view model // existing shooting location if (e.Object is ShootingLocation shootingLocation) { DisplayItem.ShootingLocationName = shootingLocation.Name; DisplayItem.ShootingLocationLatitude = shootingLocation.Coordinates?.Latitude; DisplayItem.ShootingLocationLongitude = shootingLocation.Coordinates?.Longitude; // might be null if no photos exist DisplayItem.Photo_1 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(0)?.ImageBytes); DisplayItem.Photo_2 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(1)?.ImageBytes); DisplayItem.Photo_3 = ImageTools.ByteArrayToBitmapImage(shootingLocation.Photos?.ElementAtOrDefault(2)?.ImageBytes); } // new shooting location else { // other attributes set via databinding DisplayItem.ShootingLocationName = Window.ShootingLocationControl.GetCurrentText(); } // RefreshParkingLocationControl(); Window.ShootingLocationLatitudeTextBox.Focus(); }
private void FillShootingLocation() { var subjectLocation = Window.Location_SubjectLocationControl.GetCurrentObject() as SubjectLocation; //RefreshControl(subjectLocation?.ShootingLocations?.OfType<Location>().ToList(), Window.ShootingLocationControl); _locationTabControler.ResetShootingLocationControl(); Window.ShootingLocationControl.SelectKey(CurrentDisplayItem.ShootingLocationName); _locationTabControler.DisplayItem.ShootingLocationName = CurrentDisplayItem.ShootingLocationName; var shootingLocation = Window.ShootingLocationControl.GetCurrentObject() as ShootingLocation; _locationTabControler.DisplayItem.ShootingLocationLatitude = shootingLocation.Coordinates.Latitude; _locationTabControler.DisplayItem.ShootingLocationLongitude = shootingLocation.Coordinates.Longitude; _locationTabControler.DisplayItem.Photo_1 = ImageTools.ByteArrayToBitmapImage(shootingLocation?.Photos?.ElementAtOrDefault(0)?.ImageBytes); _locationTabControler.DisplayItem.Photo_2 = ImageTools.ByteArrayToBitmapImage(shootingLocation?.Photos?.ElementAtOrDefault(1)?.ImageBytes); _locationTabControler.DisplayItem.Photo_3 = ImageTools.ByteArrayToBitmapImage(shootingLocation?.Photos?.ElementAtOrDefault(2)?.ImageBytes); }
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); } }