public static string AddressForLocation(LocationPart location)
        {
            var addressBuilder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(location.Name))
            {
                addressBuilder.AppendLine(location.Name);
            }
            if (!string.IsNullOrWhiteSpace(location.Company))
            {
                addressBuilder.AppendLine(location.Company);
            }
            if (!string.IsNullOrWhiteSpace(location.UnitApartment))
            {
                addressBuilder.AppendLine(location.UnitApartment);
            }
            if (!string.IsNullOrWhiteSpace(location.NameOrNumber))
            {
                addressBuilder.Append(location.NameOrNumber);
            }
            if (!string.IsNullOrWhiteSpace(location.Street))
            {
                if (!string.IsNullOrWhiteSpace(location.NameOrNumber))
                {
                    addressBuilder.Append(" ");
                }
                addressBuilder.AppendLine(location.Street);
            }
            else
            {
                addressBuilder.AppendLine();
            }
            if (!string.IsNullOrWhiteSpace(location.Town))
            {
                addressBuilder.AppendLine(location.Town);
            }
            if (!string.IsNullOrWhiteSpace(location.Postcode))
            {
                addressBuilder.AppendLine(location.Postcode);
            }
            if (!string.IsNullOrWhiteSpace(location.CountyState))
            {
                addressBuilder.AppendLine(location.CountyState);
            }
            if (!string.IsNullOrWhiteSpace(location.Country))
            {
                addressBuilder.AppendLine(location.Country);
            }
            return(addressBuilder.ToString());
        }
예제 #2
0
        public static Bic Create(
            string institutionCode,
            string countryCode,
            string locationCode,
            string branchCode,
            BicVersion version)
        {
            Require.NotNull(institutionCode, nameof(institutionCode));
            Require.NotNull(countryCode, nameof(countryCode));
            Require.NotNull(locationCode, nameof(locationCode));
            Require.NotNull(branchCode, nameof(branchCode));
            Require.True(InstitutionPart.Validate(institutionCode, version), nameof(institutionCode));
            Require.True(CountryPart.Validate(countryCode), nameof(countryCode));
            Require.True(LocationPart.Validate(locationCode), nameof(locationCode));
            Require.True(BranchPart.Validate(branchCode), nameof(branchCode));

            return(new Bic(institutionCode, countryCode, locationCode, branchCode));
        }
예제 #3
0
        public string GetMapUrl(LocationPart part)
        {
            if (part == null)
            {
                return(null);
            }
            if (part.Latitude.HasValue && part.Longitude.HasValue)
            {
                return($"https://www.google.com/maps/search/{part.Latitude.Value.ToString("0.000000")},{part.Longitude.Value.ToString("0.000000")}");
            }
            var address = LocationUtilities.AddressForLocation(part).Replace(Environment.NewLine, ",");

            if (!string.IsNullOrWhiteSpace(address))
            {
                return($"https://www.google.com/maps/search/{address}");
            }
            return(null);
        }
예제 #4
0
    // makes sence when there're cut locations parts outside of the grid
    // (location part width and height != cell width and height)
    private IEnumerator UpdateOutsideLocationParts
        (LocationDataVector partData, LocationData locData, List <RectTransform> lpTransforms)
    {
        yield return(new WaitForEndOfFrame());

        // disable grid layout group
        _glgContent.enabled = false;

        // update outside (right and bottom because grid begins from left top) location parts to the right size
        for (int i = 0; i <= partData.y; i++)
        {
            int           listIndex             = partData.x * (i < 0? 1 : i + 1) + i;
            LocationPart  locationPart          = locData.List[listIndex];
            RectTransform locationPartTransform = lpTransforms[listIndex];

            locationPartTransform.sizeDelta = new Vector2(locationPart.Width * 100, locationPartTransform.sizeDelta.y);

            //print(_scrollViewContent.sizeDelta.x - locationPart.Width * 100 / 2);
            float locationPartXLocalPosition = _scrollViewContent.sizeDelta.x / 2 - locationPart.Width * 100 / 2;
            locationPartTransform.localPosition = new Vector2(locationPartXLocalPosition, locationPartTransform.localPosition.y);
        }
    }
