2025-02-27 18:46:32 +01:00
|
|
|
|
using System;
|
2017-08-04 21:38:58 +02:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Globalization;
|
2025-08-19 13:14:08 +02:00
|
|
|
|
#if WPF
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
#elif UWP
|
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
|
|
|
|
|
#elif WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml.Data;
|
2025-08-19 19:43:02 +02:00
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using Avalonia.Data.Converters;
|
2025-08-19 13:14:08 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
#if UWP || WINUI
|
|
|
|
|
|
using ConverterCulture = System.String;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using ConverterCulture = System.Globalization.CultureInfo;
|
|
|
|
|
|
#endif
|
2017-08-04 21:38:58 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2025-08-19 13:14:08 +02:00
|
|
|
|
public class LocationConverter : TypeConverter, IValueConverter
|
2017-08-04 21:38:58 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sourceType == typeof(string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
|
|
|
|
{
|
2025-08-19 13:14:08 +02:00
|
|
|
|
return Location.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Location.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
2017-08-04 21:38:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-19 13:14:08 +02:00
|
|
|
|
public class LocationCollectionConverter : TypeConverter, IValueConverter
|
2017-08-04 21:38:58 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sourceType == typeof(string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
|
|
|
|
{
|
2025-08-19 13:14:08 +02:00
|
|
|
|
return LocationCollection.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return LocationCollection.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
2017-08-04 21:38:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-19 13:14:08 +02:00
|
|
|
|
public class BoundingBoxConverter : TypeConverter, IValueConverter
|
2017-08-04 21:38:58 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sourceType == typeof(string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
|
|
|
|
{
|
2025-08-19 13:14:08 +02:00
|
|
|
|
return BoundingBox.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return BoundingBox.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
2017-08-04 21:38:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-19 13:14:08 +02:00
|
|
|
|
public class TileSourceConverter : TypeConverter, IValueConverter
|
2017-08-04 21:38:58 +02:00
|
|
|
|
{
|
|
|
|
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
|
|
|
|
|
{
|
|
|
|
|
|
return sourceType == typeof(string);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
|
|
|
|
|
{
|
2025-08-19 13:14:08 +02:00
|
|
|
|
return TileSource.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return TileSource.Parse(value.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, ConverterCulture culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
2017-08-04 21:38:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|