From e49ca0b79ed0ddc55b65fb67794d77dc208e1412 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Sun, 26 May 2024 00:12:32 +0200 Subject: [PATCH] Avalonia InvalidateGeometry on new Path Figures --- MapControl/Avalonia/MapPath.Avalonia.cs | 7 +++++++ MapControl/Shared/MapPolygon.cs | 5 +---- MapControl/Shared/MapPolyline.cs | 5 +---- MapControl/WPF/MapPath.WPF.cs | 5 +++++ MapControl/WinUI/MapPath.WinUI.cs | 5 +++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/MapControl/Avalonia/MapPath.Avalonia.cs b/MapControl/Avalonia/MapPath.Avalonia.cs index 6d784dae..5c22a0d4 100644 --- a/MapControl/Avalonia/MapPath.Avalonia.cs +++ b/MapControl/Avalonia/MapPath.Avalonia.cs @@ -2,6 +2,7 @@ // Copyright © 2024 Clemens Fischer // Licensed under the Microsoft Public License (Ms-PL) +using Avalonia.Controls; using Avalonia.Controls.Shapes; using Avalonia.Media; using System.Collections; @@ -66,6 +67,12 @@ namespace MapControl UpdateData(); } + protected void SetPathFigures(PathFigures pathFigures) + { + ((PathGeometry)Data).Figures = pathFigures; + InvalidateGeometry(); + } + protected void AddPolylinePoints(PathFigures pathFigures, IEnumerable locations, double longitudeOffset, bool closed) { if (locations.Count() >= 2) diff --git a/MapControl/Shared/MapPolygon.cs b/MapControl/Shared/MapPolygon.cs index 9ca5715d..5998190f 100644 --- a/MapControl/Shared/MapPolygon.cs +++ b/MapControl/Shared/MapPolygon.cs @@ -57,10 +57,7 @@ namespace MapControl protected override void UpdateData() { - ((PathGeometry)Data).Figures = GetPathFigures(Locations, true); -#if AVALONIA - InvalidateGeometry(); -#endif + SetPathFigures(GetPathFigures(Locations, true)); } } } diff --git a/MapControl/Shared/MapPolyline.cs b/MapControl/Shared/MapPolyline.cs index 79392f8b..ccbcc9e3 100644 --- a/MapControl/Shared/MapPolyline.cs +++ b/MapControl/Shared/MapPolyline.cs @@ -57,10 +57,7 @@ namespace MapControl protected override void UpdateData() { - ((PathGeometry)Data).Figures = GetPathFigures(Locations, false); -#if AVALONIA - InvalidateGeometry(); -#endif + SetPathFigures(GetPathFigures(Locations, true)); } } } diff --git a/MapControl/WPF/MapPath.WPF.cs b/MapControl/WPF/MapPath.WPF.cs index 794037ca..27a383c0 100644 --- a/MapControl/WPF/MapPath.WPF.cs +++ b/MapControl/WPF/MapPath.WPF.cs @@ -84,6 +84,11 @@ namespace MapControl return true; } + protected void SetPathFigures(PathFigureCollection pathFigures) + { + ((PathGeometry)Data).Figures = pathFigures; + } + protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) { if (locations.Count() >= 2) diff --git a/MapControl/WinUI/MapPath.WinUI.cs b/MapControl/WinUI/MapPath.WinUI.cs index 6d07610d..98a9135a 100644 --- a/MapControl/WinUI/MapPath.WinUI.cs +++ b/MapControl/WinUI/MapPath.WinUI.cs @@ -58,6 +58,11 @@ namespace MapControl UpdateData(); } + protected void SetPathFigures(PathFigureCollection pathFigures) + { + ((PathGeometry)Data).Figures = pathFigures; + } + protected void AddPolylinePoints(PathFigureCollection pathFigures, IEnumerable locations, double longitudeOffset, bool closed) { if (locations.Count() >= 2)