Click here to Skip to main content
Click here to Skip to main content

Image Manipulation in Multitouch Development

By , 3 Apr 2010
 
Win7MultitouchDemo.zip
Win7MultitouchDemo
Win7MultitouchDemo.suo
Win7MultitouchDemo
images
Hydrangeas.jpg
Properties
Settings.settings
Windows7API
MultiTouchAPI
Windows7.Multitouch.WinForms
Properties
Windows7.Multitouch.WinForms.csproj.vspscc
Windows7.Multitouch.WPF
Properties
Windows7.Multitouch.WPF.csproj.vspscc
Windows7.Multitouch
Properties
Windows7.Multitouch.csproj.vspscc
Win7MultitouchDemo_1_.zip [file error]
Win7_20MultiTouchAPI_1_.zip [file error]
Win7_MultiTouchAPI.zip
MultiTouchAPI
Windows7.Multitouch.WinForms
Properties
Windows7.Multitouch.WinForms.csproj.vspscc
Windows7.Multitouch.WPF
Properties
Windows7.Multitouch.WPF.csproj.vspscc
Windows7.Multitouch
Properties
Windows7.Multitouch.csproj.vspscc
//-----------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using Windows7.Multitouch.Interop;

namespace Windows7.Multitouch.WinForms
{
    /// <summary>
    /// Represents a WinForms Control
    /// </summary>
    class ControlWrapper : IHwndWrapper
    {
        private readonly Control _control;

        public ControlWrapper(Control control)
        {
            //It is better to add this to the application manifest, but if the user
            //forgot to do that, we do.
            User32.SetProcessDPIAware();

            _control = control;
 
        }

        #region IHwndWrapper Members

        public IntPtr Handle
        {
            get { return _control.Handle; }
        }

        public object Source
        {
            get { return _control; }
        }


        public event EventHandler HandleCreated
        {
            add
            {
                _control.HandleCreated += value;
            }
            remove
            {
                _control.HandleCreated -= value;
            }
        }


        public event EventHandler HandleDestroyed
        {
            add
            {
                _control.HandleDestroyed += value;
            }
            remove
            {
                _control.HandleDestroyed -= value;
            }
        }
        
        public bool IsHandleCreated
        {
            get { return _control.IsHandleCreated; }
        }

        public Point PointToClient(Point point)
        {
            return _control.PointToClient(point);
        }


        public IGUITimer CreateTimer()
        {
            return new GUITimer();
        }

        #endregion
    }

    /// <summary>
    /// The WinForm GUI Timer for Inerta Events
    /// </summary>
    public class GUITimer : Timer, IGUITimer
    {
    }


    /// <summary>
    /// A factory that creates touch or gesture handler for a Windows Forms controls
    /// </summary>
    public class Factory
    {
        /// <summary>
        /// A factory that creates touch or gesture handler for a Windows Forms controls
        /// </summary>
        /// <remarks>We use factory to ensure that only one handler will be created for a control, since Gesture and Touch are mutually exclude</remarks>
        /// <typeparam name="T">The handler type</typeparam>
        /// <param name="control">The control that need touch or gesture events</param>
        /// <returns>TouchHandler or Gesture Handler</returns>
        public static T CreateHandler<T>(Control control) where T : Windows7.Multitouch.Handler
        {
            return Windows7.Multitouch.Handler.CreateHandler<T>(new ControlWrapper(control));
        }

        /// <summary>
        /// Create a wrapper for a UI based timer 
        /// </summary>
        /// <remarks>This timer is called in the context of the UI thread</remarks>
        /// <returns>A timer Wrapper</returns>
        public static IGUITimer CreateTimer()
        {
            return new GUITimer();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

About the Author

_ Kunal Chowdhury _
Software Developer
India India
Member
Kunal Chowdhury is a Microsoft MVP (Most Valuable Professional) in Silverlight Technology, a Codeproject MVP & Mentor, DZone MVB (Most Valuable Blogger), Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.
 
He is currently working as a Software Engineer II in an MNC located at Pune, India. He has a very good skill over XAML, C#, Silverlight and WPF. He has a good working experience in Windows 7 application (including Multi-touch) development too.
 
He posts his findings in his technical blog. He also writes for SilverlightShow and Codeproject portal. Many of his articles were highlighted as "Article of the Day" in Microsoft sites.
 
He also has another website called Silverlight-Zone.com where he posts article links on Silverlight, Windows Phone 7 and XNA accumulated from various web sites to help the community grow on specified technologies.
 
You can reach him in his Blog : http://www.kunal-chowdhury.com
He is also available in Twitter : http://twitter.com/kunal2383

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 3 Apr 2010
Article Copyright 2010 by _ Kunal Chowdhury _
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid