http://www.scilor.com/hd2-leo-dotNetCfMultiTouchDLL.html

SciLor's HD2 / Leo Multitouch .NET CF DLL

v0.2 (2010-02-15)

Windows Mobile and HTC HD2

Projects using this libary: HD2Wobble - GRemote Pro - Air Hockey D2

Video from HERE

SciLor's .NET CF MultiTouch DLL v0.1 adds MultiTouch-Support to your existing .NET CF software very easily (Currently only for the HD2):
If I release a new DLL, it WILL be fully compatible to the previous one!


First of all you will have to add your app to the PinchToZoom Whitelist in the registry:
[HKEY_LOCAL_MACHINE\Software\HTC\TouchGL\Pinch\WhiteList\YourApp]"ProcName"="YouAppProcessName.exe"
After adding, soft reset!

Then add the "SciLors-MultiTouch.dll" as reference in your Visual Studio project. Beware, it is not allowed to change the assembly name! It must stay "SciLors-MultiTouch.dll" or it will not work!

Afterwards declare the MultiTouch Class:
VB.NET:
Dim myMultiTouch As New SciLorsMultiTouch.SciLorsMultiTouch

C#:
SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();

Then you add following to your Form_Load event:
VB.NET:
Call myMultiTouch.CatchWndProc(Me)AddHandler myMultiTouch.MouseDown, AddressOf frmMain_MouseDownAddHandler myMultiTouch.MouseMove, AddressOf frmMain_MouseMoveAddHandler myMultiTouch.MouseUp, AddressOf frmMain_MouseUp

C#:
myMultiTouch.CatchWndProc(this);myMultiTouch.MouseDown += frmMain_MouseDown;myMultiTouch.MouseMove += frmMain_MouseMove;myMultiTouch.MouseUp += frmMain_MouseUp;

Now, at every MultiTouch Event it gets delegated to your frmMain_Mouse* procedures (There will be always 2 Events fired due to there existing 2 Fingers on the screen ;) ). You can easily detect wheather the mouse event comes from a normal mouse-press or a multitouch finger.
Single Finger:Windows.Forms.MouseButtons.None or MouseButton = Windows.Forms.MouseButtons.LeftMultiTouch:Finger 1: Windows.Forms.MouseButtons.MiddleFinger 2: Windows.Forms.MouseButtons.Right

Code Examples:
VB.NET:
Public Structure MouseStateDim Position As PointDim MouseDown As BooleanEnd StructurePublic Fingers(2) As MouseStatePublic Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseDownDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = TrueEnd WithEnd SubPublic Sub frmMain_MouseMoveByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseMoveDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = TrueEnd WithEnd SubPublic Sub frmMain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseUpDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = FalseEnd WithEnd SubPrivate Function ButtonToID(ByVal MouseButton As MouseButtons)If MouseButton = Windows.Forms.MouseButtons.None Or MouseButton = Windows.Forms.MouseButtons.Left ThenReturn 0ElseIf MouseButton = Windows.Forms.MouseButtons.Middle ThenReturn 1ElseReturn 2End IfEnd Function

C#:
public struct MouseState{public Point Position;public bool MouseDown;}public MouseState[] Fingers = new MouseState[3];public void pctDraw_MouseDown(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = true;}public void pctDraw_MouseMove(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = true;}public void pctDraw_MouseUp(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = false;}private object ButtonToID(MouseButtons MouseButton){if ((MouseButton == MouseButtons.None) | (MouseButton == MouseButtons.Left)){return 0;}if (MouseButton == MouseButtons.Middle){return 1;}return 2;}


Function Description/Documentation:
-CatchWndProc(myForm, Optional PositionFixX, Optional PositionFixY): Redirects the Windows Messages from the "myForm" to the Multitouch Class. If you want to use it for a Control on top of the Form, the PositionFix can add/remove constant values to the returned MouseMessages.
-RestoreWndProc(): Detaches the Multitouch Class from the Form to restore the normal Window Message flow.
-UpdatePositionFix(PositionFixX, PositionFixY): If your control has changed it's position you can change its position in the class
-UpdateFormTopLeft(PositionFixLeft, PositionFixTop): If the Top-Left Corner of the Form changes you may use this.
-GetInformation(): Gives a Information String of the Multitouch DLL. It includes the version and some contact information.


-Multiple Instances per Form are not supported and not needed (Multitouch events fire allways, everywhere on the form)!
-The Mouse-Coordinates are allways relative to the forms top-left corner.

ReadMe.txt (without code)

