mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
String.Format
This commit is contained in:
parent
5fde94acb9
commit
3cdbbe1e13
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
#if WINUI
|
||||
using Windows.Foundation;
|
||||
using Microsoft.UI.Xaml;
|
||||
|
|
@ -70,18 +71,9 @@ namespace MapControl
|
|||
var length = MinWidth / scale;
|
||||
var magnitude = Math.Pow(10d, Math.Floor(Math.Log10(length)));
|
||||
|
||||
if (length / magnitude < 2d)
|
||||
{
|
||||
length = 2d * magnitude;
|
||||
}
|
||||
else if (length / magnitude < 5d)
|
||||
{
|
||||
length = 5d * magnitude;
|
||||
}
|
||||
else
|
||||
{
|
||||
length = 10d * magnitude;
|
||||
}
|
||||
length = length / magnitude < 2d ? 2d * magnitude
|
||||
: length / magnitude < 5d ? 5d * magnitude
|
||||
: 10d * magnitude;
|
||||
|
||||
size.Width = length * scale + StrokeThickness + Padding.Left + Padding.Right;
|
||||
size.Height = 1.25 * FontSize + StrokeThickness + Padding.Top + Padding.Bottom;
|
||||
|
|
@ -100,7 +92,9 @@ namespace MapControl
|
|||
};
|
||||
line.Measure(size);
|
||||
|
||||
label.Text = length >= 1000d ? string.Format("{0:0} km", length / 1000d) : string.Format("{0:0} m", length);
|
||||
label.Text = length >= 1000d
|
||||
? string.Format(CultureInfo.InvariantCulture, "{0:0} km", length / 1000d)
|
||||
: string.Format(CultureInfo.InvariantCulture, "{0:0} m", length);
|
||||
label.Width = size.Width;
|
||||
label.Height = size.Height;
|
||||
label.Measure(size);
|
||||
|
|
|
|||
Loading…
Reference in a new issue