当前位置: 首页>>代码示例>>C#>>正文


C# TouchEventArgs.GetPosition方法代码示例

本文整理汇总了C#中TouchEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# TouchEventArgs.GetPosition方法的具体用法?C# TouchEventArgs.GetPosition怎么用?C# TouchEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TouchEventArgs的用法示例。


在下文中一共展示了TouchEventArgs.GetPosition方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnTouchDown

        protected override void OnTouchDown(TouchEventArgs e)
        {
            if (e.Button == 0) {
                Vector2 position = e.GetPosition(this);

                _dragging = IsMovable && (Height - position.Y) <= PadTop && position.Y < Height && position.X > 0 && position.X < Width;
                _dragOffset = position;
            }

            if (_dragging || IsModal)
                e.Handled = true;

            base.OnTouchDown(e);
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:14,代码来源:Window.cs

示例2: OnTouchDrag

 protected override void OnTouchDrag(TouchEventArgs e)
 {
     base.OnTouchDrag(e);
     Vector2 position = e.GetPosition(this);
     if (_dragging)
         Translate(position.X - _dragOffset.X, position.Y - _dragOffset.Y);
 }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:7,代码来源:Window.cs

示例3: OnPreviewTouchDown

        protected override void OnPreviewTouchDown(TouchEventArgs e)
        {
            try {
                if (_draggingPointer != -1)
                    return;
                if (e.Pointer == 0 && e.Button != 0)
                    return;
                Stage.SetScrollFocus(this);

                if (!_flickScroll)
                    ResetFade();

                if (_fadeAlpha == 0)
                    return;

                Vector2 position = e.GetPosition(this);

                if (IsScrollX && _hScrollBounds.Contains(position.X, position.Y)) {
                    e.Stopped = true;
                    ResetFade();
                    if (_hKnobBounds.Contains(position.X, position.Y)) {
                        _lastPoint = position;
                        _handlePosition = _hKnobBounds.X;
                        _touchScrollH = true;
                        _draggingPointer = e.Pointer;

                        e.Handled = true;
                        return;
                    }

                    SetScrollX(ScrollX + Math.Max(_areaWidth * .9f, MaxX * .1f) * (position.X < _hKnobBounds.X ? -1 : 1));
                    e.Handled = true;
                    return;
                }

                if (IsScrollY && _vScrollBounds.Contains(position.X, position.Y)) {
                    e.Stopped = true;
                    ResetFade();
                    if (_vKnobBounds.Contains(position.X, position.Y)) {
                        _lastPoint = position;
                        _handlePosition = _vKnobBounds.Y;
                        _touchScrollV = true;
                        _draggingPointer = e.Pointer;

                        e.Handled = true;
                        return;
                    }

                    SetScrollY(ScrollY + Math.Max(_areaHeight * .9f, MaxY * .1f) * (position.Y < _vKnobBounds.Y ? 1 : -1));
                    e.Handled = true;
                    return;
                }
            }
            finally {
                base.OnPreviewTouchDown(e);
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:57,代码来源:ScrollPane.cs

示例4: OnPreviewTouchDrag

        protected override void OnPreviewTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
                return;

            Vector2 position = e.GetPosition(this);

            if (_touchScrollH) {
                float delta = position.X - _lastPoint.X;
                float scrollH = _handlePosition + delta;
                _handlePosition = scrollH;

                scrollH = Math.Max(_hScrollBounds.X, scrollH);
                scrollH = Math.Min(_hScrollBounds.X + _hScrollBounds.Width - _hKnobBounds.Width, scrollH);

                float total = _hScrollBounds.Width - _hKnobBounds.Width;
                if (total != 0)
                    ScrollPercentX = (scrollH - _hScrollBounds.X) / total;

                _lastPoint = position;
            }
            else if (_touchScrollV) {
                float delta = position.Y - _lastPoint.Y;
                float scrollV = _handlePosition + delta;
                _handlePosition = scrollV;

                scrollV = Math.Max(_vScrollBounds.Y, scrollV);
                scrollV = Math.Min(_vScrollBounds.Y + _vScrollBounds.Height - _vKnobBounds.Height, scrollV);

                float total = _vScrollBounds.Height - _vKnobBounds.Height;
                if (total != 0)
                    ScrollPercentY = 1 - (scrollV - _vScrollBounds.Y) / total;

                _lastPoint = position;
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:38,代码来源:ScrollPane.cs

示例5: OnTouchDrag

        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
                return;

            Vector2 position = e.GetPosition(this);

            ISceneDrawable handle = _style.Handle;
            if (!IsVertical) {
                float delta = position.X - _lastPoint.X;
                float availWidth = Width - handle.MinWidth;
                float dragX = _handlePosition.X + delta;
                _handlePosition.X = dragX;

                dragX = MathHelper.Clamp(dragX, 0, availWidth);
                _splitAmount = dragX / availWidth;
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint = position;
            }
            else {
                float delta = position.Y - _lastPoint.Y;
                float availHeight = Height - handle.MinHeight;
                float dragY = _handlePosition.Y + delta;
                _handlePosition.Y = dragY;

                dragY = MathHelper.Clamp(dragY, 0, availHeight);
                _splitAmount = 1 - (dragY / availHeight);
                _splitAmount = MathHelper.Clamp(_splitAmount, _minAmount, _maxAmount);
                _lastPoint = position;
            }

            Invalidate();
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:35,代码来源:SplitPane.cs

示例6: OnTouchDown

        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                Vector2 position = e.GetPosition(this);

                if (e.Pointer == 0 && e.Button != 0)
                    return;
                if (!IsSelectable)
                    return;

                DoTouchDown(position.Y);

                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:18,代码来源:List.cs

示例7: OnTouchDown

        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (_draggingPointer != -1)
                    return;
                if (e.Pointer == 0 && e.Button != 0)
                    return;

                Vector2 position = e.GetPosition(this);

                if (_handleBounds.Contains(position.X, position.Y)) {
                    _draggingPointer = e.Pointer;
                    _lastPoint = position;
                    _handlePosition = new Vector2(_handleBounds.X, _handleBounds.Y);

                    if (Stage != null)
                        CaptureTouch(e.Pointer);

                    e.Handled = true;
                }
            }
            finally {
                base.OnTouchDown(e);
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:25,代码来源:SplitPane.cs

示例8: OnTouchUp

        protected override void OnTouchUp(TouchEventArgs e)
        {
            base.OnTouchUp(e);

            if (e.Pointer != _draggingPointer)
                return;

            _draggingPointer = -1;
            ReleaseTouchCapture(e.Pointer);

            Vector2 position = e.GetPosition(this);

            if (!CalculatePositionAndValue(position.X, position.Y)) {
                // TODO: Raise event for end of dragging control.

                //ChangeEvent changeEvent = Pools<ChangeEvent>.Obtain();
                //Fire(changeEvent);
                //Pools<ChangeEvent>.Release(changeEvent);
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:20,代码来源:Slider.cs

示例9: OnTouchDrag

        protected override void OnTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            Vector2 position = e.GetPosition(this);
            CalculatePositionAndValue(position.X, position.Y);
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:7,代码来源:Slider.cs

示例10: OnTouchDown

        protected override void OnTouchDown(TouchEventArgs e)
        {
            try {
                if (IsDisabled)
                    return;
                if (_draggingPointer != -1)
                    return;

                Vector2 position = e.GetPosition(this);

                _draggingPointer = e.Pointer;
                CalculatePositionAndValue(position.X, position.Y);

                CaptureTouch(e.Pointer);
                e.Handled = true;
            }
            finally {
                base.OnTouchDown(e);
            }
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:20,代码来源:Slider.cs

示例11: OnTouchUp

            protected override void OnTouchUp(TouchEventArgs e)
            {
                Vector2 position = e.GetPosition(this);

                if (Hit(position.X, position.Y, true) == _list) {
                    _selectBox.SelectionIndex = _list.SelectedIndex;
                    _selectBox.HideList();
                }

                base.OnTouchUp(e);
            }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:11,代码来源:SelectBox.cs


注:本文中的TouchEventArgs.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。