mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Avalonia MapPolygon, MapPolyline
This commit is contained in:
parent
bfa70de0cd
commit
cf08a2baae
9 changed files with 40 additions and 25 deletions
|
|
@ -28,8 +28,6 @@
|
|||
<Compile Remove="..\Shared\MapGraticule.cs" />
|
||||
<Compile Remove="..\Shared\MapItem.cs" />
|
||||
<Compile Remove="..\Shared\MapItemsControl.cs" />
|
||||
<Compile Remove="..\Shared\MapPolyline.cs" />
|
||||
<Compile Remove="..\Shared\MapPolygon.cs" />
|
||||
<Compile Remove="..\Shared\ViewTransform.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Media;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
|
@ -21,7 +20,7 @@ namespace MapControl
|
|||
|
||||
public static readonly StyledProperty<Geometry> DataProperty =
|
||||
DependencyPropertyHelper.AddOwner<MapPath, Geometry>(Path.DataProperty,
|
||||
(path, oldValue, newValue) => path.DataPropertyChanged(oldValue, newValue));
|
||||
(path, oldValue, newValue) => path.UpdateData());
|
||||
|
||||
public Geometry Data
|
||||
{
|
||||
|
|
@ -31,16 +30,6 @@ namespace MapControl
|
|||
|
||||
protected override Geometry CreateDefiningGeometry() => Data;
|
||||
|
||||
private void DataPropertyChanged(Geometry oldData, Geometry newData)
|
||||
{
|
||||
// Check if data is actually a new Geometry.
|
||||
//
|
||||
if (newData != null && !ReferenceEquals(newData, oldData))
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMapTransform(Matrix matrix)
|
||||
{
|
||||
if (Data.Transform is MatrixTransform transform)
|
||||
|
|
|
|||
|
|
@ -141,14 +141,18 @@ namespace MapControl
|
|||
return longitudeOffset;
|
||||
}
|
||||
|
||||
protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable<Location> locations, bool closed)
|
||||
protected PathFigureCollection GetPathFigures(IEnumerable<Location> locations, bool closed)
|
||||
{
|
||||
var pathFigures = new PathFigureCollection();
|
||||
|
||||
if (parentMap != null && locations != null)
|
||||
{
|
||||
var longitudeOffset = GetLongitudeOffset(Location ?? locations.FirstOrDefault());
|
||||
|
||||
AddPolylinePoints(pathFigures, locations, longitudeOffset, closed);
|
||||
}
|
||||
|
||||
return pathFigures;
|
||||
}
|
||||
|
||||
protected void AddMultiPolygonPoints(PathFigureCollection pathFigures, IEnumerable<IEnumerable<Location>> polygons)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ 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
|
||||
|
|
@ -32,7 +35,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets or sets the Locations that define the polygon points.
|
||||
/// </summary>
|
||||
#if WPF
|
||||
#if WPF || AVALONIA
|
||||
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
||||
#endif
|
||||
public IEnumerable<Location> Locations
|
||||
|
|
@ -54,9 +57,10 @@ namespace MapControl
|
|||
|
||||
protected override void UpdateData()
|
||||
{
|
||||
var figures = ((PathGeometry)Data).Figures;
|
||||
figures.Clear();
|
||||
AddPolylinePoints(figures, Locations, true);
|
||||
((PathGeometry)Data).Figures = GetPathFigures(Locations, true);
|
||||
#if AVALONIA
|
||||
InvalidateGeometry();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ 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
|
||||
|
|
@ -32,7 +35,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets or sets the Locations that define the polyline points.
|
||||
/// </summary>
|
||||
#if WPF
|
||||
#if WPF || AVALONIA
|
||||
[System.ComponentModel.TypeConverter(typeof(LocationCollectionConverter))]
|
||||
#endif
|
||||
public IEnumerable<Location> Locations
|
||||
|
|
@ -54,9 +57,10 @@ namespace MapControl
|
|||
|
||||
protected override void UpdateData()
|
||||
{
|
||||
var figures = ((PathGeometry)Data).Figures;
|
||||
figures.Clear();
|
||||
AddPolylinePoints(figures, Locations, false);
|
||||
((PathGeometry)Data).Figures = GetPathFigures(Locations, false);
|
||||
#if AVALONIA
|
||||
InvalidateGeometry();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ using System.Collections.Generic;
|
|||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue