?
Solved

How can I create a "hello world" touchscreen ap for Windows 7?

Posted on 2011-09-29
8
Medium Priority
?
729 Views
Last Modified: 2012-06-27
My friend has an HP Touchsmart, and I'm curious how I could develop apps for it.

I read the MSDN article on how to get started but I'm not very advanced with WPF. I think I did everything right but I'm getting build errors like the below. It tells me to copy some XAML into the MainWindow XAML, then add some methods to the MainWindow class.
 
The InitializeComponent(); I had to comment out, because it had an error. I read up on that, and I have no idea how to follow the solution.

Error      1      'BasicManipulation.MainWindow' does not contain a definition for 'Window_ManipulationStarting' and no extension method 'Window_ManipulationStarting' accepting a first argument of type 'BasicManipulation.MainWindow' could be found (are you missing a using directive or an assembly reference?)      F:\Users\Casey\Documents\Visual Studio 2010\Projects\WpfTouch\WpfTouch\MainWindow.xaml      6      159      WpfTouch

Here is the XAML:
<Window x:Class="BasicManipulation.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Move, Size, and Rotate the Square"
        WindowState="Maximized"
        ManipulationStarting="Window_ManipulationStarting"
        ManipulationDelta="Window_ManipulationDelta"
        ManipulationInertiaStarting="Window_InertiaStarting">
    <Window.Resources>

        <!--The movement, rotation, and size of the Rectangle is
        specified by its RenderTransform.-->
        <MatrixTransform x:Key="InitialMatrixTransform">
            <MatrixTransform.Matrix>
                <Matrix OffsetX="200" OffsetY="200"/>
            </MatrixTransform.Matrix>
        </MatrixTransform>

    </Window.Resources>

    <Canvas>
        <Rectangle Fill="Red" Name="manRect"
                 Width="200" Height="200"
                 RenderTransform="{StaticResource InitialMatrixTransform}"
                 IsManipulationEnabled="true" />
    </Canvas>
</Window>


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            //InitializeComponent();
        }
        void Window_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
        {
            e.ManipulationContainer = this;
            e.Handled = true;
        }
        void Window_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {

            // Get the Rectangle and its RenderTransform matrix.
            Rectangle rectToMove = e.OriginalSource as Rectangle;
            Matrix rectsMatrix = ((MatrixTransform)rectToMove.RenderTransform).Matrix;

            // Rotate the Rectangle.
            rectsMatrix.RotateAt(e.DeltaManipulation.Rotation,
                                 e.ManipulationOrigin.X,
                                 e.ManipulationOrigin.Y);

            // Resize the Rectangle.  Keep it square 
            // so use only the X value of Scale.
            rectsMatrix.ScaleAt(e.DeltaManipulation.Scale.X,
                                e.DeltaManipulation.Scale.X,
                                e.ManipulationOrigin.X,
                                e.ManipulationOrigin.Y);

            // Move the Rectangle.
            rectsMatrix.Translate(e.DeltaManipulation.Translation.X,
                                  e.DeltaManipulation.Translation.Y);

            // Apply the changes to the Rectangle.
            rectToMove.RenderTransform = new MatrixTransform(rectsMatrix);

            Rect containingRect =
                new Rect(((FrameworkElement)e.ManipulationContainer).RenderSize);

            Rect shapeBounds =
                rectToMove.RenderTransform.TransformBounds(
                    new Rect(rectToMove.RenderSize));

            // Check if the rectangle is completely in the window.
            // If it is not and intertia is occuring, stop the manipulation.
            if (e.IsInertial && !containingRect.Contains(shapeBounds))
            {
                e.Complete();
            }


            e.Handled = true;
        }
        void Window_InertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {

            // Decrease the velocity of the Rectangle's movement by 
            // 10 inches per second every second.
            // (10 inches * 96 pixels per inch / 1000ms^2)
            e.TranslationBehavior.DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0);

            // Decrease the velocity of the Rectangle's resizing by 
            // 0.1 inches per second every second.
            // (0.1 inches * 96 pixels per inch / (1000ms^2)
            e.ExpansionBehavior.DesiredDeceleration = 0.1 * 96 / (1000.0 * 1000.0);

            // Decrease the velocity of the Rectangle's rotation rate by 
            // 2 rotations per second every second.
            // (2 * 360 degrees / (1000ms^2)
            e.RotationBehavior.DesiredDeceleration = 720 / (1000.0 * 1000.0);

            e.Handled = true;
        }


    }
}

Open in new window

0
Comment
Question by:harmono
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 36890256
you can Try Microsoft Surface SDK for Touch Screen Development.

Surface SDK Link
0
 
LVL 16

Assisted Solution

by:Kalpesh Chhatrala
Kalpesh Chhatrala earned 100 total points
ID: 36890259
Surface Sample available from below link

http://nsquaredsolutions.com/surfacebook/
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 36890715
I would say that it depends on the kind of application you want to build. Any regular application (good old WinForms) will work if the buttons are big enough to be used with the fingers!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:harmono
ID: 36894246
emoreau,

Actually I have tried to create a simple two button test app in both Windows Forms and WPF and they didn't work properly. Apparently the touchscreen does not send regular mouse events. I have not tried different mouse events, I was mainly trying the MouseDown, and MouseUp events and the preview click events, because I'm trying to avoid the delay caused by double-clicking since this is a music app.
So the above code was my third try at this using WPF and some event handlers. I'm not sure if the Touchsmart works differently than Windows touch, but the dev sites I checked seemed to indicate you could develop a regular app. Maybe this weekend I'll try using the click, and double-click events to see if the touch sends that event. It may be that I'm in some kind of "mode" I'm not familiar with. I haven't messed with the Touchsmart PC much at all, so I have no idea what you can do with it.
It looks like I should work with the Touchsmart SDK (reading a tutorial right now) experiment with that, then maybe with what I've learned try to make it more universal, or just complete the prototype for the touchsmart environment, there may be some benefits that I don't know about.

I don't put much demands on the graphics, or things like that, it's mainly just latentcy and real time that is my usual technical challenge, although it would be nice to have some good graphics later on.

0
 
LVL 1

Author Comment

by:harmono
ID: 36894253
kalpesh,

will that work with the HP Touchsmart? It has to work with that computer unless I decide to buy this Gateway that's on clearance.
0
 
LVL 1

Author Comment

by:harmono
ID: 36894444
I found this article on the touchsmartdevzone website. It covers the basics.

http://www.touchsmartdevzone.com/article/95/An-HP-TouchSmart-Application-Development-Guidelines-Primer/?textpage=2
0
 
LVL 7

Accepted Solution

by:
vbigham earned 900 total points
ID: 36894716
You should find that the wpf controls have at least some of the following events:
PreviewTouchDown
PreviewTouchMove
PreviewTouchUp
TouchDown
TouchEnter
TouchLeave
TouchMove
TouchUp

I have definitely used the TouchDown event on the TouchSmart.  I had the most success when I started using Commanding and attaching commands to buttons.  After that they seemed to work for touches and for the mouse.

For a full description about commanding:
http://msdn.microsoft.com/en-us/library/ms752308.aspx
(Check the very bottom of the article about creating custom commands implementing ICommand)

I don't know anything yet about using multitouch.. sorry.

Best of luck.
0
 
LVL 1

Author Closing Comment

by:harmono
ID: 36894997
Why this is not mentioned in so many articles I did not know, but this is exactly what I was looking for. This is a major breakthrough.
0

Featured Post

Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question