mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-13 21:16:35 +08:00
33 lines
1.1 KiB
C#
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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|