Experience: develop multiple points using WPFProgramIt makes me feel very simple, and it all proves Microsoft's strength.
Step 1: Open vs2010 and create a wpfapplication1 Program
Step 2: Add a canvas and add the touchdown, touchmove, and touchup events to the canvas.
For example, <canvas background = "gray" name = "canvas1" Touchdown = "canvas1_touchdown"
Touchmove = "canvas1_touchmove" touchup = "canvas1_touchup"/>
Step 3: Define a digital dictionary storage object:
Private dictionary <int, ellipse> ellipses = new dictionary <int, ellipse> ();
Add the following to the three events:Code:
Private void canvas1_touchdown (Object sender, toucheventargs E)
{
Ellipse ellipse = new ellipse ();
Ellipse. width = 50;
Ellipse. Height = 50;
Ellipse. Stroke = brushes. yellowgreen;
Touchpoint = E. gettouchpoint (this. canvas1 );
Canvas. settop (ellipse, touchpoint. bounds. Top );
Canvas. setleft (ellipse, touchpoint. bounds. Left );
Ellipses [E. touchdevice. ID] = ellipse;
This. canvas1.children. Add (ellipse );
}
Private void canvas1_touchmove (Object sender, toucheventargs E)
{
Ellipse ellipse = ellipses [E. touchdevice. ID];
Touchpoint = E. gettouchpoint (this. canvas1 );
Canvas. settop (ellipse, touchpoint. bounds. Top );
Canvas. setleft (ellipse, touchpoint. bounds. Left );
}
Private void canvas1_touchup (Object sender, toucheventargs E)
{
Ellipse ellipse = ellipses [E. touchdevice. ID];
Ellipses. Remove (E. touchdevice. ID );
This. canvas1.children. Remove (ellipse );
}
Compile and run OK. You can download a multi-point simulator with multi-point touch screen hardware.
The effect is as follows: