Click here to Skip to main content
Licence CPOL
First Posted 10 May 2009
Views 11,652
Downloads 97
Bookmarked 11 times

Finger Gesture Support for the Compact Framework

By | 10 May 2009 | Article
An article on finger gesture support for a Pocket PC app.

Introduction

Getting your Windows Mobile application to compete with the iPhone can be difficult. Here is a quick way to get the finger gesture support on your Windows Forms. This little snippet can integrate four way gesture support for your Mobile app.

Using the Code

Just copy and paste the class level variables and the two events, and instantly you will have gesture support.

public partial class Form1 :  Form
{

    private   int  startPositionY = 0;
    private   int  startPositionX = 0;
    //Configurable Points for your device so you can support 
    //different screen sizes . This would work on a 240x320 
    // To support a 320x240 you can switch the values
    // to support a 240x240 make them both 25
    private   const   int  Touch_ThresholdY = 100; 
    private   const   int  Touch_ThresholdX = 25;  

    public  Form1()
    {
        InitializeComponent();
    }

    private   void  Form1_MouseDown( object  sender,  MouseEventArgs  e)
    {
        startPositionY = e.Y;
        startPositionX = e.X;
    }

    private   void  Form1_MouseUp( object  sender,  MouseEventArgs  e)
    {
        if  (startPositionX > e.X && startPositionY < e.Y) 
        {
            if  ((e.Y - startPositionY) > Touch_ThresholdY)
            {
                 MessageBox .Show(\cf4 "Finger Down" );
            }
            else   if  ((startPositionX - e.X) > Touch_ThresholdX)
            {
                 MessageBox .Show(\cf4 "Finger Left" );
            }
        }
        else   if  (startPositionX < e.X && startPositionY > e.Y) 
        {
            if  ((startPositionY - e.Y) > Touch_ThresholdY)
            {
                 MessageBox .Show(\cf4 "Finger Up" );
            }
            else   if  ((e.X - startPositionX) > Touch_ThresholdX)
            {
                 MessageBox .Show(\cf4 "Finger Right" );
            }
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

VbGuru613

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 2 Pinmembertoms22:45 21 Sep '09  
GeneralThis is great! Pinmembergciochina23:05 20 May '09  
GeneralRe: This is great! PinmemberVbGuru6139:13 23 Jun '09  
GeneralMy vote of 1 PinmemberMark Nischalke3:09 11 May '09  
GeneralSimilar solution but making use of the Unit Circle. PinmemberM.K.A. Monster19:14 10 May '09  
GeneralRe: Similar solution but making use of the Unit Circle. PinmemberMark Nischalke3:13 11 May '09  
GeneralRe: Similar solution but making use of the Unit Circle. PinmemberVbGuru6136:05 11 May '09  
GeneralMy vote of 1 PinmemberMohammadAmiry18:39 10 May '09  
GeneralRe: My vote of 1 PinmemberVbGuru6132:45 11 May '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120528.1 | Last Updated 10 May 2009
Article Copyright 2009 by VbGuru613
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid