Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Image Manipulation in Multitouch Development

, 3 Apr 2010 CPOL
In this article, I will describe Image manipulation in Windows 7 multitouch Environment
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
Win7_20MultiTouchAPI_1_.zip
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 Service 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)

Share

About the Author

Kunal Chowdhury (@kunal2383)
Team Leader
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik MVP, Nokia Developer Champion, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.
 
He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.
 
Technical Blog: http://www.kunal-chowdhury.com
Facebook: http://facebook.com/blog.kunal
Twitter : http://twitter.com/kunal2383
Follow on   Twitter   Google+   LinkedIn

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 3 Apr 2010
Article Copyright 2010 by Kunal Chowdhury (@kunal2383)
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid