Add visual extensions

This commit is contained in:
chinboy
2025-05-25 14:23:43 +08:00
committed by CHINBOY
parent 0130ba9cde
commit 6e9c8b2788
2 changed files with 27 additions and 0 deletions
@@ -1,3 +1,8 @@
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System.Diagnostics;
namespace AtomUI.Controls.Utils;
@@ -0,0 +1,22 @@
using Avalonia;
namespace AtomUI.Controls.Utils;
public static class VisualExtensions
{
internal static Point Translate(this Visual fromElement, Visual toElement, Point fromPoint)
{
if (fromElement == toElement)
{
return fromPoint;
}
var transform = fromElement.TransformToVisual(toElement);
if (transform.HasValue)
{
return fromPoint.Transform(transform.Value);
}
return fromPoint;
}
}