本文整理匯總了C#中Windows.UI.Input.GestureRecognizer.ProcessUpEvent方法的典型用法代碼示例。如果您正苦於以下問題:C# GestureRecognizer.ProcessUpEvent方法的具體用法?C# GestureRecognizer.ProcessUpEvent怎麽用?C# GestureRecognizer.ProcessUpEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.UI.Input.GestureRecognizer
的用法示例。
在下文中一共展示了GestureRecognizer.ProcessUpEvent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddGestureRecognizer
private void AddGestureRecognizer()
{
var gesture = new GestureRecognizer() {
AutoProcessInertia = true,
GestureSettings = GestureSettings.Drag | GestureSettings.CrossSlide,
CrossSlideHorizontally = true,
CrossSlideThresholds = new CrossSlideThresholds { SpeedBumpEnd = 30 }
};
Point lastDragLocation;
var lastDragTime = DateTime.Now;
gesture.Dragging += (sender, args) => {
switch (args.DraggingState) {
case DraggingState.Started:
lastDragLocation = args.Position;
lastDragTime = DateTime.Now;
break;
case DraggingState.Continuing: {
if (swipeDisplayed) {
SwipeHelp.FadeOut();
swipeDisplayed = false;
}
var delta = args.Position.X - lastDragLocation.X;
var time = DateTime.Now.Subtract(lastDragTime).TotalSeconds;
if (Math.Abs(delta) > 30 && time > 0) {
var velocity = delta / time;
lastDragLocation = args.Position;
lastDragTime = DateTime.Now;
Model.Zoomed(velocity);
}
break;
}
}
};
gesture.CrossSliding += (sender, args) => {
switch (args.CrossSlidingState) {
case CrossSlidingState.Started:
lastDragLocation = args.Position;
lastDragTime = DateTime.Now;
break;
case CrossSlidingState.Dragging: {
if (swipeDisplayed) {
SwipeHelp.FadeOut();
swipeDisplayed = false;
}
var delta = args.Position.X - lastDragLocation.X;
var time = DateTime.Now.Subtract(lastDragTime).TotalSeconds;
if (Math.Abs(delta) > 30 && time > 0) {
var velocity = delta / time;
lastDragLocation = args.Position;
lastDragTime = DateTime.Now;
Model.Zoomed(velocity);
}
break;
}
}
};
GraphView.PointerPressed += (sender, args) => {
GraphView.CapturePointer(args.Pointer);
gesture.ProcessDownEvent(args.GetCurrentPoint(GraphView));
};
GraphView.PointerMoved += (sender, args) => {
gesture.ProcessMoveEvents(args.GetIntermediatePoints(GraphView));
};
GraphView.PointerReleased += (sender, args) => {
gesture.ProcessUpEvent(args.GetCurrentPoint(GraphView));
GraphView.ReleasePointerCapture(args.Pointer);
};
}
示例2: Register
//.........這裏部分代碼省略.........
}
}
#endregion 鼠標後退和前進
#region 滑動後退和前進
if (config.IsNavigateBackBySlideToRight || config.IsNavigateForwardBySlideToLeft)
{
var isNavigateBackBySlideToRight = config.IsNavigateBackBySlideToRight;
var isNavigateForwardBySlideToLeft = config.IsNavigateForwardBySlideToLeft;
var recognizer = new GestureRecognizer()
{
GestureSettings = GestureSettings.CrossSlide,
CrossSlideHorizontally = true
};
PointerPoint startPoint = null;
PointerPoint endPoint = null;
if (_pointerPressedHandlers.ContainsKey(frame) == false)
{
TypedEventHandler<CoreWindow, PointerEventArgs> pointerPressedHandler = (sender, e) =>
{
e.Handled = true;
switch (e.CurrentPoint.PointerDevice.PointerDeviceType)
{
case Windows.Devices.Input.PointerDeviceType.Touch:
case Windows.Devices.Input.PointerDeviceType.Pen:
var point = e.CurrentPoint;
startPoint = point;
recognizer.ProcessDownEvent(point);
break;
}
};
_pointerPressedHandlers.Add(frame, pointerPressedHandler);
window.PointerPressed += pointerPressedHandler;
}
if (_pointerMovedHandlers.ContainsKey(frame) == false)
{
TypedEventHandler<CoreWindow, PointerEventArgs> pointerMovedHandler = (sender, e) =>
{
e.Handled = true;
switch (e.CurrentPoint.PointerDevice.PointerDeviceType)
{
case Windows.Devices.Input.PointerDeviceType.Touch:
case Windows.Devices.Input.PointerDeviceType.Pen:
recognizer.ProcessMoveEvents(e.GetIntermediatePoints());
break;
}
};
_pointerMovedHandlers.Add(frame, pointerMovedHandler);
window.PointerMoved += pointerMovedHandler;
}
if (_pointerReleasedHandlers.ContainsKey(frame) == false)
{
TypedEventHandler<CoreWindow, PointerEventArgs> pointerReleasedHandler = (sender, e) =>
{
e.Handled = true;
switch (e.CurrentPoint.PointerDevice.PointerDeviceType)
{
case Windows.Devices.Input.PointerDeviceType.Touch:
case Windows.Devices.Input.PointerDeviceType.Pen:
var point = e.CurrentPoint;
endPoint = point;
recognizer.ProcessUpEvent(point);
break;
}
};
_pointerReleasedHandlers.Add(frame, pointerReleasedHandler);
window.PointerReleased += pointerReleasedHandler;
}
recognizer.CrossSliding += async (sender, e) =>
{
if (e.CrossSlidingState == CrossSlidingState.Completed)
{
if (startPoint != null && endPoint != null)
{
var startX = startPoint.Position.X;
var endX = endPoint.Position.X;
if (startX < endX && isNavigateBackBySlideToRight)
{
if (asyncBackAction != null)
{
await asyncBackAction();
}
}
if (startX > endX && isNavigateForwardBySlideToLeft)
{
if (asyncForwardAction != null)
{
await asyncForwardAction();
}
}
}
}
};
}
#endregion 滑動後退和前進
}