2013-04-12 19:59:16 +02:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2013-05-07 18:12:25 +02:00
|
|
|
|
// Copyright © Clemens Fischer 2012-2013
|
2013-04-12 19:59:16 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
#if NETFX_CORE
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-05-07 18:12:25 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Fills a rectangular area with an ImageBrush from the Source property.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class MapImage : MapRectangle
|
2013-04-12 19:59:16 +02:00
|
|
|
|
{
|
|
|
|
|
|
private static readonly Transform imageTransform = new MatrixTransform
|
|
|
|
|
|
{
|
2013-05-07 18:12:25 +02:00
|
|
|
|
Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
|
2013-04-12 19:59:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
|
|
|
|
|
|
"Source", typeof(ImageSource), typeof(MapImage),
|
|
|
|
|
|
new PropertyMetadata(null, (o, e) => ((MapImage)o).SourceChanged((ImageSource)e.NewValue)));
|
|
|
|
|
|
|
|
|
|
|
|
public ImageSource Source
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (ImageSource)GetValue(SourceProperty); }
|
|
|
|
|
|
set { SetValue(SourceProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-21 23:56:08 +02:00
|
|
|
|
private void SourceChanged(ImageSource image)
|
2013-04-12 19:59:16 +02:00
|
|
|
|
{
|
|
|
|
|
|
Fill = new ImageBrush
|
|
|
|
|
|
{
|
2013-04-21 23:56:08 +02:00
|
|
|
|
ImageSource = image,
|
2013-05-07 18:12:25 +02:00
|
|
|
|
RelativeTransform = imageTransform
|
2013-04-12 19:59:16 +02:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|