harmono
asked on
How can I create a "hello world" touchscreen ap for Windows 7?
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.MainWin dow' does not contain a definition for 'Window_ManipulationStarti ng' and no extension method 'Window_ManipulationStarti ng' accepting a first argument of type 'BasicManipulation.MainWin dow' could be found (are you missing a using directive or an assembly reference?) F:\Users\Casey\Documents\V isual Studio 2010\Projects\WpfTouch\Wpf Touch\Main Window.xam l 6 159 WpfTouch
Here is the XAML:
<Window x:Class="BasicManipulation .MainWindo w"
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="Wind ow_Manipul ationStart ing"
ManipulationDelta="Window_ Manipulati onDelta"
ManipulationInertiaStartin g="Window_ InertiaSta rting">
<Window.Resources>
<!--The movement, rotation, and size of the Rectangle is
specified by its RenderTransform.-->
<MatrixTransform x:Key="InitialMatrixTransf orm">
<MatrixTransform.Matrix>
<Matrix OffsetX="200" OffsetY="200"/>
</MatrixTransform.Matrix>
</MatrixTransform>
</Window.Resources>
<Canvas>
<Rectangle Fill="Red" Name="manRect"
Width="200" Height="200"
RenderTransform="{StaticRe source InitialMatrixTransform}"
IsManipulationEnabled="tru e" />
</Canvas>
</Window>
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.MainWin
Here is the XAML:
<Window x:Class="BasicManipulation
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="Wind
ManipulationDelta="Window_
ManipulationInertiaStartin
<Window.Resources>
<!--The movement, rotation, and size of the Rectangle is
specified by its RenderTransform.-->
<MatrixTransform x:Key="InitialMatrixTransf
<MatrixTransform.Matrix>
<Matrix OffsetX="200" OffsetY="200"/>
</MatrixTransform.Matrix>
</MatrixTransform>
</Window.Resources>
<Canvas>
<Rectangle Fill="Red" Name="manRect"
Width="200" Height="200"
RenderTransform="{StaticRe
IsManipulationEnabled="tru
</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;
}
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
ASKER
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.
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.
ASKER
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.
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.
ASKER
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
http://www.touchsmartdevzone.com/article/95/An-HP-TouchSmart-Application-Development-Guidelines-Primer/?textpage=2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Surface SDK Link