예제 #5
0
        public static Outcome <Bic> TryParse(string value, BicVersion version)
        {
            if (value == null || !CheckLength(value))
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidBicValue, value)));
            }

            string institutionCode = InstitutionPart.FromBic(value, version);

            if (institutionCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_InstitutionCode, value)));
            }

            string countryCode = CountryPart.FromBic(value);

            if (countryCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_CountryCode, value)));
            }

            string locationCode = LocationPart.FromBic(value);

            if (locationCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_LocationCode, value)));
            }

            string branchCode = BranchPart.FromBic(value);

            if (branchCode == null)
            {
                return(Outcome <Bic> .FromError(Format.Current(Strings.InvalidInput_BranchCode, value)));
            }

            return(Outcome.Of(new Bic(institutionCode, countryCode, locationCode, branchCode, value)));
        }
예제 #6
0
        public static Bic?Parse(string value, BicVersion version)
        {
            if (value == null || !CheckLength(value))
            {
                return(null);
            }

            string institutionCode = InstitutionPart.FromBic(value, version);

            if (institutionCode == null)
            {
                return(null);
            }

            string countryCode = CountryPart.FromBic(value);

            if (countryCode == null)
            {
                return(null);
            }

            string locationCode = LocationPart.FromBic(value);

            if (locationCode == null)
            {
                return(null);
            }

            string branchCode = BranchPart.FromBic(value);

            if (branchCode == null)
            {
                return(null);
            }

            return(new Bic(institutionCode, countryCode, locationCode, branchCode, value));
        }
예제 #7
0
        public LocationPart GeocodeIfRequired(LocationPart part)
        {
            if (part == null || string.IsNullOrWhiteSpace(GetApiKey()))
            {
                return(part);
            }
            // Don't geocode if we already have coordinate values
            if (part.Latitude.HasValue && part.Longitude.HasValue)
            {
                return(part);
            }
            var address = LocationUtilities.AddressForLocation(part);
            var results = Geocode(address);

            if (!results.Any())
            {
                return(part);
            }
            var result = results.First();

            part.Latitude  = result.Latitude;
            part.Longitude = result.Longitude;
            return(part);
        }
예제 #8
0
 public Location(LocationPart locationPart)
     : this(locationPart.Record)
 {
 }
        public static string AddressForLocationWeb(LocationPart location)
        {
            var address = AddressForLocation(location);

            return(address.Replace(Environment.NewLine, "<br/>"));
        }
예제 #10
0
 public Location(LocationPart locationPart)
     : this(locationPart.Record) { }
예제 #11
0
    /// <summary>
    /// Create and spawn location grid.
    /// </summary>
    public void Create(LocationData locationData)
    {
        // location grid always have to be [X x Y]
        // get last list element to get grid = [maxX; maxY]
        LocationPart       lastElement = locationData.List[locationData.List.Count - 1];
        LocationDataVector partData    = new LocationDataVector(-1);

        foreach (string part in lastElement.Id.Split('_'))
        {
            int number;
            if (int.TryParse(part, out number))
            {
                if (partData.y == -1)
                {
                    partData.y = number;
                }
                else
                {
                    partData.x = number;
                }
            }
        }

        // get full width and height of location container
        float width = 0, height = 0;

        for (int i = 0; i <= partData.x; i++)
        {
            width += _locationGridCellSize;
        }
        for (int i = 0; i <= partData.y; i++)
        {
            height += _locationGridCellSize;
        }

        // set location container width, height and local position (left top)
        _scrollViewContent.sizeDelta     = new Vector2(width, height);
        _scrollViewContent.localPosition = new Vector3(_scrollViewContent.sizeDelta.x / 2, -_scrollViewContent.sizeDelta.y / 2);

        // set grid layout group cell size and fixed column count
        _glgContent.cellSize        = new Vector2(_locationGridCellSize, _locationGridCellSize);
        _glgContent.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        _glgContent.constraintCount = partData.x + 1;

        // load location parts sprites
        List <RectTransform> locationPartsTransforms = new List <RectTransform>();

        for (int i = 0; i < locationData.List.Count; i++)
        {
            string        spritePath         = _locationPath + locationData.List[i].Id;
            Sprite        locationPartSprite = Resources.Load <Sprite>(spritePath);
            RectTransform locationPart       = Instantiate(_locationPartPrefab, _scrollViewContent.transform);
            locationPart.GetComponent <Image>().sprite = locationPartSprite;
            locationPartsTransforms.Add(locationPart);
        }

        // update container to the right size
        float newWidth  = width - 512 + lastElement.Width * 100;
        float newHeight = height - 512 + lastElement.Height * 100;

        _scrollViewContent.sizeDelta = new Vector2(newWidth, newHeight);

        // update location parts data after grid creation with saved grid elements position
        StartCoroutine(UpdateOutsideLocationParts(partData, locationData, locationPartsTransforms));
    }