Changed class Location to readonly struct

This commit is contained in:
ClemensFischer 2026-02-01 22:56:50 +01:00
parent d7d7bba5f2
commit 6566167ff0
27 changed files with 194 additions and 307 deletions

View file

@ -1,10 +1,13 @@
#if WPF
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
#elif WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
#elif AVALONIA
@ -19,14 +22,17 @@ namespace MapControl
/// </summary>
public partial class MapItem : ListBoxItem, IMapElement
{
/// <summary>
/// Gets/sets MapPanel.AutoCollapse.
/// </summary>
public bool AutoCollapse
{
get => (bool)GetValue(AutoCollapseProperty);
set => SetValue(AutoCollapseProperty, value);
}
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.Register<MapItem, Location>(nameof(Location), default,
(item, oldValue, newValue) =>
{
MapPanel.SetLocation(item, newValue);
item.UpdateMapTransform();
});
public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.Register<MapItem, bool>(nameof(AutoCollapse), false,
(item, oldValue, newValue) => MapPanel.SetAutoCollapse(item, newValue));
/// <summary>
/// Gets/sets MapPanel.Location.
@ -37,6 +43,15 @@ namespace MapControl
set => SetValue(LocationProperty, value);
}
/// <summary>
/// Gets/sets MapPanel.AutoCollapse.
/// </summary>
public bool AutoCollapse
{
get => (bool)GetValue(AutoCollapseProperty);
set => SetValue(AutoCollapseProperty, value);
}
/// <summary>
/// Implements IMapElement.ParentMap.
/// </summary>
@ -94,7 +109,7 @@ namespace MapControl
private void UpdateMapTransform()
{
if (MapTransform != null && ParentMap != null && Location != null)
if (MapTransform != null && ParentMap != null)
{
MapTransform.Matrix = ParentMap.GetMapToViewTransform(Location);
}