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

@ -15,13 +15,13 @@ namespace MapControl
new QuadraticEase { EasingMode = EasingMode.EaseOut });
public static readonly DependencyProperty CenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(),
DependencyPropertyHelper.Register<MapBase, Location>(nameof(Center), new Location(0d, 0d),
(map, oldValue, newValue) => map.CenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value),
true);
public static readonly DependencyProperty TargetCenterProperty =
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(),
DependencyPropertyHelper.Register<MapBase, Location>(nameof(TargetCenter), new Location(0d, 0d),
(map, oldValue, newValue) => map.TargetCenterPropertyChanged(newValue),
(map, value) => map.CoerceCenterProperty(value),
true);

View file

@ -1,47 +1,16 @@
using System.Windows;
using System.Windows.Controls;
namespace MapControl
{
/// <summary>
/// ContentControl placed on a MapPanel at a geographic location specified by the Location property.
/// </summary>
public class MapContentControl : ContentControl
public partial class MapContentControl
{
public static readonly DependencyProperty AutoCollapseProperty =
MapPanel.AutoCollapseProperty.AddOwner(typeof(MapContentControl));
public static readonly DependencyProperty LocationProperty =
MapPanel.LocationProperty.AddOwner(typeof(MapContentControl));
static MapContentControl()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapContentControl), new FrameworkPropertyMetadata(typeof(MapContentControl)));
}
/// <summary>
/// Gets/sets MapPanel.AutoCollapse.
/// </summary>
public bool AutoCollapse
{
get => (bool)GetValue(AutoCollapseProperty);
set => SetValue(AutoCollapseProperty, value);
}
/// <summary>
/// Gets/sets MapPanel.Location.
/// </summary>
public Location Location
{
get => (Location)GetValue(LocationProperty);
set => SetValue(LocationProperty, value);
}
}
/// <summary>
/// MapContentControl with a Pushpin Style.
/// </summary>
public class Pushpin : MapContentControl
public partial class Pushpin
{
static Pushpin()
{

View file

@ -6,13 +6,6 @@ namespace MapControl
{
public partial class MapItem
{
public static readonly DependencyProperty AutoCollapseProperty =
MapPanel.AutoCollapseProperty.AddOwner(typeof(MapItem));
public static readonly DependencyProperty LocationProperty =
MapPanel.LocationProperty.AddOwner(typeof(MapItem),
new FrameworkPropertyMetadata(null, (o, e) => ((MapItem)o).UpdateMapTransform()));
static MapItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MapItem), new FrameworkPropertyMetadata(typeof(MapItem)));

View file

@ -8,7 +8,7 @@ namespace MapControl
DependencyPropertyHelper.RegisterAttached< bool>("AutoCollapse", typeof(MapPanel));
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.RegisterAttached<Location>("Location", typeof(MapPanel), null,
DependencyPropertyHelper.RegisterAttached<Location?>("Location", typeof(MapPanel), null,
FrameworkPropertyMetadataOptions.AffectsParentArrange);
public static readonly DependencyProperty BoundingBoxProperty =

View file

@ -13,7 +13,7 @@ namespace MapControl
if (ParentMap != null && locations != null)
{
var longitudeOffset = GetLongitudeOffset(Location ?? locations.FirstOrDefault());
var longitudeOffset = GetLongitudeOffset(locations);
AddPolylinePoints(context, locations, longitudeOffset, closed);
}
@ -25,7 +25,7 @@ namespace MapControl
if (ParentMap != null && polygons != null)
{
var longitudeOffset = GetLongitudeOffset(Location);
var longitudeOffset = GetLongitudeOffset(polygons.FirstOrDefault());
foreach (var locations in polygons)
{