2013-04-12 19:59:16 +02:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2014-01-10 20:11:39 +01:00
|
|
|
|
// Copyright © 2014 Clemens Fischer
|
2013-04-12 19:59:16 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#if WINDOWS_RUNTIME
|
2013-04-12 19:59:16 +02:00
|
|
|
|
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>
|
2014-07-01 18:57:44 +02:00
|
|
|
|
public class MapImage : MapRectangle
|
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-10-13 16:32:51 +02:00
|
|
|
|
|
|
|
|
|
|
private void SourceChanged(ImageSource image)
|
|
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
var transform = new MatrixTransform
|
2013-10-13 16:32:51 +02:00
|
|
|
|
{
|
2014-07-01 18:57:44 +02:00
|
|
|
|
Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
|
2013-10-13 16:32:51 +02:00
|
|
|
|
};
|
2014-07-01 18:57:44 +02:00
|
|
|
|
transform.Freeze();
|
2013-10-13 16:32:51 +02:00
|
|
|
|
|
2014-07-01 18:57:44 +02:00
|
|
|
|
Fill = new ImageBrush
|
|
|
|
|
|
{
|
|
|
|
|
|
ImageSource = image,
|
|
|
|
|
|
RelativeTransform = transform
|
|
|
|
|
|
};
|
2013-10-13 16:32:51 +02:00
|
|
|
|
}
|
2013-04-12 19:59:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|