String.Format

This commit is contained in:
Clemens 2021-07-05 00:04:07 +02:00
parent 5fde94acb9
commit 3cdbbe1e13
2 changed files with 12 additions and 25 deletions

View file

@ -3,6 +3,7 @@
// Licensed under the Microsoft Public License (Ms-PL)
using System;
using System.Globalization;
#if WINUI
using Microsoft.UI.Xaml;
#elif WINDOWS_UWP
@ -55,17 +56,8 @@ namespace MapControl
private static string GetLabelFormat(double lineDistance)
{
if (lineDistance < 1d / 60d)
{
return "{0} {1}°{2:00}'{3:00}\"";
}
if (lineDistance < 1d)
{
return "{0} {1}°{2:00}'";
}
return "{0} {1}°";
return lineDistance < 1d / 60d ? "{0} {1}°{2:00}'{3:00}\""
: lineDistance < 1d ? "{0} {1}°{2:00}'" : "{0} {1}°";
}
private static string GetLabelText(double value, string format, string hemispheres)
@ -80,7 +72,8 @@ namespace MapControl
var seconds = (int)Math.Round(value * 3600d);
return string.Format(format, hemisphere, seconds / 3600, (seconds / 60) % 60, seconds % 60);
return string.Format(CultureInfo.InvariantCulture,
format, hemisphere, seconds / 3600, seconds / 60 % 60, seconds % 60);
}
}
}