XAML-Map-Control/MapControl/WPF/MapPanel.WPF.cs

52 lines
1.8 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2025-01-01 18:57:55 +01:00
// Copyright © Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
2024-05-20 23:24:34 +02:00
using System.Collections.Generic;
using System.Linq;
using System.Windows;
2024-05-20 23:24:34 +02:00
using System.Windows.Media;
namespace MapControl
{
public partial class MapPanel
{
2024-05-27 11:05:22 +02:00
public static readonly DependencyProperty AutoCollapseProperty =
DependencyPropertyHelper.RegisterAttached< bool>("AutoCollapse", typeof(MapPanel));
2024-05-27 11:05:22 +02:00
public static readonly DependencyProperty LocationProperty =
DependencyPropertyHelper.RegisterAttached<Location>("Location", typeof(MapPanel), null,
2024-05-27 11:05:22 +02:00
FrameworkPropertyMetadataOptions.AffectsParentArrange);
public static readonly DependencyProperty BoundingBoxProperty =
DependencyPropertyHelper.RegisterAttached<BoundingBox>("BoundingBox", typeof(MapPanel), null,
2024-05-27 11:05:22 +02:00
FrameworkPropertyMetadataOptions.AffectsParentArrange);
2024-08-28 14:39:49 +02:00
protected IEnumerable<FrameworkElement> ChildElements => InternalChildren.OfType<FrameworkElement>();
2021-01-17 00:31:30 +01:00
public MapPanel()
{
2021-01-17 00:31:30 +01:00
if (this is MapBase)
{
2024-05-20 23:24:34 +02:00
SetValue(ParentMapProperty, this);
2021-01-17 00:31:30 +01:00
}
}
2021-01-17 00:31:30 +01:00
public static MapBase GetParentMap(FrameworkElement element)
{
2021-01-17 00:31:30 +01:00
return (MapBase)element.GetValue(ParentMapProperty);
}
2024-05-20 23:24:34 +02:00
public static void SetRenderTransform(FrameworkElement element, Transform transform, double originX = 0d, double originY = 0d)
{
element.RenderTransform = transform;
element.RenderTransformOrigin = new Point(originX, originY);
}
private static void SetVisible(FrameworkElement element, bool visible)
{
2024-05-20 23:24:34 +02:00
element.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
}
}
}