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

39 lines
1.1 KiB
C#
Raw Normal View History

2024-05-19 23:23:27 +02:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © 2024 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using Avalonia.Controls;
using Avalonia.Media;
namespace MapControl
{
2024-05-20 23:24:34 +02:00
public partial class MapPanel
2024-05-19 23:23:27 +02:00
{
public MapPanel()
{
if (this is MapBase mapBase)
{
2024-05-20 23:24:34 +02:00
SetValue(ParentMapProperty, mapBase);
2024-05-19 23:23:27 +02:00
}
}
2024-05-20 23:24:34 +02:00
public static MapBase GetParentMap(Control element)
2024-05-19 23:23:27 +02:00
{
2024-05-20 23:24:34 +02:00
return (MapBase)element.GetValue(ParentMapProperty);
2024-05-19 23:23:27 +02:00
}
2024-05-20 23:24:34 +02:00
public static void SetRenderTransform(Control element, Transform transform, double originX = 0d, double originY = 0d)
2024-05-19 23:23:27 +02:00
{
2024-05-20 23:24:34 +02:00
element.RenderTransform = transform;
element.RenderTransformOrigin = new RelativePoint(originX, originY, RelativeUnit.Relative);
2024-05-19 23:23:27 +02:00
}
2024-05-20 23:24:34 +02:00
private Controls ChildElements => Children;
2024-05-19 23:23:27 +02:00
2024-05-20 23:24:34 +02:00
private static void SetVisible(Control element, bool visible)
2024-05-19 23:23:27 +02:00
{
2024-05-20 23:24:34 +02:00
element.IsVisible = visible;
2024-05-19 23:23:27 +02:00
}
}
}