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

Windows 7 Multi-touch Using WPF

Page 22 highlights

Touch2ID = e.StylusDevice.Id; // move the rectangle to the given location Touch2.SetValue(Canvas.LeftProperty, p.X - Touch2.Width / 2); Touch2.SetValue(Canvas.TopProperty, p.Y - Touch2.Height / 2); } } void Window1_StylusMove(object sender, StylusEventArgs e) { Point p = e.GetPosition(this); // determine which contact this belongs to if (Touch1ID == e.StylusDevice.Id) { // move the rectangle to the given location Touch1.SetValue(Canvas.LeftProperty, p.X - Touch1.Width / 2); Touch1.SetValue(Canvas.TopProperty, p.Y - Touch1.Height / 2); } else if (Touch2ID == e.StylusDevice.Id) { // move the rectangle to the given location Touch2.SetValue(Canvas.LeftProperty, p.X - Touch2.Width / 2); Touch2.SetValue(Canvas.TopProperty, p.Y - Touch2.Height / 2); } } void Window1_StylusUp(object sender, StylusEventArgs e) { // reinitialize touch id and hide the rectangle if (e.StylusDevice.Id == Touch1ID) { Touch1.SetValue(Canvas.LeftProperty, -Touch1.Width); Touch1ID = 0; } else if (e.StylusDevice.Id == Touch2ID) { Touch2.SetValue(Canvas.LeftProperty, -Touch2.Width); Touch2ID = 0; } } #endregion } } The full blog, Windows 7 Multi-touch Using WPF, is available at http://blog.andreweichacker.com/2009/02/windows-7-multi-touch-using-wpf/. 22

  • 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

22
Touch2ID = e.StylusDevice.Id;
// move the rectangle to the given location
Touch2.SetValue(Canvas.LeftProperty, p.X - Touch2.Width /
2);
Touch2.SetValue(Canvas.TopProperty, p.Y - Touch2.Height /
2);
}
}
void Window1_StylusMove(object sender, StylusEventArgs e)
{
Point p = e.GetPosition(this);
// determine which contact this belongs to
if (Touch1ID == e.StylusDevice.Id)
{
// move the rectangle to the given location
Touch1.SetValue(Canvas.LeftProperty, p.X - Touch1.Width /
2);
Touch1.SetValue(Canvas.TopProperty, p.Y - Touch1.Height /
2);
}
else if (Touch2ID == e.StylusDevice.Id)
{
// move the rectangle to the given location
Touch2.SetValue(Canvas.LeftProperty, p.X - Touch2.Width /
2);
Touch2.SetValue(Canvas.TopProperty, p.Y - Touch2.Height /
2);
}
}
void
Window1_StylusUp(object sender, StylusEventArgs e)
{
// reinitialize touch id and hide the rectangle
if (e.StylusDevice.Id == Touch1ID)
{
Touch1.SetValue(Canvas.LeftProperty, -Touch1.Width);
Touch1ID = 0;
}
else if (e.StylusDevice.Id == Touch2ID)
{
Touch2.SetValue(Canvas.LeftProperty, -Touch2.Width);
Touch2ID = 0;
}
}
#endregion
}
}
The full blog,
Windows 7 Multi-touch Using WPF
, is available at
.