mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-26 03:00:28 +08:00
Add visual extensions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user