2018-02-09 17:43:47 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2018-02-09 17:43:47 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#if WPF
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.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;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#elif WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
2024-05-25 23:03:40 +02:00
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
|
using DependencyProperty = Avalonia.AvaloniaProperty;
|
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
|
|
|
|
{
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty LocationsProperty =
|
2024-05-23 18:22:52 +02:00
|
|
|
|
DependencyPropertyHelper.Register<MapPolygon, IEnumerable<Location>>(nameof(Locations), null,
|
2024-05-23 18:08:14 +02:00
|
|
|
|
(polygon, oldValue, newValue) => polygon.DataCollectionPropertyChanged(oldValue, newValue));
|
2018-02-09 17:43:47 +01:00
|
|
|
|
|
2024-05-23 18:08:14 +02:00
|
|
|
|
public static readonly DependencyProperty FillRuleProperty =
|
2024-05-23 18:22:52 +02:00
|
|
|
|
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
|
2024-05-23 18:08:14 +02:00
|
|
|
|
(polygon, oldValue, newValue) => ((PathGeometry)polygon.Data).FillRule = newValue);
|
2023-01-24 16:22:02 +01:00
|
|
|
|
|
2018-02-09 17:43:47 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the Locations that define the polygon points.
|
|
|
|
|
|
/// </summary>
|
2024-05-25 23:03:40 +02:00
|
|
|
|
#if WPF || AVALONIA
|
2021-06-14 21:41:37 +02:00
|
|
|
|
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
2018-04-10 22:34:34 +02:00
|
|
|
|
#endif
|
2018-02-09 17:43:47 +01:00
|
|
|
|
public IEnumerable<Location> Locations
|
|
|
|
|
|
{
|
2022-08-06 10:40:59 +02:00
|
|
|
|
get => (IEnumerable<Location>)GetValue(LocationsProperty);
|
|
|
|
|
|
set => SetValue(LocationsProperty, value);
|
2018-02-09 17:43:47 +01: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 MapPolygon()
|
|
|
|
|
|
{
|
|
|
|
|
|
Data = new PathGeometry();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-09 17:43:47 +01:00
|
|
|
|
protected override void UpdateData()
|
|
|
|
|
|
{
|
2024-05-26 00:12:32 +02:00
|
|
|
|
SetPathFigures(GetPathFigures(Locations, true));
|
2018-02-09 17:43:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|