Exemplo n.º 1
0
        internal void HandleDelete()
        {
            var selectedItem = _listerWindow.LocationListView.SelectedItem as LocationListerDisplayItem;

            if (selectedItem is LocationListerDisplayItem displayItem)
            {
                if (DataAccess.DataAccessAdapter.DeleteShootingLocationById((displayItem.Tag as ShootingLocation).Id, out string errorMessagse) == DataAccess.PersistenceManager.E_DBReturnCode.error)
                {
                    ShowMessage(errorMessagse, E_MessageType.error);
                }
                else
                {
                    Mouse.OverrideCursor = Cursors.Wait;

                    AllDisplayItems.Remove(displayItem);
                    CurrentDisplayItem.Reset();

                    _locationTabControler.RefreshAllObjectsFromDB();
                    _locationTabControler.ReloadAndRefreshControls();

                    Mouse.OverrideCursor = null;

                    ShowMessage("Shooting location successfully deleted.", E_MessageType.success);
                }
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
Exemplo n.º 3
0
        private void FillLocationTab()
        {
            FillCountry();
            FillArea();
            FillSubArea();
            FillSubjectLocation();

            FillShootingLocation();
            FillParkingLocation();

            /*
             * // country
             * Window.Location_CountryControl.SelectKey(CurrentDisplayItem.CountryName);
             * _locationTabControler.DisplayItem.CountryName = CurrentDisplayItem.CountryName;
             * var country = Window.Location_CountryControl.GetCurrentObject() as Country;
             *
             * // area
             * RefreshControl(country?.Areas?.OfType<Location>().ToList(), Window.Location_AreaControl);
             * Window.Location_AreaControl.SelectKey(CurrentDisplayItem.AreaName);
             * _locationTabControler.DisplayItem.AreaName = CurrentDisplayItem.AreaName;
             * var area = Window.Location_AreaControl.GetCurrentObject() as Area;
             *
             * // subarea
             * RefreshControl(area?.SubAreas?.OfType<Location>().ToList(), Window.Location_SubAreaControl);
             * Window.Location_SubAreaControl.SelectKey(CurrentDisplayItem.SubAreaName);
             * _locationTabControler.DisplayItem.SubAreaName = CurrentDisplayItem.SubAreaName;
             * //var subArea = Window.Location_SubAreaControl.GetCurrentObject() as SubArea;
             * var subjectLocations = country.SubjectLocations.Where(c => c.Country.Name == CurrentDisplayItem.CountryName &&
             *                                                    c.Area.Name == CurrentDisplayItem.AreaName && c.SubArea.Name == CurrentDisplayItem.SubAreaName).ToList();
             *
             * // subject location
             * RefreshControl(subjectLocations?.OfType<Location>().ToList(), Window.Location_SubjectLocationControl);
             * Window.Location_SubjectLocationControl.SelectKey(CurrentDisplayItem.SubjectLocationName);
             * _locationTabControler.DisplayItem.SubjectLocationName = CurrentDisplayItem.SubjectLocationName;
             * var subjectLocation = Window.Location_SubjectLocationControl.GetCurrentObject() as SubjectLocation;
             * _locationTabControler.DisplayItem.SubjectLocationLatitude = subjectLocation.Coordinates.Latitude;
             * _locationTabControler.DisplayItem.SubjectLocationLongitude = subjectLocation.Coordinates.Longitude;
             *
             * // shooting location
             * RefreshControl(subjectLocation?.ShootingLocations?.OfType<Location>().ToList(), Window.ShootingLocationControl);
             * 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);
             *
             * // parking location
             * RefreshControl(shootingLocation?.ParkingLocations?.OfType<Location>().ToList(), Window.ParkingLocationControl);
             * Window.ParkingLocationControl.SelectKey(CurrentDisplayItem.ParkingLocationName);
             * _locationTabControler.DisplayItem.ParkingLocationName = CurrentDisplayItem.ParkingLocationName;
             * var parkingLocation = Window.ParkingLocationControl.GetCurrentObject() as ParkingLocation;
             * _locationTabControler.DisplayItem.ParkingLocationLatitude = parkingLocation?.Coordinates.Latitude;
             * _locationTabControler.DisplayItem.ParkingLocationLongitude = parkingLocation?.Coordinates.Longitude;
             */

            var shootingLocation = Window.ShootingLocationControl.GetCurrentObject() as ShootingLocation; // added from comment above

            var shootingLocationId = shootingLocation.Id;

            var di = AllDisplayItems.FirstOrDefault(d => (d.Tag as ShootingLocation).Id == shootingLocationId);

            di.ShootingLocationName = shootingLocation.Name;
        }