本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例9: OnTouchDrag
protected override void OnTouchDrag(TouchEventArgs e)
{
base.OnTouchDrag(e);
Vector2 position = e.GetPosition(this);
CalculatePositionAndValue(position.X, position.Y);
}
示例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);
}
}
示例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);
}