锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / 语音识别开源 / Windows多点触摸笔迹画板例子

服务方向

人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发

联系方式

固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

Windows多点触摸笔迹画板例子

 

大概看了下代码,核心在于WMTouchEventArgs里的id,我win10的PC,测试没有效果,可能在支持多点屏幕上才会有效果吧。如果初学者看不明白代码,30元全程指导。

 

Demonstrates how to enable and handle multi-touch window messages in a managed application. 演示如何在托管应用程序中启用和处理多点触摸窗口消息。

MultiTouch sample application. Single window, where user can draw using multiple fingers at the same time. The trace of the primary finger, the one that was put on the digitizer first, is drawn in black. Secondary fingers are drawn in six other colors: red, green, blue, cyan, magenta and yellow. MultiTouch示例应用程序。单窗口,用户可以同时使用多个手指进行绘制。主手指(首先放在数字化仪上的手指)的轨迹以黑色绘制。辅助手指用其他六种颜色绘制:红色,绿色,蓝色,青色,洋红色和黄色。

It is an example of the neccessary infrastructure for handling multi-touch events inside a managed application. The application receives WM_TOUCH window messages. Demonstrates how to register a window to receive WM_TOUCH messages; how to unpack WM_TOUCH message parameters and how to use them. In addition, it also shows how to store the strokes and draw them on appropriate events. Demonstrates: RegisterTouchWindow, GetTouchInputInfo, CloseTouchInputHandle, WM_TOUCH.
它是在托管应用程序中处理多点触摸事件所必需的基础结构示例。该应用程序接收WM_TOUCH窗口消息。演示如何注册一个窗口以接收WM_TOUCH消息;如何解压缩WM_TOUCH消息参数以及如何使用它们。此外,它还显示了如何存储笔画并在适当的事件上绘制它们。演示:RegisterTouchWindow,GetTouchInputInfo,CloseTouchInputHandle,WM_TOUCH。

win多点触摸例子

The Windows Touch Scratchpad sample in C# shows how to use Windows Touch messages to draw traces of the touch points to a window. The trace of the primary finger, the one that was put on the digitizer first, is drawn in black. Secondary fingers are drawn in six other colors: red, green, blue, cyan, magenta, and yellow. The following image shows how the application could look when it runs. 展示了如何使用Windows Touch消息将接触点的痕迹绘制到窗口上。主手指(首先放在数字化仪上的手指)的轨迹以黑色绘制。辅助手指以其他六种颜色绘制:红色,绿色,蓝色,青色,洋红色和黄色。下图显示了该应用程序在运行时的外观。

private void OnLoadHandler(Object sender, EventArgs e)
        {
            try
            {
                // Registering the window for multi-touch, using the default settings.
                // p/invoking into user32.dll
                if (!RegisterTouchWindow(this.Handle, 0))
                {
                    Debug.Print("ERROR: Could not register window for multi-touch");
                }
            }
            catch (Exception exception)
            {
                Debug.Print("ERROR: RegisterTouchWindow API not available");
                Debug.Print(exception.ToString());
                MessageBox.Show("RegisterTouchWindow API not available", "MTScratchpadWMTouch ERROR",
                    MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0);
            }
        }
(...)
        [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
        protected override void WndProc(ref Message m)
        {
            // Decode and handle WM_TOUCH message.
            bool handled;
            switch (m.Msg)
            {
                case WM_TOUCH:
                    handled = DecodeTouch(ref m);
                    break;
                default:
                    handled = false;
                    break;
            }

            // Call parent WndProc for default message processing.
            base.WndProc(ref m);

            if (handled)
            {
                // Acknowledge event if handled.
                m.Result = new System.IntPtr(1);
            }
        }

The following code shows how the Windows Touch message is interpreted and the data is added to stroke collections.
以下代码显示了如何解释Windows Touch消息以及如何将数据添加到笔划集合。

private bool DecodeTouch(ref Message m)
        {
            // More than one touchinput may be associated with a touch message,一个消息里有多个触摸输入
            // so an array is needed to get all event information.
            int inputCount = LoWord(m.WParam.ToInt32()); // Number of touch inputs, actual per-contact messages

            TOUCHINPUT[] inputs; // Array of TOUCHINPUT structures
            inputs = new TOUCHINPUT[inputCount]; // Allocate the storage for the parameters of the per-contact messages

            // Unpack message parameters into the array of TOUCHINPUT structures, each
            // representing a message for one single contact.
            if (!GetTouchInputInfo(m.LParam, inputCount, inputs, touchInputSize))
            {
                // Get touch info failed.
                return false;
            }

            // For each contact, dispatch the message to the appropriate message
            // handler.
            bool handled = false; // Boolean, is message handled
            for (int i = 0; i <inputCount; i++) { TOUCHINPUT ti /> handler = null;     // Touch event handler
                if ((ti.dwFlags & TOUCHEVENTF_DOWN) != 0)
                {
                    handler = Touchdown;
                }
                else if ((ti.dwFlags & TOUCHEVENTF_UP) != 0)
                {
                    handler = Touchup;
                }
                else if ((ti.dwFlags & TOUCHEVENTF_MOVE) != 0)
                {
                    handler = TouchMove;
                }

                // Convert message parameters into touch event arguments and handle the event.
                if (handler != null)
                {
                    // Convert the raw touchinput message into a touchevent.
                    WMTouchEventArgs te = new WMTouchEventArgs(); // Touch event arguments

                    // TOUCHINFO point coordinates and contact size is in 1/100 of a pixel; convert it to pixels.
                    // Also convert screen to client coordinates.
                    te.ContactY = ti.cyContact/100;
                    te.ContactX = ti.cxContact/100;
                    te.Id = ti.dwID;
                    {
                        Point pt = PointToClient(new Point(ti.x/100, ti.y/100));
                        te.LocationX = pt.X;
                        te.LocationY = pt.Y;
                    }
                    te.Time = ti.dwTime;
                    te.Mask = ti.dwMask;
                    te.Flags = ti.dwFlags;

                    // Invoke the event handler.
                    handler(this, te);

                    // Mark this event as handled.
                    handled = true;
                }
            }

            CloseTouchInputHandle(m.LParam);

            return handled;
        }
    }

The following code shows how a stroke collection is displayed. 以下代码显示了笔划集合的显示方式。

public void Draw(Graphics graphics)
        {
            if ((points.Count < 2) || (graphics == null))
            {
                return;
            }

            Pen pen = new Pen(color, penWidth);
            graphics.DrawLines(pen, (Point[]) points.ToArray(typeof(Point)));
        }

he following code shows how the individual stroke objects display themselves with a Graphics object. 以下代码显示了单个笔画对象如何与Graphics对象一起显示。

 public void Draw(Graphics graphics)
        {
            if(points.Count < 2 || graphics == null)
            {
                return;
            }

            Pen pen = new Pen(color, penWidth);
            graphics.DrawLines(pen, (Point[]) points.ToArray(typeof(Point)));
        }
友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内