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;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media;
|
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)
|
|
|
|
|
|
{
|
2013-05-07 18:12:25 +02:00
|
|
|
|
var visibility = Visibility.Hidden;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
if (values.Length == 2 && values[0] is Map && values[1] is Transform)
|
2012-08-26 21:54:00 +02:00
|
|
|
|
{
|
2013-05-07 18:12:25 +02:00
|
|
|
|
var parentMap = (Map)values[0];
|
|
|
|
|
|
var transform = ((Transform)values[1]).Value;
|
2012-08-26 21:54:00 +02:00
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
if (transform.OffsetX >= 0d && transform.OffsetX <= parentMap.ActualWidth &&
|
|
|
|
|
|
transform.OffsetY >= 0d && transform.OffsetY <= 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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|