mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
TypeConverter for MapProjection
This commit is contained in:
parent
de6bc52d10
commit
17a481c773
|
|
@ -19,6 +19,11 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Defines a map projection between geographic coordinates and cartesian map coordinates.
|
||||
/// </summary>
|
||||
#if UWP || WINUI
|
||||
[Windows.Foundation.Metadata.CreateFromString(MethodName = "Parse")]
|
||||
#else
|
||||
[System.ComponentModel.TypeConverter(typeof(MapProjectionConverter))]
|
||||
#endif
|
||||
public abstract class MapProjection
|
||||
{
|
||||
public const double Wgs84EquatorialRadius = 6378137d;
|
||||
|
|
@ -131,5 +136,18 @@ namespace MapControl
|
|||
|
||||
return rotatedRect;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return CrsId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a MapProjection instance from a CRS id string.
|
||||
/// </summary>
|
||||
public static MapProjection Parse(string crsId)
|
||||
{
|
||||
return MapProjectionFactory.Instance.GetProjection(crsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace MapControl
|
|||
|
||||
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return Location.Parse(value.ToString());
|
||||
return ConvertFrom(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
|
|
@ -55,7 +55,7 @@ namespace MapControl
|
|||
|
||||
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return LocationCollection.Parse(value.ToString());
|
||||
return ConvertFrom(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
|
|
@ -78,7 +78,7 @@ namespace MapControl
|
|||
|
||||
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return BoundingBox.Parse(value.ToString());
|
||||
return ConvertFrom(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
|
|
@ -101,7 +101,30 @@ namespace MapControl
|
|||
|
||||
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return TileSource.Parse(value.ToString());
|
||||
return ConvertFrom(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class MapProjectionConverter : TypeConverter, IValueConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
return MapProjection.Parse(value.ToString());
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
{
|
||||
return ConvertFrom(value.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
||||
|
|
|
|||
Loading…
Reference in a new issue