2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2018-02-09 17:43:47 +01:00
|
|
|
|
// © 2018 Clemens Fischer
|
2012-10-25 08:42:51 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2017-08-04 21:38:58 +02:00
|
|
|
|
#if WINDOWS_UWP
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using Windows.UI.Text;
|
2018-03-29 19:35:52 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Data;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
2012-10-25 08:42:51 +02:00
|
|
|
|
using System.Windows;
|
2018-03-29 19:35:52 +02:00
|
|
|
|
using System.Windows.Data;
|
2012-10-25 08:42:51 +02:00
|
|
|
|
using System.Windows.Media;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#endif
|
2012-10-25 08:42:51 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2017-06-25 23:05:48 +02:00
|
|
|
|
/// Base class for map overlays with background, foreground, stroke and font properties.
|
2012-10-25 08:42:51 +02:00
|
|
|
|
/// </summary>
|
2014-07-01 18:57:44 +02:00
|
|
|
|
public partial class MapOverlay : MapPanel
|
2012-10-25 08:42:51 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public double FontSize
|
2012-10-25 08:42:51 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
get { return (double)GetValue(FontSizeProperty); }
|
|
|
|
|
|
set { SetValue(FontSizeProperty, value); }
|
2012-10-25 08:42:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public FontFamily FontFamily
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (FontFamily)GetValue(FontFamilyProperty); }
|
|
|
|
|
|
set { SetValue(FontFamilyProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public FontStyle FontStyle
|
2012-10-25 08:42:51 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
get { return (FontStyle)GetValue(FontStyleProperty); }
|
|
|
|
|
|
set { SetValue(FontStyleProperty, value); }
|
2012-10-25 08:42:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FontStretch FontStretch
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (FontStretch)GetValue(FontStretchProperty); }
|
|
|
|
|
|
set { SetValue(FontStretchProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-22 21:42:29 +01:00
|
|
|
|
public FontWeight FontWeight
|
2012-10-25 08:42:51 +02:00
|
|
|
|
{
|
2012-11-22 21:42:29 +01:00
|
|
|
|
get { return (FontWeight)GetValue(FontWeightProperty); }
|
|
|
|
|
|
set { SetValue(FontWeightProperty, value); }
|
2012-10-25 08:42:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush Foreground
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (Brush)GetValue(ForegroundProperty); }
|
|
|
|
|
|
set { SetValue(ForegroundProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Brush Stroke
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (Brush)GetValue(StrokeProperty); }
|
|
|
|
|
|
set { SetValue(StrokeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double StrokeThickness
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(StrokeThicknessProperty); }
|
|
|
|
|
|
set { SetValue(StrokeThicknessProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DoubleCollection StrokeDashArray
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); }
|
|
|
|
|
|
set { SetValue(StrokeDashArrayProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double StrokeDashOffset
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(StrokeDashOffsetProperty); }
|
|
|
|
|
|
set { SetValue(StrokeDashOffsetProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PenLineCap StrokeDashCap
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (PenLineCap)GetValue(StrokeDashCapProperty); }
|
|
|
|
|
|
set { SetValue(StrokeDashCapProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PenLineCap StrokeStartLineCap
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (PenLineCap)GetValue(StrokeStartLineCapProperty); }
|
|
|
|
|
|
set { SetValue(StrokeStartLineCapProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PenLineCap StrokeEndLineCap
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (PenLineCap)GetValue(StrokeEndLineCapProperty); }
|
|
|
|
|
|
set { SetValue(StrokeEndLineCapProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public PenLineJoin StrokeLineJoin
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (PenLineJoin)GetValue(StrokeLineJoinProperty); }
|
|
|
|
|
|
set { SetValue(StrokeLineJoinProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public double StrokeMiterLimit
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(StrokeMiterLimitProperty); }
|
|
|
|
|
|
set { SetValue(StrokeMiterLimitProperty, value); }
|
|
|
|
|
|
}
|
2018-05-01 02:06:22 +02:00
|
|
|
|
|
2018-05-01 02:31:47 +02:00
|
|
|
|
public Binding FontSizeBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(FontSizeProperty, nameof(FontSize)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding FontFamilyBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(FontFamilyProperty, nameof(FontFamily)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding FontStyleBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(FontStyleProperty, nameof(FontStyle)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding FontStretchBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(FontStretchProperty, nameof(FontStretch)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding FontWeightBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(FontWeightProperty, nameof(FontWeight)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-01 02:06:22 +02:00
|
|
|
|
public Binding ForegroundBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(ForegroundProperty, nameof(Foreground)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeProperty, nameof(Stroke)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeThicknessBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeThicknessProperty, nameof(StrokeThickness)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeDashArrayBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeDashArrayProperty, nameof(StrokeDashArray)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeDashOffsetBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeDashOffsetProperty, nameof(StrokeDashOffset)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeDashCapBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeDashCapProperty, nameof(StrokeDashCap)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeStartLineCapBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeStartLineCapProperty, nameof(StrokeStartLineCap)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeEndLineCapBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeEndLineCapProperty, nameof(StrokeEndLineCap)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeLineJoinBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeLineJoinProperty, nameof(StrokeLineJoin)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Binding StrokeMiterLimitBinding
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return GetBinding(StrokeMiterLimitProperty, nameof(StrokeMiterLimit)); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void SetParentMap(MapBase map)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (map != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
|
if (Foreground == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetBinding(ForegroundProperty,
|
|
|
|
|
|
map.GetBindingExpression(MapBase.ForegroundProperty)?.ParentBinding ??
|
|
|
|
|
|
new Binding { Source = map, Path = new PropertyPath("Foreground") });
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
if (Stroke == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetBinding(StrokeProperty, ForegroundBinding);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.SetParentMap(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Binding GetBinding(DependencyProperty property, string propertyName)
|
|
|
|
|
|
{
|
|
|
|
|
|
return GetBindingExpression(property)?.ParentBinding ??
|
|
|
|
|
|
new Binding { Source = this, Path = new PropertyPath(propertyName) };
|
|
|
|
|
|
}
|
2012-10-25 08:42:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|