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

56 lines
2.2 KiB
C#
Raw Normal View History

2025-02-27 18:46:32 +01:00
using System.Collections.Generic;
2024-05-20 23:24:34 +02:00
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);
2025-08-12 10:57:44 +02:00
protected IEnumerable<FrameworkElement> ChildElements => Children.OfType<FrameworkElement>();
protected FrameworkElement GetChildElement(int index) => index < Children.Count ? (FrameworkElement)Children[index] : null;
protected void InsertChildElement(int index, FrameworkElement element) => Children.Insert(index, element);
protected void InsertChildElements(int index, IEnumerable<FrameworkElement> elements)
{
foreach (var element in elements)
{
Children.Insert(index++, element);
}
}
protected void RemoveChildElement(int index) => Children.RemoveAt(index);
protected void RemoveChildElements(int index, int count) => Children.RemoveRange(index, count);
2024-08-28 14:39:49 +02: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;
}
}
}