本文整理汇总了C#中UIPanGestureRecognizer.LocationInView方法的典型用法代码示例。如果您正苦于以下问题:C# UIPanGestureRecognizer.LocationInView方法的具体用法?C# UIPanGestureRecognizer.LocationInView怎么用?C# UIPanGestureRecognizer.LocationInView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIPanGestureRecognizer
的用法示例。
在下文中一共展示了UIPanGestureRecognizer.LocationInView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pan
void Pan (UIPanGestureRecognizer pan)
{
var location = pan.LocationInView (View);
switch (pan.State) {
case UIGestureRecognizerState.Began:
// Capture the initial touch offset from the itemView's center.
var center = itemView.Center;
offset.X = location.X - center.X;
offset.Y = location.Y - center.Y;
// Disable the behavior while the item is manipulated by the pan recognizer.
stickyBehavior.Enabled = false;
break;
case UIGestureRecognizerState.Changed:
// Get reference bounds.
var referenceBounds = View.Bounds;
var referenceWidth = referenceBounds.Width;
var referenceHeight = referenceBounds.Height;
// Get item bounds.
var itemBounds = itemView.Bounds;
var itemHalfWidth = itemBounds.Width / 2f;
var itemHalfHeight = itemBounds.Height / 2f;
// Apply the initial offset.
location.X -= offset.X;
location.Y -= offset.Y;
// Bound the item position inside the reference view.
location.X = NMath.Max (itemHalfWidth, location.X);
location.X = NMath.Min (referenceWidth - itemHalfWidth, location.X);
location.Y = NMath.Max (itemHalfHeight, location.Y);
location.Y = NMath.Min (referenceHeight - itemHalfHeight, location.Y);
// Apply the resulting item center.
itemView.Center = location;
break;
case UIGestureRecognizerState.Ended:
case UIGestureRecognizerState.Cancelled:
// Get the current velocity of the item from the pan gesture recognizer.
var velocity = pan.VelocityInView (View);
// Re-enable the stickyCornersBehavior.
stickyBehavior.Enabled = true;
// Add the current velocity to the sticky corners behavior.
stickyBehavior.AddLinearVelocity (velocity);
break;
}
}
示例2: NodeTouchEvent
public NodeTouchEvent(NodeUIView parent, UIPanGestureRecognizer pan)
{
switch (pan.State) {
case UIGestureRecognizerState.Began:
type = TouchType.Down;
break;
case UIGestureRecognizerState.Changed:
type = TouchType.Move;
break;
case UIGestureRecognizerState.Ended:
type = TouchType.Up;
break;
case UIGestureRecognizerState.Possible:
case UIGestureRecognizerState.Cancelled:
case UIGestureRecognizerState.Failed:
break;
}
var p = pan.LocationInView (parent);
point = new Point (p.X, p.Y);
var velo = pan.VelocityInView (parent);
velocity = new Vec2 (velo.X / 1000, velo.Y / 1000);
}
示例3: HandlePan
/// <summary>
/// Handles the pan gesture.
/// </summary>
void HandlePan(UIPanGestureRecognizer panGest)
{
var view = this.contentContainerView;
if(!this.EnablePanGesture)
{
return;
}
if (panGest.State == UIGestureRecognizerState.Began)
{
this.panStartX = panGest.LocationInView(view).X;
}
else if (panGest.State == UIGestureRecognizerState.Changed && panStartX < PAN_GESTURE_REC_WIDTH)
{
float currentX = panGest.TranslationInView(view).X;
if (currentX < PAN_GESTURE_THRESHOLD)
{
if (currentX >= 0)
{
this.RevealMenu(currentX);
this.ShowDimView(true, currentX / WIDTH);
}
}
else
{
// If dragged past threshold, fully show the menu.
this.ShowMenu(true);
}
}
else if (panGest.State == UIGestureRecognizerState.Cancelled || panGest.State == UIGestureRecognizerState.Ended || panGest.State == UIGestureRecognizerState.Failed)
{
panStartX = 0f;
if (!this.IsMenuVisible)
{
// Hide if not panned past threshold.
this.ShowMenu(false);
}
}
}
示例4: PanGestureInActiveArea
private bool PanGestureInActiveArea(UIPanGestureRecognizer panGesture, MenuLocations menuLocation, nfloat gestureActiveArea) {
var position = panGesture.LocationInView(ContentViewController.View).X;
if (menuLocation == MenuLocations.Left)
return position > gestureActiveArea;
else
return position < ContentViewController.View.Bounds.Width - gestureActiveArea;
}
示例5: _handleHighlightGestureRecognizer
//#pragma mark - Input.
public void _handleHighlightGestureRecognizer( UIPanGestureRecognizer gestureRecognizer ){
CGPoint point = gestureRecognizer.LocationInView(this);
if (gestureRecognizer.State == UIGestureRecognizerState.Changed || gestureRecognizer.State == UIGestureRecognizerState.Ended) {
foreach (UIButton button in this.buttonDictionary.Values) {
bool points = button.Frame.Contains( point) && !button.Hidden;
if (gestureRecognizer.State == UIGestureRecognizerState.Changed) {
button.Highlighted = points;
} else {
button.Highlighted = false;
}
if (gestureRecognizer.State == UIGestureRecognizerState.Ended && points) {
button.SendActionForControlEvents(UIControlEvent.TouchUpInside);
}
}
}
}
示例6: pan
protected void pan(UIPanGestureRecognizer sender)
{
if (IsSigning) {
_touchLocation = sender.LocationInView (this);
PointF mid = BezierSignatureView.MidPoint (_touchLocation, _prevTouchLocation);
switch (sender.State) {
case UIGestureRecognizerState.Began:
{
_drawPath.MoveToPoint (_touchLocation);
break;
}
case UIGestureRecognizerState.Changed:
{
_drawPath.AddQuadCurveToPoint (_prevTouchLocation.X, _prevTouchLocation.Y, mid.X, mid.Y);
IsSigning = true;
break;
}
default:
{
break; }
}
_prevTouchLocation = _touchLocation;
SetNeedsDisplay ();
}
}
示例7: PanGestureRecognizer
public void PanGestureRecognizer(UIPanGestureRecognizer sender)
{
var enabledGestures = TouchPanel.EnabledGestures;
if ((enabledGestures & GestureType.FreeDrag) != 0)
{
TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.FreeDrag, new TimeSpan(_nowUpdate.Ticks), new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2 (sender.TranslationInView(sender.View)), new Vector2(0,0)));
}
}
示例8: ResizeRegionOfInterestWithGestureRecognizer
void ResizeRegionOfInterestWithGestureRecognizer (UIPanGestureRecognizer pan)
{
var touchLocation = pan.LocationInView (pan.View);
var oldRegionOfInterest = RegionOfInterest;
switch (pan.State) {
case UIGestureRecognizerState.Began:
// When the gesture begins, save the corner that is closes to
// the resize region of interest gesture recognizer's touch location.
currentControlCorner = CornerOfRect (oldRegionOfInterest, touchLocation);
break;
case UIGestureRecognizerState.Changed:
var newRegionOfInterest = oldRegionOfInterest;
switch (currentControlCorner) {
case ControlCorner.None:
// Update the new region of interest with the gesture recognizer's translation.
var translation = pan.TranslationInView (pan.View);
// Move the region of interest with the gesture recognizer's translation.
if (RegionOfInterest.Contains (touchLocation)) {
newRegionOfInterest.X += translation.X;
newRegionOfInterest.Y += translation.Y;
}
// If the touch location goes outside the preview layer,
// we will only translate the region of interest in the
// plane that is not out of bounds.
var normalizedRect = new CGRect (0, 0, 1, 1);
if (!normalizedRect.Contains (VideoPreviewLayer.PointForCaptureDevicePointOfInterest (touchLocation))) {
if (touchLocation.X < RegionOfInterest.GetMinX () || touchLocation.X > RegionOfInterest.GetMaxX ()) {
newRegionOfInterest.Y += translation.Y;
} else if (touchLocation.Y < RegionOfInterest.GetMinY () || touchLocation.Y > RegionOfInterest.GetMaxY ()) {
newRegionOfInterest.X += translation.X;
}
}
// Set the translation to be zero so that the new gesture
// recognizer's translation is in respect to the region of
// interest's new position.
pan.SetTranslation (CGPoint.Empty, pan.View);
break;
case ControlCorner.TopLeft:
newRegionOfInterest = new CGRect (touchLocation.X, touchLocation.Y,
oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
oldRegionOfInterest.Height + oldRegionOfInterest.Y - touchLocation.Y);
break;
case ControlCorner.TopRight:
newRegionOfInterest = new CGRect (newRegionOfInterest.X,
touchLocation.Y,
touchLocation.X - newRegionOfInterest.X,
oldRegionOfInterest.Height + newRegionOfInterest.Y - touchLocation.Y);
break;
case ControlCorner.BottomLeft:
newRegionOfInterest = new CGRect (touchLocation.X, oldRegionOfInterest.Y,
oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
touchLocation.Y - oldRegionOfInterest.Y);
break;
case ControlCorner.BottomRight:
newRegionOfInterest = new CGRect (oldRegionOfInterest.X, oldRegionOfInterest.Y,
touchLocation.X - oldRegionOfInterest.X,
touchLocation.Y - oldRegionOfInterest.Y);
break;
}
// Update the region of intresest with a valid CGRect.
SetRegionOfInterestWithProposedRegionOfInterest (newRegionOfInterest);
break;
case UIGestureRecognizerState.Ended:
RegionOfInterestDidChange?.Invoke (this, EventArgs.Empty);
// Reset the current corner reference to none now that the resize.
// gesture recognizer has ended.
currentControlCorner = ControlCorner.None;
break;
default:
return;
}
}
示例9: OnPanGesture
public void OnPanGesture (UIPanGestureRecognizer sender)
{
var location = sender.LocationInView (sender.View);
var position = GetOffsetPosition (new Vector2 (location.X, location.Y), true);
var delta = position - _previousPanPosition.GetValueOrDefault (position);
if (sender.State == UIGestureRecognizerState.Ended ||
sender.State == UIGestureRecognizerState.Cancelled ||
sender.State == UIGestureRecognizerState.Failed) {
TouchPanel.GestureList.Enqueue (new GestureSample (
GestureType.DragComplete, new TimeSpan (DateTime.Now.Ticks),
position, Vector2.Zero,
delta, Vector2.Zero));
_previousPanPosition = null;
} else {
TouchPanel.GestureList.Enqueue (new GestureSample (
GestureType.FreeDrag, new TimeSpan (DateTime.Now.Ticks),
position, Vector2.Zero,
delta, Vector2.Zero));
_previousPanPosition = position;
}
}
示例10: PanGestureRecognizer
public void PanGestureRecognizer(UIPanGestureRecognizer sender)
{
if (sender.State==UIGestureRecognizerState.Ended || sender.State==UIGestureRecognizerState.Cancelled || sender.State==UIGestureRecognizerState.Failed)
TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.DragComplete, new TimeSpan(_nowUpdate.Ticks), new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2 (sender.TranslationInView(sender.View)), new Vector2(0,0)));
else
TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.FreeDrag, new TimeSpan(_nowUpdate.Ticks), new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2 (sender.TranslationInView(sender.View)), new Vector2(0,0)));
}
示例11: HandleTouchPan
public void HandleTouchPan (UIPanGestureRecognizer gestureRecognizer)
{
if (gestureRecognizer.State == UIGestureRecognizerState.Ended) {
GestureDidEnd ();
return;
}
if (gestureRecognizer.State == UIGestureRecognizerState.Began) {
GestureDidBegin ();
return;
}
if (gestureRecognizer.NumberOfTouches == 2) {
TiltCamera (gestureRecognizer.TranslationInView (View));
} else {
CGPoint p = gestureRecognizer.LocationInView (View);
HandlePan (p);
}
}
示例12: OnPan
private void OnPan(UIPanGestureRecognizer recognizer)
{
if (recognizer.State == UIGestureRecognizerState.Began || recognizer.State == UIGestureRecognizerState.Changed)
{
_isInitialized = true;
var stepLength = _background.Frame.Width / ((MaxValue - MinValue) / Step);
var touchPoint = recognizer.LocationInView(this);
UIView indicator = null;
UIView touchArea = null;
//Is this a slide to left or right?
if (recognizer == _leftIndicatorGesture)
{
indicator = _leftIndicator;
touchArea = _leftTouchArea;
}
else if (recognizer == _rightIndicatorGesture)
{
indicator = _rightIndicator;
touchArea = _rightTouchArena;
}
if (recognizer.State == UIGestureRecognizerState.Began)
{
_startX = (float)indicator.Center.X;
}
var cumulativeManipulation = touchPoint.X - _startX;
var deltaManipulation = touchPoint.X - indicator.Center.X;
if (deltaManipulation > 0 && cumulativeManipulation / stepLength > _lastStep ||
deltaManipulation < 0 && cumulativeManipulation / stepLength < _lastStep)
{
if (deltaManipulation > 0)
{
_lastStep++;
}
else
{
_lastStep--;
}
var numberOfSteps = Math.Ceiling(deltaManipulation / stepLength);
var newPosition = new CGPoint(indicator.Center.X + stepLength * numberOfSteps, indicator.Center.Y);
var pixelStep = (MaxValue - MinValue) / Frame.Width;
if (touchPoint.X >= 0 && touchPoint.X <= _background.Frame.Width-10)
{
if (recognizer == _leftIndicatorGesture)
{
var newLeftValue = Round(MinValue + (pixelStep * newPosition.X));
if (newLeftValue >= RightValue)
{
return;
}
}
else if (recognizer == _rightIndicatorGesture)
{
var newRightValue = Round(MinValue + (pixelStep * newPosition.X));
if (newRightValue <= LeftValue)
{
return;
}
}
if (recognizer == _leftIndicatorGesture)
{
indicator.Center = newPosition;
touchArea.Center = newPosition;
var width = _rightIndicator.Center.X - _leftIndicator.Center.X;
_range.Frame = new CoreGraphics.CGRect(newPosition.X, _range.Frame.Y, width, _range.Frame.Height);
}
else if (recognizer == _rightIndicatorGesture)
{
indicator.Center = newPosition;
touchArea.Center = newPosition;
var width = _rightIndicator.Center.X - _leftIndicator.Center.X;
_range.Frame = new CoreGraphics.CGRect(_range.Frame.X, _range.Frame.Y, width, _range.Frame.Height);
}
LeftValue = Round(MinValue + (pixelStep * _leftIndicator.Center.X));
RightValue = Round(MinValue + (pixelStep * _rightIndicator.Center.X));
if (ValueChanging != null)
{
ValueChanging(this, new EventArgs());
}
}
}
}
else if (recognizer.State == UIGestureRecognizerState.Ended)
{
//.........这里部分代码省略.........
示例13: HandlePan
private void HandlePan(UIPanGestureRecognizer rec)
{
if (rec.State == UIGestureRecognizerState.Began)
{
HandleTouchesBeganAtLocation(rec.LocationInView(View));
}
else if (rec.State == UIGestureRecognizerState.Changed)
{
HandleTouchesMovedToLocation(rec.LocationInView(View));
}
else if (rec.State == UIGestureRecognizerState.Ended ||
rec.State == UIGestureRecognizerState.Cancelled ||
rec.State == UIGestureRecognizerState.Failed)
{
float velocity = rec.VelocityInView(View).X;
if (Math.Abs(velocity) > kLWMinimumVelocityToTriggerSlide)
{
if (velocity > 0f)
{
SlideOutSlideNavigationView();
}
else
{
SlideInSlideNavigationView();
}
}
else
{
HandleTouchesEndedAtLocation(rec.LocationInView(View));
}
}
}
示例14: dismissingPanGestureRecognizerPanned
private void dismissingPanGestureRecognizerPanned(UIPanGestureRecognizer panner)
{
if (Flags.ScrollViewIsAnimatingAZoom || Flags.IsAnimatingAPresentationOrDismissal)
return;
PointF translation = panner.TranslationInView (panner.View);
PointF locationInView = panner.LocationInView (panner.View);
PointF velocity = panner.VelocityInView (panner.View);
float vectorDistance = (float)Math.Sqrt (Math.Pow (velocity.X, 2) + Math.Pow (velocity.Y, 2));
if (panner.State == UIGestureRecognizerState.Began) {
Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
if (Flags.IsDraggingImage)
StartImageDragging (locationInView, new UIOffset ());
} else if (panner.State == UIGestureRecognizerState.Changed) {
if (Flags.IsDraggingImage) {
PointF newAnchor = ImageDragStartingPoint;
newAnchor.X += translation.X + ImageDragOffsetFromActualTranslation.Horizontal;
newAnchor.Y += translation.Y + ImageDragOffsetFromActualTranslation.Vertical;
AttachmentBehavior.AnchorPoint = newAnchor;
} else {
Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
if (Flags.IsDraggingImage) {
UIOffset translationOffset = new UIOffset (-1 * translation.X, -1 * translation.Y);
StartImageDragging (locationInView, translationOffset);
}
}
} else {
if (vectorDistance > JTSImageViewController.JTSImageViewController_MinimumFlickDismissalVelocity) {
if (Flags.IsDraggingImage) {
DismissImageWithFlick (velocity);
} else {
Dismiss (true);
}
} else {
CancelCurrentImageDrag (true);
}
}
}
示例15: SortingPanGestureUpdated
public void SortingPanGestureUpdated(UIPanGestureRecognizer panGesture)
{
switch (panGesture.State)
{
case UIGestureRecognizerState.Ended:
case UIGestureRecognizerState.Cancelled:
case UIGestureRecognizerState.Failed:
{
autoScrollActive = false;
break;
}
case UIGestureRecognizerState.Began:
{
autoScrollActive = true;
SortingAutoScrollMovementCheck();
break;
}
case UIGestureRecognizerState.Changed:
{
PointF translation = panGesture.TranslationInView(this);
PointF offset = translation;
PointF locationInScroll = panGesture.LocationInView(this);
sortMovingItem.Transform = CGAffineTransform.MakeTranslation(offset.X, offset.Y);
SortingMoveDidContinueToPoint(locationInScroll);
break;
}
default:
break;
}
}