2026-01-21 22:27:29 +01:00
|
|
|
|
using System.Collections;
|
2026-02-01 22:56:50 +01:00
|
|
|
|
using System.Collections.Generic;
|
2026-01-21 22:27:29 +01:00
|
|
|
|
using System.Collections.Specialized;
|
2026-02-01 22:56:50 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
2026-01-21 22:27:29 +01:00
|
|
|
|
#if WPF
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using PolypointGeometry = System.Windows.Media.StreamGeometry;
|
|
|
|
|
|
#elif UWP
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
using PolypointGeometry = Windows.UI.Xaml.Media.PathGeometry;
|
|
|
|
|
|
#elif WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
|
using PolypointGeometry = Microsoft.UI.Xaml.Media.PathGeometry;
|
|
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
|
using PolypointGeometry = Avalonia.Media.PathGeometry;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Base class of MapPolyline and MapPolygon and MapMultiPolygon.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class MapPolypoint
|
|
|
|
|
|
{
|
|
|
|
|
|
public static readonly DependencyProperty FillRuleProperty =
|
|
|
|
|
|
DependencyPropertyHelper.Register<MapPolygon, FillRule>(nameof(FillRule), FillRule.EvenOdd,
|
|
|
|
|
|
(polypoint, oldValue, newValue) => ((PolypointGeometry)polypoint.Data).FillRule = newValue);
|
|
|
|
|
|
|
|
|
|
|
|
public FillRule FillRule
|
|
|
|
|
|
{
|
|
|
|
|
|
get => (FillRule)GetValue(FillRuleProperty);
|
|
|
|
|
|
set => SetValue(FillRuleProperty, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected MapPolypoint()
|
|
|
|
|
|
{
|
|
|
|
|
|
Data = new PolypointGeometry();
|
2026-02-01 22:56:50 +01:00
|
|
|
|
Location = new Location(0d, double.NaN);
|
2026-01-21 22:27:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void DataCollectionPropertyChanged(IEnumerable oldValue, IEnumerable newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (oldValue is INotifyCollectionChanged oldCollection)
|
|
|
|
|
|
{
|
|
|
|
|
|
oldCollection.CollectionChanged -= DataCollectionChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (newValue is INotifyCollectionChanged newCollection)
|
|
|
|
|
|
{
|
|
|
|
|
|
newCollection.CollectionChanged += DataCollectionChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UpdateData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void DataCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateData();
|
|
|
|
|
|
}
|
2026-02-01 22:56:50 +01:00
|
|
|
|
|
|
|
|
|
|
protected double GetLongitudeOffset(IEnumerable<Location> locations)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ParentMap.MapProjection.IsNormalCylindrical)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0d;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Location location;
|
|
|
|
|
|
|
|
|
|
|
|
if (!double.IsNaN(Location.Longitude))
|
|
|
|
|
|
{
|
|
|
|
|
|
location = Location;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (locations != null && locations.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
location = locations.First();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0d;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ParentMap.InsideViewBounds(ParentMap.LocationToView(location)))
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0d;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ParentMap.NearestLongitude(location.Longitude) - location.Longitude;
|
|
|
|
|
|
}
|
2026-01-21 22:27:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|