diff --git a/MapControl/Shared/BoundingBox.cs b/MapControl/Shared/BoundingBox.cs index 56947875..5d4ad5f2 100644 --- a/MapControl/Shared/BoundingBox.cs +++ b/MapControl/Shared/BoundingBox.cs @@ -40,6 +40,11 @@ namespace MapControl public virtual Location Center => new Location((South + North) / 2d, (West + East) / 2d); + public override string ToString() + { + return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", South, West, North, East); + } + /// /// Creates a BoundingBox instance from a string containing a comma-separated sequence of four or five floating point numbers. /// diff --git a/MapControl/Shared/LocationCollection.cs b/MapControl/Shared/LocationCollection.cs index 90c89274..39f9687a 100644 --- a/MapControl/Shared/LocationCollection.cs +++ b/MapControl/Shared/LocationCollection.cs @@ -48,20 +48,22 @@ namespace MapControl Add(new Location(latitude, longitude)); } + public override string ToString() + { + return string.Join(" ", this.Select(l => l.ToString())); + } + /// /// Creates a LocationCollection instance from a string containing a sequence /// of Location strings that are separated by a spaces or semicolons. /// public static LocationCollection Parse(string locations) { - if (string.IsNullOrEmpty(locations)) - { - return new LocationCollection(); - } - - var strings = locations.Split(new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries); - - return new LocationCollection(strings.Select(l => Location.Parse(l))); + return string.IsNullOrEmpty(locations) + ? new LocationCollection() + : new LocationCollection(locations + .Split(new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries) + .Select(Location.Parse)); } /// diff --git a/MapControl/Shared/TileSource.cs b/MapControl/Shared/TileSource.cs index 8576d873..1f142044 100644 --- a/MapControl/Shared/TileSource.cs +++ b/MapControl/Shared/TileSource.cs @@ -89,6 +89,11 @@ namespace MapControl return ImageLoader.LoadImageAsync(buffer); } + public override string ToString() + { + return UriTemplate; + } + /// /// Creates a TileSource instance from an Uri template string. /// diff --git a/MapControl/UWP/MapControl.UWP.csproj b/MapControl/UWP/MapControl.UWP.csproj index e5927464..f1a2b58c 100644 --- a/MapControl/UWP/MapControl.UWP.csproj +++ b/MapControl/UWP/MapControl.UWP.csproj @@ -278,8 +278,8 @@ Tile.WinUI.cs - - TileSourceConverter.cs + + ValueConverters.cs diff --git a/MapControl/WinUI/TileSourceConverter.cs b/MapControl/WinUI/TileSourceConverter.cs deleted file mode 100644 index 3c700c6c..00000000 --- a/MapControl/WinUI/TileSourceConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -#if UWP -using Windows.UI.Xaml.Data; -#elif WINUI -using Microsoft.UI.Xaml.Data; -#endif - -namespace MapControl -{ - public class TileSourceConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return TileSource.Parse(value.ToString()); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotSupportedException(); - } - } -} diff --git a/MapControl/WinUI/ValueConverters.cs b/MapControl/WinUI/ValueConverters.cs new file mode 100644 index 00000000..657c0556 --- /dev/null +++ b/MapControl/WinUI/ValueConverters.cs @@ -0,0 +1,61 @@ +using System; +#if UWP +using Windows.UI.Xaml.Data; +#elif WINUI +using Microsoft.UI.Xaml.Data; +#endif + +namespace MapControl +{ + public class LocationConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + return Location.Parse(value.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value.ToString(); + } + } + + public class LocationCollectionConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + return LocationCollection.Parse(value.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value.ToString(); + } + } + + public class BoundingBoxConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + return BoundingBox.Parse(value.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value.ToString(); + } + } + + public class TileSourceConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + return TileSource.Parse(value.ToString()); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + return value.ToString(); + } + } +}