2025-11-19 23:34:39 +01:00
|
|
|
|
#if AVALONIA
|
2025-12-07 21:43:46 +01:00
|
|
|
|
global using UIElement = Avalonia.Controls.Control;
|
2025-11-19 23:34:39 +01:00
|
|
|
|
global using FrameworkElement = Avalonia.Controls.Control;
|
|
|
|
|
|
using Avalonia;
|
|
|
|
|
|
using Avalonia.Media;
|
|
|
|
|
|
#elif WPF
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#elif UWP
|
|
|
|
|
|
using Windows.UI.Xaml;
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#elif WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2025-12-07 21:43:46 +01:00
|
|
|
|
public static class UIElementExtension
|
2025-11-19 23:34:39 +01:00
|
|
|
|
{
|
2025-12-07 21:43:46 +01:00
|
|
|
|
public static void SetRenderTransform(this UIElement element, Transform transform, bool center = false)
|
2025-11-19 23:34:39 +01:00
|
|
|
|
{
|
|
|
|
|
|
element.RenderTransform = transform;
|
|
|
|
|
|
#if AVALONIA
|
|
|
|
|
|
element.RenderTransformOrigin = center ? RelativePoint.Center : RelativePoint.TopLeft;
|
|
|
|
|
|
#else
|
|
|
|
|
|
if (center)
|
|
|
|
|
|
{
|
|
|
|
|
|
element.RenderTransformOrigin = new Point(0.5, 0.5);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-07 21:43:46 +01:00
|
|
|
|
public static void SetVisible(this UIElement element, bool visible)
|
2025-11-19 23:34:39 +01:00
|
|
|
|
{
|
|
|
|
|
|
#if AVALONIA
|
|
|
|
|
|
element.IsVisible = visible;
|
|
|
|
|
|
#else
|
|
|
|
|
|
element.Visibility = visible ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|