本文整理匯總了C#中System.Windows.Input.TouchFrameEventArgs類的典型用法代碼示例。如果您正苦於以下問題:C# TouchFrameEventArgs類的具體用法?C# TouchFrameEventArgs怎麽用?C# TouchFrameEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TouchFrameEventArgs類屬於System.Windows.Input命名空間,在下文中一共展示了TouchFrameEventArgs類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Point
public partial class MainWindow : Window
{
// Variables for tracking the position of two points.
Point pt1, pt2 = new Point();
public MainWindow()
{
InitializeComponent();
Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
}
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
if (this.canvas1 != null)
{
foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1))
{
if (_touchPoint.Action == TouchAction.Down)
{
// Clear the canvas and capture the touch to it.
this.canvas1.Children.Clear();
_touchPoint.TouchDevice.Capture(this.canvas1);
}
else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null)
{
// This is the first (primary) touch point. Just record its position.
if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
{
pt1.X = _touchPoint.Position.X;
pt1.Y = _touchPoint.Position.Y;
}
// This is not the first touch point. Draw a line from the first point to this one.
else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
{
pt2.X = _touchPoint.Position.X;
pt2.Y = _touchPoint.Position.Y;
Line _line = new Line();
_line.Stroke = new RadialGradientBrush(Colors.White, Colors.Black);
_line.X1 = pt1.X;
_line.X2 = pt2.X;
_line.Y1 = pt1.Y;
_line.Y2 = pt2.Y;
_line.StrokeThickness = 2;
this.canvas1.Children.Add(_line);
}
}
else if (_touchPoint.Action == TouchAction.Up)
{
// If this touch is captured to the canvas, release it.
if (_touchPoint.TouchDevice.Captured == this.canvas1)
{
this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice);
}
}
}
}
}
}