mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
WinUI value converters
This commit is contained in:
parent
e006cbedc6
commit
933cb7f2ba
|
|
@ -40,6 +40,11 @@ namespace MapControl
|
||||||
|
|
||||||
public virtual Location Center => new Location((South + North) / 2d, (West + East) / 2d);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a BoundingBox instance from a string containing a comma-separated sequence of four or five floating point numbers.
|
/// Creates a BoundingBox instance from a string containing a comma-separated sequence of four or five floating point numbers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -48,20 +48,22 @@ namespace MapControl
|
||||||
Add(new Location(latitude, longitude));
|
Add(new Location(latitude, longitude));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Join(" ", this.Select(l => l.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a LocationCollection instance from a string containing a sequence
|
/// Creates a LocationCollection instance from a string containing a sequence
|
||||||
/// of Location strings that are separated by a spaces or semicolons.
|
/// of Location strings that are separated by a spaces or semicolons.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocationCollection Parse(string locations)
|
public static LocationCollection Parse(string locations)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(locations))
|
return string.IsNullOrEmpty(locations)
|
||||||
{
|
? new LocationCollection()
|
||||||
return new LocationCollection();
|
: new LocationCollection(locations
|
||||||
}
|
.Split(new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(Location.Parse));
|
||||||
var strings = locations.Split(new char[] { ' ', ';' }, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
|
|
||||||
return new LocationCollection(strings.Select(l => Location.Parse(l)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,11 @@ namespace MapControl
|
||||||
return ImageLoader.LoadImageAsync(buffer);
|
return ImageLoader.LoadImageAsync(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return UriTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a TileSource instance from an Uri template string.
|
/// Creates a TileSource instance from an Uri template string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -278,8 +278,8 @@
|
||||||
<Compile Include="..\WinUI\Tile.WinUI.cs">
|
<Compile Include="..\WinUI\Tile.WinUI.cs">
|
||||||
<Link>Tile.WinUI.cs</Link>
|
<Link>Tile.WinUI.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\WinUI\TileSourceConverter.cs">
|
<Compile Include="..\WinUI\ValueConverters.cs">
|
||||||
<Link>TileSourceConverter.cs</Link>
|
<Link>ValueConverters.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="TileImageLoader.UWP.cs" />
|
<Compile Include="TileImageLoader.UWP.cs" />
|
||||||
|
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
61
MapControl/WinUI/ValueConverters.cs
Normal file
61
MapControl/WinUI/ValueConverters.cs
Normal file
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue