HP Dx9000 Resources for Developing Touch-Friendly Applications for HP Business - Page 20

Window1.xaml.cs

Page 20 highlights

the two contact points using stylus events in his blog. First, he enabled touch events to the application. Then he subscribed to stylus events and identified the two touch points via the touch IDs. In the example, two squares, one black and one red appear at the touch down locations. The squares move accordingly to the touch contacts and disappear when the touches are released. Window1.xaml Window1.xaml.cs 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; using System.Windows.Interop; using System.Runtime.InteropServices; using System.Diagnostics; namespace MultitouchTest { public partial class Window1 : Window { #region Class Variables private int Touch1ID = 0; private int Touch2ID = 0; // id for first touch contact // id for second touch contact #endregion #region P/Invoke // just a little interop. It's different this time! [DllImport("user32.dll")] public static extern bool SetProp(IntPtr hWnd, string lpString, IntPtr hData); 20

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

20
the two contact points using stylus events in his blog. First, he enabled touch events
to the application. Then he subscribed to stylus events and identified the two touch
points via the touch IDs. In the example, two squares, one black and one red
appear at the touch down locations. The squares move accordingly to the touch
contacts and disappear when the touches are released.
Window1.xaml
<Window x:Class="MultitouchTest.Window1"
Title="Window1" Height="800" Width="1200">
<Canvas>
<Rectangle Canvas.Left="-20" Canvas.Top="0" Height="20"
Name="Touch1" Stroke="Black" Fill="Black"
Width="20" />
<Rectangle Canvas.Left="-20" Canvas.Top="0" Height="20"
Name="Touch2" Stroke="Red" Width="20" Fill="Red" />
</Canvas>
</Window>
Window1.xaml.cs
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;
using System.Windows.Interop;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace MultitouchTest
{
public partial class Window1 : Window
{
#region Class Variables
private int Touch1ID = 0;
// id for first touch contact
private int Touch2ID = 0;
// id for second touch contact
#endregion
#region P/Invoke
// just a little interop.
It's different this time!
[DllImport("user32.dll")]
public static extern bool SetProp(IntPtr hWnd, string lpString,
IntPtr hData);