mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
64 lines
2 KiB
C#
64 lines
2 KiB
C#
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
// Copyright © 2024 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System.Collections.Generic;
|
|
#if WPF
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
#elif UWP
|
|
using Windows.UI.Xaml;
|
|
using Windows.UI.Xaml.Media;
|
|
#elif WINUI
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Media;
|
|
#elif AVALONIA
|
|
using Avalonia.Media;
|
|
using DependencyProperty = Avalonia.AvaloniaProperty;
|
|
#endif
|
|
|
|
namespace MapControl
|
|
{
|
|
/// <summary>
|
|
/// A polyline defined by a collection of Locations.
|
|
/// </summary>
|
|
public class MapPolyline : MapPath
|
|
{
|
|
public static readonly DependencyProperty LocationsProperty =
|
|
DependencyPropertyHelper.Register<MapPolyline, IEnumerable<Location>>(nameof(Locations), null,
|
|
(polyline, oldValue, newValue) => polyline.DataCollectionPropertyChanged(oldValue, newValue));
|
|
|
|
public static readonly DependencyProperty FillRuleProperty =
|
|
DependencyPropertyHelper.Register<MapPolyline, FillRule>(nameof(FillRule), FillRule.EvenOdd,
|
|
(polyline, oldValue, newValue) => ((PathGeometry)polyline.Data).FillRule = newValue);
|
|
|
|
/// <summary>
|
|
/// Gets or sets the Locations that define the polyline points.
|
|
/// </summary>
|
|
#if WPF || AVALONIA
|
|
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
|
#endif
|
|
public IEnumerable<Location> Locations
|
|
{
|
|
get => (IEnumerable<Location>)GetValue(LocationsProperty);
|
|
set => SetValue(LocationsProperty, value);
|
|
}
|
|
|
|
public FillRule FillRule
|
|
{
|
|
get => (FillRule)GetValue(FillRuleProperty);
|
|
set => SetValue(FillRuleProperty, value);
|
|
}
|
|
|
|
public MapPolyline()
|
|
{
|
|
Data = new PathGeometry();
|
|
}
|
|
|
|
protected override void UpdateData()
|
|
{
|
|
SetPathFigures(GetPathFigures(Locations, true));
|
|
}
|
|
}
|
|
}
|