當前位置: 首頁>>代碼示例>>C#>>正文


C# GestureRecognizer.ProcessMoveEvents方法代碼示例

本文整理匯總了C#中Windows.UI.Input.GestureRecognizer.ProcessMoveEvents方法的典型用法代碼示例。如果您正苦於以下問題:C# GestureRecognizer.ProcessMoveEvents方法的具體用法?C# GestureRecognizer.ProcessMoveEvents怎麽用?C# GestureRecognizer.ProcessMoveEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.UI.Input.GestureRecognizer的用法示例。


在下文中一共展示了GestureRecognizer.ProcessMoveEvents方法的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);
            };
        }
開發者ID:Inferis,項目名稱:drash-win8,代碼行數:78,代碼來源:DrashPage.xaml.cs

示例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 滑動後退和前進
        }
開發者ID:h82258652,項目名稱:SoftwareKobo.UniversalToolkit,代碼行數:101,代碼來源:NavigationHelper.cs


注:本文中的Windows.UI.Input.GestureRecognizer.ProcessMoveEvents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。