SciLor's .NET CF MultiTouch DLL v0.2                            i.                            .7.                           .. :v                          c:  .X                           i.::                             :                            ..i..                           #MMMMM                           QM  AM                           9M  zM                           6M  AM                           2M  2MX#MM@1.                           OM  tMMMMMMMMMM;                      .X#MMMM  ;MMMMMMMMMMMMv                  cEMMMMMMMMMU7@MMMMMMMMMMMMM@            .n@MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM           MMMMMMMM@@#$BWWB#@@#$WWWQQQWWWWB#@MM.           MM                                ;M.           $M                                EM           WMO$@@@@@@@@@@@@@@@@@@@@@@@@@@@@#OMM           #M                                cM           QM         Another Cake by        tM           MM              SciLor            CMO        .MMMM                                oMMMt       1MO 6MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM iMM      .M1  BM     For all Portal Lovers!     vM  ,Mt      1M   @M............................... WM   M6       MM  .A8OQWWWWWWWWWWWWWWWWWWWWWWWWWWWOAz2  #M        MM                                      MM.         @MMY                                vMME           UMMMbi                        i8MMMt              C@MMMMMbt;;i.......i;XQMMMMMMt                   ;ZMMMMMMMMMMMMMMM@A;.ReadMeYou will need the .NET CF 2.0This DLL adds MultiTouch-Support to your existing .NET CF software very easily (Currently only for the HD2):First of all you will have to add your app to the PinchToZoom Whitelist in the registry:[HKEY_LOCAL_MACHINE\Software\HTC\TouchGL\Pinch\WhiteList\YourApp]"ProcName"="YouAppProcessName.exe"After adding, soft reset!Then add the "SciLors-MultiTouch.dll" as reference in your Visual Studio project. Beware, it is not allowed to change the assembly name! It must stay "SciLors-MultiTouch.dll" or it will not work!Afterwards declare the MultiTouch Class:VB.NET:Dim myMultiTouch As New SciLorsMultiTouch.SciLorsMultiTouchC#:SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();Then you add following to your Form_Load event:VB.NET:Call myMultiTouch.CatchWndProc(Me)AddHandler myMultiTouch.MouseDown, AddressOf frmMain_MouseDownAddHandler myMultiTouch.MouseMove, AddressOf frmMain_MouseMoveAddHandler myMultiTouch.MouseUp, AddressOf frmMain_MouseUpC#:myMultiTouch.CatchWndProc(this);myMultiTouch.MouseDown += frmMain_MouseDown;myMultiTouch.MouseMove += frmMain_MouseMove;myMultiTouch.MouseUp += frmMain_MouseUp;Now, at every MultiTouch Event it gets delegated to your frmMain_Mouse* procedures (There will be always 2 Events fired due to there existing 2 Fingers on the screen ;) ). You can easily detect wheather the mouse event comes from a normal mouse-press or a multitouch finger.Single Finger:Windows.Forms.MouseButtons.None or MouseButton = Windows.Forms.MouseButtons.LeftMultiTouch:Finger 1: Windows.Forms.MouseButtons.MiddleFinger 2: Windows.Forms.MouseButtons.RightCode Examples:VB.NET:Public Structure MouseStateDim Position As PointDim MouseDown As BooleanEnd StructurePublic Fingers(2) As MouseStatePublic Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseDownDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = TrueEnd WithEnd SubPublic Sub frmMain_MouseMoveByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseMoveDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = TrueEnd WithEnd SubPublic Sub frmMain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseUpDim ButtonID As Byte = ButtonToID(e.Button)With Fingers(ButtonID).Position.X = e.X.Position.Y = e.Y.MouseDown = FalseEnd WithEnd SubPrivate Function ButtonToID(ByVal MouseButton As MouseButtons)If MouseButton = Windows.Forms.MouseButtons.None Or MouseButton = Windows.Forms.MouseButtons.Left ThenReturn 0ElseIf MouseButton = Windows.Forms.MouseButtons.Middle ThenReturn 1ElseReturn 2End IfEnd FunctionC#:public struct MouseState{public Point Position;public bool MouseDown;}public MouseState[] Fingers = new MouseState[3];public void pctDraw_MouseDown(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = true;}public void pctDraw_MouseMove(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = true;}public void pctDraw_MouseUp(object sender, MouseEventArgs e){int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));this.Fingers[ButtonID].Position.X = e.X;this.Fingers[ButtonID].Position.Y = e.Y;this.Fingers[ButtonID].MouseDown = false;}private object ButtonToID(MouseButtons MouseButton){if ((MouseButton == MouseButtons.None) | (MouseButton == MouseButtons.Left)){return 0;}if (MouseButton == MouseButtons.Middle){return 1;}return 2;}Function Description/Documentation:-CatchWndProc(myForm, Optional PositionFixX, Optional PositionFixY): Redirects the Windows Messages from the "myForm" to the Multitouch Class. If you want to use it for a Control on top of the Form, the PositionFix can add/remove constant values to the returned MouseMessages.-RestoreWndProc(): Detaches the Multitouch Class from the Form to restore the normal Window Message flow.-UpdatePositionFix(PositionFixX, PositionFixY): If your control has changed it's position you can change its position in the class-UpdateFormTopLeft(PositionFixLeft, PositionFixTop): If the Top-Left Corner of the Form changes you may use this.-GetInformation(): Gives a Information String of the Multitouch DLL. It includes the version and some contact information.ToDo:Additional:-Multiple Instances are not supported and not needed (Multitouch events fire allways, everywhere on the form)!-The Mouse-Coordinates are allways relative to the forms top-left corner.Known Bugs:If you like my hard work PLEASE DONATE! :)http://www.scilor.com/donate.htmlChangeLog:v0.2 (2010-02-15)-Enhancement: Added "UpdatePositionFix"/"UpdateForm" and "RestoreWndProc"-Enhancement: Added some Documentation-----------------------v0.1 (2009-12-07)-Initial Release---------------LINKS-------------------------My Website: http://www.scilor.com/SciLor's .NET CF MultiTouch DLL Website: http://www.scilor.com/hd2-leo-dotNetCfMultiTouchDLL.htmlDonation: http://www.scilor.com/donate.html-

SciLor's Multitouch .NET CF DLL v0.2

ZIP
ZIP scilors-hd2-leo-multitouch-demov02-dll - Download Button
Mirror
Please always link to this website and do NOT mirror my software!


Read more: http://www.scilor.com/hd2-leo-dotNetCfMultiTouchDLL.html#ixzz0xlmFqy76
posted on 2010-08-27 10:31  warkxp  阅读(301)  评论(0编辑  收藏  举报