2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2012-11-23 16:16:09 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class MapPanel
|
|
|
|
|
|
{
|
2019-07-08 23:00:57 +02:00
|
|
|
|
public static readonly DependencyProperty LocationProperty = DependencyProperty.RegisterAttached(
|
|
|
|
|
|
"Location", typeof(Location), typeof(MapPanel),
|
|
|
|
|
|
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsParentArrange));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty BoundingBoxProperty = DependencyProperty.RegisterAttached(
|
|
|
|
|
|
"BoundingBox", typeof(BoundingBox), typeof(MapPanel),
|
|
|
|
|
|
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsParentArrange));
|
|
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
private static readonly DependencyPropertyKey ParentMapPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
|
2019-07-08 23:00:57 +02:00
|
|
|
|
"ParentMap", typeof(MapBase), typeof(MapPanel),
|
|
|
|
|
|
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits, ParentMapPropertyChanged));
|
2012-11-23 16:16:09 +01:00
|
|
|
|
|
2020-03-28 21:53:38 +01:00
|
|
|
|
private static readonly DependencyPropertyKey ViewPositionPropertyKey = DependencyProperty.RegisterAttachedReadOnly(
|
|
|
|
|
|
"ViewPosition", typeof(Point?), typeof(MapPanel), new PropertyMetadata());
|
2018-04-30 23:13:50 +02:00
|
|
|
|
|
2013-04-12 19:59:16 +02:00
|
|
|
|
public static readonly DependencyProperty ParentMapProperty = ParentMapPropertyKey.DependencyProperty;
|
2020-03-28 21:53:38 +01:00
|
|
|
|
public static readonly DependencyProperty ViewPositionProperty = ViewPositionPropertyKey.DependencyProperty;
|
2013-04-12 19:59:16 +02:00
|
|
|
|
|
2021-01-17 00:31:30 +01:00
|
|
|
|
public MapPanel()
|
2012-11-23 16:16:09 +01:00
|
|
|
|
{
|
2021-01-17 00:31:30 +01:00
|
|
|
|
if (this is MapBase)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetValue(ParentMapPropertyKey, this);
|
|
|
|
|
|
}
|
2012-11-23 16:16:09 +01:00
|
|
|
|
}
|
2013-04-12 19:59:16 +02:00
|
|
|
|
|
2021-01-17 00:31:30 +01:00
|
|
|
|
public static MapBase GetParentMap(FrameworkElement element)
|
2013-04-12 19:59:16 +02:00
|
|
|
|
{
|
2021-01-17 00:31:30 +01:00
|
|
|
|
return (MapBase)element.GetValue(ParentMapProperty);
|
2013-04-12 19:59:16 +02:00
|
|
|
|
}
|
2018-04-30 23:13:50 +02:00
|
|
|
|
|
2023-01-14 18:41:10 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the attached ViewPosition property of an element. The method is called during
|
|
|
|
|
|
/// ArrangeOverride and may be overridden to modify the actual view position value.
|
|
|
|
|
|
/// An overridden method should call this method to set the attached property.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected virtual void SetViewPosition(FrameworkElement element, ref Point? position)
|
2018-04-30 23:13:50 +02:00
|
|
|
|
{
|
2022-11-05 17:32:29 +01:00
|
|
|
|
element.SetValue(ViewPositionPropertyKey, position);
|
2018-04-30 23:13:50 +02:00
|
|
|
|
}
|
2012-11-23 16:16:09 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|