当前位置: 首页>>代码示例>>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;未经允许,请勿转载。