• 判断Mouse事件源类型


      //鼠标事件源类型
    public enum MouseEventSource { Mouse, Pen, Touch } /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); inkcv.PreviewMouseDown += Inkcv_PreviewMouseDown; inkcv.PreviewMouseMove += Inkcv_PreviewMouseMove; inkcv.PreviewMouseUp += Inkcv_PreviewMouseUp; } private void Inkcv_PreviewMouseUp(object sender, MouseButtonEventArgs e) { var s = GetMouseEventSource(); result.Text = "mouse up,Source: "+ s.ToString(); } private void Inkcv_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton==MouseButtonState.Pressed) { result.Text ="mouse move,Source: "+ GetMouseEventSource().ToString(); } } private void Inkcv_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var s = GetMouseEventSource(); result.Text = "mouse previewdown,Source: "+ s.ToString(); } [DllImport("user32.dll")] private static extern uint GetMessageExtraInfo(); public static MouseEventSource GetMouseEventSource() { uint extra = GetMessageExtraInfo(); bool isTouchOrPen = ((extra & 0xffffff00) == 0xff515700); if (!isTouchOrPen) return MouseEventSource.Mouse; bool isTouch = ((extra & 0x00000080) == 0x00000080); return isTouch ? MouseEventSource.Touch : MouseEventSource.Pen; } }
  • 相关阅读:
    Java
    Java
    Java
    Java
    Java
    Hang Gliding线段树
    Biggest Number深搜
    2021年暑假康复性训练(Codeforces Round #731 (Div. 3))全题解
    Python GUI tkinter 随机生成题目
    ModuleNotFoundError: No module named ‘exceptions‘ 情况解决
  • 原文地址:https://www.cnblogs.com/TianPing/p/10382009.html
Copyright © 2020-2023  润新知