2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2017-08-04 21:38:58 +02:00
|
|
|
|
using System.Collections.Generic;
|
2021-06-14 21:41:37 +02:00
|
|
|
|
#if WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#elif UWP
|
2018-04-10 22:34:34 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
2015-03-20 18:49:17 +01:00
|
|
|
|
using System.Windows;
|
2012-11-22 21:42:29 +01:00
|
|
|
|
using System.Windows.Media;
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#endif
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2018-02-09 17:43:47 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A polyline defined by a collection of Locations.
|
|
|
|
|
|
/// </summary>
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public class MapPolyline : MapPath
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
2018-02-09 17:43:47 +01:00
|
|
|
|
public static readonly DependencyProperty LocationsProperty = DependencyProperty.Register(
|
|
|
|
|
|
nameof(Locations), typeof(IEnumerable<Location>), typeof(MapPolyline),
|
|
|
|
|
|
new PropertyMetadata(null, (o, e) => ((MapPolyline)o).DataCollectionPropertyChanged(e)));
|
2013-02-12 19:30:58 +01:00
|
|
|
|
|
2023-01-24 16:22:02 +01:00
|
|
|
|
public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register(
|
|
|
|
|
|
nameof(FillRule), typeof(FillRule), typeof(MapPolyline),
|
|
|
|
|
|
new PropertyMetadata(FillRule.EvenOdd, (o, e) => ((PathGeometry)((MapPolyline)o).Data).FillRule = (FillRule)e.NewValue));
|
|
|
|
|
|
|
2017-08-04 21:38:58 +02:00
|
|
|
|
/// <summary>
|
2018-02-09 17:43:47 +01:00
|
|
|
|
/// Gets or sets the Locations that define the polyline points.
|
2017-08-04 21:38:58 +02:00
|
|
|
|
/// </summary>
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#if !UWP
|
2021-06-14 21:41:37 +02:00
|
|
|
|
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#endif
|
2017-08-04 21:38:58 +02:00
|
|
|
|
public IEnumerable<Location> Locations
|
|
|
|
|
|
{
|
2022-08-06 10:40:59 +02:00
|
|
|
|
get => (IEnumerable<Location>)GetValue(LocationsProperty);
|
|
|
|
|
|
set => SetValue(LocationsProperty, value);
|
2017-08-04 21:38:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 16:22:02 +01:00
|
|
|
|
public FillRule FillRule
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (FillRule)GetValue(FillRuleProperty);
|
|
|
|
|
|
set => SetValue(FillRuleProperty, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public MapPolyline()
|
|
|
|
|
|
{
|
|
|
|
|
|
Data = new PathGeometry();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-25 08:53:50 +02:00
|
|
|
|
protected override void UpdateData()
|
2013-02-12 19:30:58 +01:00
|
|
|
|
{
|
2023-12-13 14:55:49 +01:00
|
|
|
|
var figures = ((PathGeometry)Data).Figures;
|
|
|
|
|
|
figures.Clear();
|
|
|
|
|
|
AddPolylinePoints(figures, Locations, false);
|
2013-02-12 19:30:58 +01:00
|
|
|
|
}
|
2012-11-22 21:42:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|