Ejemplo n.º 1
0
        private void UpdateDistance()
        {
            var coord = DataContext as Coordinate;

            if (coord == null)
            {
                return;
            }
            var pos = _mainVm.UserLocation;

            if (coord.Point == null || pos == null)
            {
                DistanceText.Text = string.Empty;
            }
            else
            {
                var unit     = _settings.DistanceUnit;
                var distance = pos.Coordinate.Point.GetDistanceTo(coord.Point, unit);
                var culture  = _localization.GetCulture(_settings.CurrentLocale);
                switch (unit)
                {
                case DistanceUnitEnum.Kilometers:
                    DistanceText.Text = distance > 1
                            ? string.Format(culture, "{0:0.#} km", distance)
                            : string.Format(culture, "{0:0} m", distance * 1000);
                    break;

                case DistanceUnitEnum.Miles:
                    DistanceText.Text = distance > 1
                            ? string.Format(culture, "{0:0.#} mi", distance)
                            : string.Format(culture, "{0:0} yd", distance * 1760);
                    break;
                }
            }
        }