mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-03-07 22:13:50 +01:00
Reuse polyline PathFigureCollection
This commit is contained in:
parent
6b386827ff
commit
71f17420b5
|
|
@ -139,35 +139,27 @@ namespace MapControl
|
||||||
return longitudeOffset;
|
return longitudeOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PathFigureCollection GetPolylineFigures(IEnumerable<Location> locations, bool closed)
|
protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable<Location> locations, bool closed)
|
||||||
{
|
{
|
||||||
var pathFigures = new PathFigureCollection();
|
|
||||||
|
|
||||||
if (parentMap != null && locations != null)
|
if (parentMap != null && locations != null)
|
||||||
{
|
{
|
||||||
var longitudeOffset = GetLongitudeOffset(Location ?? locations.FirstOrDefault());
|
var longitudeOffset = GetLongitudeOffset(Location ?? locations.FirstOrDefault());
|
||||||
|
|
||||||
AddPolylineLocations(pathFigures, locations, longitudeOffset, closed);
|
AddPolylinePoints(pathFigures, locations, longitudeOffset, closed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathFigures;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PathFigureCollection GetMultiPolygonFigures(IEnumerable<IEnumerable<Location>> polygons)
|
protected void AddMultiPolygonPoints(PathFigureCollection pathFigures, IEnumerable<IEnumerable<Location>> polygons)
|
||||||
{
|
{
|
||||||
var pathFigures = new PathFigureCollection();
|
|
||||||
|
|
||||||
if (parentMap != null && polygons != null)
|
if (parentMap != null && polygons != null)
|
||||||
{
|
{
|
||||||
var longitudeOffset = GetLongitudeOffset(Location);
|
var longitudeOffset = GetLongitudeOffset(Location);
|
||||||
|
|
||||||
foreach (var polygon in polygons)
|
foreach (var polygon in polygons)
|
||||||
{
|
{
|
||||||
AddPolylineLocations(pathFigures, polygon, longitudeOffset, true);
|
AddPolylinePoints(pathFigures, polygon, longitudeOffset, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathFigures;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,9 @@ namespace MapControl
|
||||||
|
|
||||||
protected override void UpdateData()
|
protected override void UpdateData()
|
||||||
{
|
{
|
||||||
((PathGeometry)Data).Figures = GetPolylineFigures(Locations, true);
|
var figures = ((PathGeometry)Data).Figures;
|
||||||
|
figures.Clear();
|
||||||
|
AddPolylinePoints(figures, Locations, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,9 @@ namespace MapControl
|
||||||
|
|
||||||
protected override void UpdateData()
|
protected override void UpdateData()
|
||||||
{
|
{
|
||||||
((PathGeometry)Data).Figures = GetPolylineFigures(Locations, false);
|
var figures = ((PathGeometry)Data).Figures;
|
||||||
|
figures.Clear();
|
||||||
|
AddPolylinePoints(figures, Locations, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ namespace MapControl
|
||||||
|
|
||||||
protected override void UpdateData()
|
protected override void UpdateData()
|
||||||
{
|
{
|
||||||
((PathGeometry)Data).Figures = GetMultiPolygonFigures(Polygons);
|
var figures = ((PathGeometry)Data).Figures;
|
||||||
|
figures.Clear();
|
||||||
|
AddMultiPolygonPoints(figures, Polygons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ namespace MapControl
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddPolylineLocations(PathFigureCollection pathFigures, IEnumerable<Location> locations, double longitudeOffset, bool closed)
|
protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable<Location> locations, double longitudeOffset, bool closed)
|
||||||
{
|
{
|
||||||
if (locations.Count() >= 2)
|
if (locations.Count() >= 2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace MapControl
|
||||||
UpdateData();
|
UpdateData();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddPolylineLocations(PathFigureCollection pathFigures, IEnumerable<Location> locations, double longitudeOffset, bool closed)
|
protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable<Location> locations, double longitudeOffset, bool closed)
|
||||||
{
|
{
|
||||||
if (locations.Count() >= 2)
|
if (locations.Count() >= 2)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue