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


C# Android.GetPointerId方法代碼示例

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


在下文中一共展示了Android.GetPointerId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: HandleTouchDown

        // ---------------------------------------------------------

        #region Private Methods

        private void HandleTouchDown(Android.Views.MotionEvent e)
        {
            // Set values from settings
            _currentPaint.Color = _formsView.PaintColor.ToAndroid();
            _currentPaint.StrokeWidth = _formsView.LineWidth * _deviceDensity;

            // Init storage for pointers and historical coords
            _pointerIds = new List<int>();
            _lastPointers = new List<PaintPointer>();

            // Loop all pointers
            for(int i = 0; i < e.PointerCount; i++)
            {
                // Get and store the pointer
                var pointerId = e.GetPointerId(i);

                _pointerIds.Add(pointerId);

                // Get the pointer coords
                var currentPoint = GetPointerCoords(e, pointerId);

                // Store the coord in the historical list
                _lastPointers.Add(new PaintPointer() { PointerId = pointerId, Coords = currentPoint });

                // Draw the line
                DrawLine(currentPoint, currentPoint);
            }
        }
開發者ID:Manne990,項目名稱:XamarinFormsPaintView,代碼行數:32,代碼來源:PaintViewRenderer.cs

示例2: OnTouch

            public bool OnTouch( Android.Views.View v, Android.Views.MotionEvent e )
            {
                Android.Views.MotionEventActions action = e.Action;

                if ( ( action & Android.Views.MotionEventActions.Mask ) != Android.Views.MotionEventActions.Move )
                {
                    TouchPointer tec = new TouchPointer ();

                    switch ( action & Android.Views.MotionEventActions.Mask )
                    {
                        case Android.Views.MotionEventActions.Down:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( 0 ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Pressed );
                            break;
                        case Android.Views.MotionEventActions.PointerDown:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( ( int ) ( action & Android.Views.MotionEventActions.PointerIdMask ) >> ( int ) Android.Views.MotionEventActions.PointerIdShift ) ),
                                                     new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Pressed );
                            break;
                        case Android.Views.MotionEventActions.Up:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( 0 ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Released );
                            break;
                        case Android.Views.MotionEventActions.PointerUp:
                            tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( ( int ) ( action & Android.Views.MotionEventActions.PointerIdMask ) >> ( int ) Android.Views.MotionEventActions.PointerIdShift ) ),
                                                    new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Released );
                            break;
                    }

                    bool isChanged = false;
                    for ( int i = 0; i < touchPointers.Count; i++ )
                    {
                        if ( touchPointers [ i ].Id == tec.Id )
                        {
                            touchPointers [ i ] = tec;
                            isChanged = true;
                            break;
                        }
                    }

                    if ( !isChanged )
                        touchPointers.Add ( tec );
                }
                else if ( ( action & Android.Views.MotionEventActions.Mask ) == Android.Views.MotionEventActions.Move )
                {
                    for ( int i = 0; i < e.PointerCount; i++ )
                    {
                        TouchPointer tec = new TouchPointer ( new IntPtr ( e.GetPointerId ( i ) ), new Vector2 ( e.GetX (), e.GetY () ), PointerMode.Moved );
                        touchPointers [ i ] = tec;
                    }
                }

                return true;
            }
開發者ID:Daramkun,項目名稱:ProjectLiqueur,代碼行數:51,代碼來源:TouchPanel.cs


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