2013-05-07 18:12:25 +02:00
|
|
|
|
using System;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Data;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
using MapControl;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
namespace WpfApplication
|
2012-08-26 21:54:00 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public class LocationToVisibilityConverter : IMultiValueConverter
|
2012-08-26 21:54:00 +02:00
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
2021-01-12 22:21:03 +01:00
|
|
|
|
var visibility = Visibility.Collapsed;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
|
2018-04-30 23:13:50 +02:00
|
|
|
|
if (values.Length == 2 && values[0] is MapBase && values[1] is Point?)
|
2012-08-26 21:54:00 +02:00
|
|
|
|
{
|
2018-04-30 23:13:50 +02:00
|
|
|
|
var parentMap = (MapBase)values[0];
|
|
|
|
|
|
var position = (Point?)values[1];
|
2012-08-26 21:54:00 +02:00
|
|
|
|
|
2018-04-30 23:13:50 +02:00
|
|
|
|
if (position.HasValue &&
|
2021-01-12 22:21:03 +01:00
|
|
|
|
position.Value.X >= 0d &&
|
|
|
|
|
|
position.Value.Y >= 0d &&
|
|
|
|
|
|
position.Value.X <= parentMap.ActualWidth &&
|
|
|
|
|
|
position.Value.Y <= parentMap.ActualHeight)
|
2012-08-26 21:54:00 +02:00
|
|
|
|
{
|
2012-10-25 08:42:51 +02:00
|
|
|
|
visibility = Visibility.Visible;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return visibility;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotSupportedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|