Files
serein-flow/Serein.Workbench.Avalonia/Extension/PointerExtension.cs
2025-01-01 17:49:48 +08:00

33 lines
1.1 KiB
C#

using Avalonia.Controls;
using Avalonia.Input;
using Avalonia;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Workbench.Avalonia.Extension
{
internal static class PointerExtension
{
public static bool JudgePointer(this
PointerEventArgs eventArgs,
object? sender,
PointerType pointerType,
Func<PointerPointProperties,bool> judgePointerFunc)
{
if(sender is not Visual visual)
{
return false;
}
if (eventArgs.Pointer.Type == pointerType) // 是否是否是指定的设备类型
{
var point = eventArgs.GetCurrentPoint(visual); // 获取到点击点
return judgePointerFunc.Invoke(point.Properties); // 判断是否属于某种类型的点击
}
return false;
}
}
}