2018-02-09 17:43:47 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2020-01-09 19:40:10 +01:00
|
|
|
|
// © 2020 Clemens Fischer
|
2018-02-09 17:43:47 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
2018-02-09 17:43:47 +01:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#endif
|
2018-02-09 17:43:47 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A polygon defined by a collection of Locations.
|
|
|
|
|
|
/// </summary>
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public class MapPolygon : MapPath
|
2018-02-09 17:43:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
|
|
|
|
|
|
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolygon),
|
|
|
|
|
|
new PropertyMetadata(null, (o, e) => ((MapPolygon)o).DataCollectionPropertyChanged(e)));
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the Locations that define the polygon points.
|
|
|
|
|
|
/// </summary>
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#if !WINDOWS_UWP
|
2018-02-09 17:43:47 +01:00
|
|
|
|
[TypeConverter(typeof(LocationCollectionConverter))]
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#endif
|
2018-02-09 17:43:47 +01:00
|
|
|
|
public IEnumerable<Location> Locations
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (IEnumerable<Location>)GetValue(LocationsProperty); }
|
|
|
|
|
|
set { SetValue(LocationsProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public MapPolygon()
|
|
|
|
|
|
{
|
|
|
|
|
|
Data = new PathGeometry();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-09 17:43:47 +01:00
|
|
|
|
protected override void UpdateData()
|
|
|
|
|
|
{
|
2018-02-13 20:11:16 +01:00
|
|
|
|
var figures = ((PathGeometry)Data).Figures;
|
|
|
|
|
|
figures.Clear();
|
2018-02-09 17:43:47 +01:00
|
|
|
|
|
2018-02-14 18:10:53 +01:00
|
|
|
|
if (ParentMap != null)
|
2018-02-09 17:43:47 +01:00
|
|
|
|
{
|
2018-04-11 22:29:50 +02:00
|
|
|
|
AddPolylineLocations(figures, Locations, true);
|
2018-02-09 17:43:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|