public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { if (!minThumbOn && !maxThumbOn) return true; var touchPoint = uitouch.LocationInView (this); if (minThumbOn) { minThumb.Center = new PointF(Math.Max ( XForValue(MinValue), Math.Min(touchPoint.X - distanceFromCenter, XForValue(SelectedMaxValue - MinRange))), minThumb.Center.Y - Frame.Top); SelectedMinValue = ValueForX (minThumb.Center.X); } if (maxThumbOn) { maxThumb.Center = new PointF(Math.Min ( XForValue(MaxValue), Math.Max( touchPoint.X - distanceFromCenter, XForValue(SelectedMinValue + MinRange) ) ), maxThumb.Center.Y - Frame.Top); SelectedMaxValue = ValueForX (maxThumb.Center.X); } UpdateTrackHighlight(); this.SetNeedsLayout(); if (ThumbChanged != null) ThumbChanged(this); return true; }
protected void AddSpot (UITouch touch) { // create a random color spot at the point of touch, then add it to the others Spot spot = Spot.CreateNewRandomColor (touch.LocationInView (this)); touchSpots.Add (spot); // tell the OS to redraw SetNeedsDisplay (); }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { var touchPoint = uitouch.LocationInView (this); if (minThumb.Frame.Contains (touchPoint)) { minThumbOn = true; distanceFromCenter = touchPoint.X - minThumb.Center.X; } else if (maxThumb.Frame.Contains (touchPoint)) { maxThumbOn = true; distanceFromCenter = touchPoint.X - maxThumb.Center.X; } return true; }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { var TouchPoint = uitouch.LocationInView (this); if (_leftKnobLayer.Frame.Contains (TouchPoint)) { _leftTouchPoint = TouchPoint; _leftKnobLayer.Highlighted = true; _leftKnobLayer.SetNeedsDisplay (); } else if (_rightKnobLayer.Frame.Contains (TouchPoint)) { _rightTouchPoint = TouchPoint; _rightKnobLayer.Highlighted = true; _rightKnobLayer.SetNeedsDisplay (); } return _leftKnobLayer.Highlighted || _rightKnobLayer.Highlighted; }
public override void TouchesMoved(NSSet touches, UIEvent evt) { isCleared = false; UITouch touch = touches.AnyObject as UITouch; CGPoint point = touch.LocationInView(this); center++; points[center] = point; if (center == 4) { points[3] = new CGPoint((points[2].X + points[4].X) / 2f, (points[2].Y + points[4].Y) / 2f); path.MoveTo(points[0]); path.AddCurveToPoint(points[3], points[1], points[2]); SetNeedsDisplay(); points[0] = points[3]; points[1] = points[4]; center = 1; } }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { var TouchPoint = uitouch.LocationInView(this); if (_leftKnobLayer.Frame.Contains(TouchPoint)) { _leftTouchPoint = TouchPoint; _leftKnobLayer.Highlighted = true; _leftKnobLayer.SetNeedsDisplay(); } else if (_rightKnobLayer.Frame.Contains(TouchPoint)) { _rightTouchPoint = TouchPoint; _rightKnobLayer.Highlighted = true; _rightKnobLayer.SetNeedsDisplay(); } return(_leftKnobLayer.Highlighted || _rightKnobLayer.Highlighted); }
public override void TouchesEnded(NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); UITouch touch = touches.AnyObject as UITouch; var cgPoint = touch.LocationInView(this); var point = new SKPoint((float)this.ContentScaleFactor * (float)cgPoint.X, (float)this.ContentScaleFactor * (float)cgPoint.Y); var rect = new SKRect(point.X - 25f, point.Y - 25f, point.X + 50f, point.Y + 50f); // if touch ended within current viewbox! if (takeButton.TouchUpInside(rect)) { TakeButtonTouched?.Invoke(this, new EventArgs()); Counter++; } if (flashButton.TouchUpInside(rect)) { FlashButtonTouched?.Invoke(this, new EventArgs()); } if (cameraButton.TouchUpInside(rect)) { CameraButtonTouched?.Invoke(this, new EventArgs()); } if (closeButton.TouchUpInside(rect)) { CloseButtonTouched?.Invoke(this, new EventArgs()); } if (sendButton.TouchUpInside(rect)) { SendButtonTouched?.Invoke(this, new EventArgs()); } if (counterButton.TouchUpInside(rect)) { CounterButtonTouched?.Invoke(this, new EventArgs()); } buttons.ForEach((btn) => btn.Touched = false); }
private void FireEvent( TouchRecognizer recognizer, long id, TouchActionType actionType, UITouch touch, bool isInContact) { // Convert touch location to Xamarin.Forms Point value CGPoint cgPoint = touch.LocationInView(recognizer.View); Point xfPoint = new Point(cgPoint.X, cgPoint.Y); // Get the method to call for firing events Action <Element, TouchActionEventArgs> onTouchAction = recognizer.touchEffect.OnTouchAction; // Call that method onTouchAction( recognizer.element, new TouchActionEventArgs(id, actionType, xfPoint, isInContact)); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); UITouch touch = (UITouch)touches.AnyObject; CGPoint touchPoint = touch.LocationInView(chart.PlotView); TKChartSelectionInfo hitTestInfo = chart.HitTestForPoint(touchPoint); if (hitTestInfo != null) { selectedPoint = chart.VisualPointForSeries(hitTestInfo.Series, hitTestInfo.DataPointIndex); originalLocation = touchPoint; if (selectedPoint != null) { selectedPoint.Animator = null; originalPosition = selectedPoint.Center; } } }
public void TouchBegan(UITouch touch, UIView view) { var touchImgView = touchImageViewQueue.PopTouchImageView(); touchImgView.Center = touch.LocationInView(view); view.AddSubview(touchImgView); touchImgView.Alpha = 0.0f; touchImgView.Transform = CGAffineTransform.MakeScale(1.13f, 1.13f); SetTouchImageView(touchImgView, touch); UIView.Animate(duration: 0.1, animation: () => { touchImgView.Alpha = 1.0f; touchImgView.Transform = CGAffineTransform.MakeScale(1, 1); }); touchesStartDateMapTable[touch] = DateTime.Now; }
public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { var TouchPoint = uitouch.LocationInView (this); if (_leftKnobLayer.Highlighted) { _leftTouchPoint = TouchPoint; } else if (_rightKnobLayer.Highlighted) { _rightTouchPoint = TouchPoint; } CATransaction.Begin (); CATransaction.DisableActions = true; SetLayerFrames (); CATransaction.Commit (); return _leftKnobLayer.Highlighted || _rightKnobLayer.Highlighted; }
void CheckForBoundaryHop(UITouch touch) { long id = touch.Handle.ToInt64(); // TODO: Might require converting to a List for multiple hits TouchRecognizer recognizerHit = null; foreach (UIView view in viewDictionary.Keys) { CGPoint location = touch.LocationInView(view); if (new CGRect(new CGPoint(), view.Frame.Size).Contains(location)) { recognizerHit = viewDictionary[view]; } } if (idToTouchDictionary.ContainsKey(id)) { if (recognizerHit != idToTouchDictionary[id]) { if (idToTouchDictionary[id] != null) { FireEvent(idToTouchDictionary[id], id, TouchActionType.Exited, touch, true); } if (recognizerHit != null) { FireEvent(recognizerHit, id, TouchActionType.Entered, touch, true); } idToTouchDictionary[id] = recognizerHit; } } else { if (recognizerHit != null) { FireEvent(recognizerHit, id, TouchActionType.Entered, touch, true); } idToTouchDictionary[id] = recognizerHit; } }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; currentPoint = touch.LocationInView(touch.View); if (newPoint || isEndPoint) { if (isSnapToGrid) { bool stillInRange = CheckDragProximity(); if (!stillInRange) { UpdatePoint(); } } else { UpdatePoint(); }; } else { if (touchMonitoring) { bool stillInRange = CheckDragProximity(); if (stillInRange) { if (stopwatch.ElapsedMilliseconds > longPressTime) { touchMonitoring = false; RemovePoint(); } } else { UpdatePoint(); } } } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); UITouch touch = touches.AnyObject as UITouch; if (touch != null) { PointF pt = touch.LocationInView(this); if (_path.ContainsPoint(pt, true)) { Title = "You touched the square"; } else { Title = "You didn't touch the square"; } } }
public override void EndTracking(UITouch uitouch, UIEvent uievent) { base.EndTracking(uitouch, uievent); var touchLocationInView = uitouch?.LocationInView(this); if (touchLocationInView == null) { return; } //let offset = type(of: self).validBoundsOffset //let validBounds = CGRect(x: bounds.origin.x - offset, y: bounds.origin.y - offset, width: bounds.width + (2 * offset), height: bounds.height + (2 * offset)) var validBounds = Bounds; if (validBounds.Contains(touchLocationInView.Value)) { Checked = !Checked; SendActionForControlEvents(UIControlEvent.ValueChanged); } }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; /* MyImageインスタンスの現在の座標 */ var newPoint = touch.LocationInView(this); /* MyImageインスタンスの前回の座標 */ var previousPoint = touch.PreviousLocationInView(this); /* 差分を計算 */ nfloat dx = newPoint.X - previousPoint.X; nfloat dy = newPoint.Y - previousPoint.Y; /* コールバック */ var el = this.Element as MyImage; el.Drug(el, new DrugEventArgs(el, dx, dy)); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { UITouch aTouch = (UITouch)touches.AnyObject; PointF location = aTouch.LocationInView(this); var coordinate = _mapView.ConvertPoint(location, this); if (this.HasPoint) { _mapView.RemoveAnnotation(point); point = new PointAnnotation(coordinate, "Meeting Place", "Here"); _mapView.AddAnnotation(point); } else { point = new PointAnnotation(coordinate, "Meeting Place", "Here"); _mapView.AddAnnotation(point); this.HasPoint = true; } }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); if (Mode == CropMode.Editing) { // adjust by the amount moved UITouch touch = touches.AnyObject as UITouch; if (touch != null) { CGPoint touchPoint = touch.LocationInView(View); CGPoint delta = new CGPoint(touchPoint.X - LastTapPos.X, touchPoint.Y - LastTapPos.Y); MoveCropView(delta); LastTapPos = touchPoint; } } }
private void handleUITouch(UITouch touch) { var location = touch.LocationInView(null); PendingInputs.Enqueue(new MousePositionAbsoluteInput { Position = new Vector2((float)location.X * view.Scale, (float)location.Y * view.Scale) }); switch (touch.Phase) { case UITouchPhase.Moved: case UITouchPhase.Began: PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Left, true)); break; case UITouchPhase.Cancelled: case UITouchPhase.Ended: PendingInputs.Enqueue(new MouseButtonInput(MouseButton.Left, false)); break; } }
public override bool BeginTracking(UITouch touch, UIEvent uievent) { _previousTouchPoint = (CGPoint)touch.LocationInView((UIView)this); // hit test the knob layers if (_lowerKnobLayer.PaintFrame.Contains(_previousTouchPoint)) { _lowerKnobLayer.Highlighted = true; _lowerKnobLayer.SetNeedsDisplay(); } else if (_upperKnobLayer.PaintFrame.Contains(_previousTouchPoint)) { _upperKnobLayer.Highlighted = true; _upperKnobLayer.SetNeedsDisplay(); } RawHighValue = HighValue; RawLowValue = LowValue; return(_upperKnobLayer.Highlighted || _lowerKnobLayer.Highlighted); }
public override bool ContinueTracking(UITouch touch, UIEvent uievent) { CGPoint point = touch.LocationInView(this); percent = (point.X - knobWidth / 2.0f) / (Bounds.Width - knobWidth); if (percent < 0.0f) { percent = 0.0f; } if (percent > 1.0f) { percent = 1.0f; } if ((oldPercent < 0.25f && percent > 0.5f) || (oldPercent > 0.75f && percent < 0.5f)) { mustFlip = false; } SetNeedsDisplay(); SendActionForControlEvents(UIControlEvent.TouchDragInside); return(true); }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); UITouch touch = touches.AnyObject as UITouch; PointF point = touch.LocationInView(this); float dx = point.X - Centre.X; float dy = point.Y - Centre.Y; float r2 = dx * dx + dy * dy; iOutsideOuter = (r2 > iOuterRadius * iOuterRadius); iOutsideInner = (r2 > iInnerRadius * iInnerRadius); if (iTouchedOuter /*&& iOutsideInner*/) { UpdateAngle(point); } SetNeedsDisplay(); }
public override void TouchesEnded(NSSet touches, UIEvent evt) { UITouch touch = touches.AnyObject as UITouch; //Obtain the location of the touch and add it to the current path and current_points array. CGPoint touchLocation = touch.LocationInView(this); currentPath.AddLineTo(touchLocation); currentPoints.Add(touchLocation); //Obtain the smoothed path and the points array for that path. currentPath = smoothedPathWithGranularity(40, out currentPoints); //Add the smoothed path and points array to their Lists. paths.Add(currentPath); points.Add(currentPoints.ToArray()); //Obtain the image for the imported signature and display it in the image view. imageView.Image = GetImage(false); updateBounds(touchLocation); SetNeedsDisplay(); }
public override void TouchesBegan(MonoTouch.Foundation.NSSet touches, UIEvent evt) { // Disable gestures on preview mode if (mParent.ShouldDisplayFilledCells) { return; } // Touch began: find the cell under the finger and register it as a path start if (touches.Count == 1) { UITouch touch = (UITouch)touches.AnyObject; PointF fingerLocation = touch.LocationInView(this); Cell cell = getCellFromViewCoordinates(fingerLocation); mParent.StartPathCreation(cell); } base.TouchesBegan(touches, evt); }
public LinePoint (UITouch touch, int sequenceNumber, PointType pointType) { SequenceNumber = sequenceNumber; Type = touch.Type; PointType = pointType; Timestamp = touch.Timestamp; var view = touch.View; Location = touch.LocationInView (view); PreciseLocation = touch.GetPreciseLocation (view); AzimuthAngle = touch.GetAzimuthAngle (view); EstimatedProperties = touch.EstimatedProperties; EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates; AltitudeAngle = touch.AltitudeAngle; Force = (Type == UITouchType.Stylus || touch.Force > 0) ? touch.Force : 1f; if (EstimatedPropertiesExpectingUpdates != 0) PointType = this.PointType.Add (PointType.NeedsUpdate); EstimationUpdateIndex = touch.EstimationUpdateIndex; }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { var touchPoint = uitouch.LocationInView(this); if (_lowerTouchEdgeInsets.InsetRect(_lowerHandle.Frame).Contains(touchPoint) && !LowerHandleHidden) { _lowerHandle.Highlighted = true; _lowerTouchOffset = (float)touchPoint.X - (float)_lowerHandle.Center.X; } if (_upperTouchEdgeInsets.InsetRect(_upperHandle.Frame).Contains(touchPoint) && !UpperHandleHidden) { _upperHandle.Highlighted = true; _upperTouchOffset = (float)touchPoint.X - (float)_upperHandle.Center.X; } _stepValueInternal = StepValueContinuously ? StepValue : 0.0f; DragStarted?.Invoke(this, EventArgs.Empty); return(true); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { GestureEndResetMembers(obj); CurrentPoint = new CGPoint(0, 0); UITouch touch = (UITouch)touches.AnyObject; CGPoint point = touch.LocationInView(this); foreach (PCCircle circle in Subviews) { if (circle.Frame.Contains(point)) { circle.State = CircleState.CircleStateSelected; CircleSet.Add(circle); } } if (CircleSet.Count > 0) { //数组中最后一个对象的处理 CircleSetLastObjectWithState(CircleState.CircleStateLastOneSelected); SetNeedsDisplay(); } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); iTouchedInner = false; iOutsideInner = false; iTouchedOuter = false; iOutsideOuter = false; iRotating = false; UITouch touch = touches.AnyObject as UITouch; PointF point = touch.LocationInView(this); float dx = point.X - Centre.X; float dy = point.Y - Centre.Y; float r2 = dx * dx + dy * dy; if (r2 > iInnerRadius * iInnerRadius) { iTouchedOuter = true; iRotating = true; if (EventStartRotation != null) { EventStartRotation(this, EventArgs.Empty); } } else { iTouchedInner = true; } iTouchDownAngle = CalculateMouseAngle(point); iLastTouchAngle = iTouchDownAngle; SetNeedsDisplay(); }
public override void TouchesMoved(NSSet touches, UIEvent evt) { CurrentPoint = new CGPoint(0, 0); UITouch touch = (UITouch)touches.AnyObject; CGPoint point = touch.LocationInView(this); foreach (PCCircle circle in Subviews) { if (circle.Frame.Contains(point)) { if (!CircleSet.Contains(circle)) { CircleSet.Add(circle); // move过程中的连线(包含跳跃连线的处理) CalAngleAndconnectTheJumpedCircle(); } } else { CurrentPoint = point; } } foreach (PCCircle circle in CircleSet) { circle.State = CircleState.CircleStateSelected; // 如果是登录或者验证原手势密码,就改为对应的状态 (加上这句没有三角箭头) //if (Type != CircleViewType.CircleViewTypeSetting) //{ // circle.State = CircleState.CircleStateLastOneSelected; //} } if (CircleSet.Count > 0) { // 数组中最后一个对象的处理 CircleSetLastObjectWithState(CircleState.CircleStateLastOneSelected); SetNeedsDisplay(); } }
public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { var TouchPoint = uitouch.LocationInView(this); if (_leftKnobLayer.Highlighted) { _leftTouchPoint = TouchPoint; } else if (_rightKnobLayer.Highlighted) { _rightTouchPoint = TouchPoint; } CATransaction.Begin(); CATransaction.DisableActions = true; SetLayerFrames(); CATransaction.Commit(); return(_leftKnobLayer.Highlighted || _rightKnobLayer.Highlighted); }
public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt) { foreach (UITouch pointer in touches) { if (_pointer1 == null) { _pointer1 = pointer; CGPoint screenPos1 = _pointer1.LocationInView(this); _baseMapView.OnInputEvent(NativeActionPointer1Down, (float)screenPos1.X * _scale, (float)screenPos1.Y * _scale, NativeNoCoordinate, NativeNoCoordinate); continue; } if (_pointer2 == null) { _pointer2 = pointer; CGPoint screenPos1 = _pointer1.LocationInView(this); CGPoint screenPos2 = _pointer2.LocationInView(this); _baseMapView.OnInputEvent(NativeActionPointer2Down, (float)screenPos1.X * _scale, (float)screenPos1.Y * _scale, (float)screenPos2.X * _scale, (float)screenPos2.Y * _scale); break; } } }
/// <summary> /// TouchesBegan is called whenever a new touch is added to the gesture. /// </summary> public override void TouchesBegan(NSSet touches, UIEvent evt) { NSSet AllTouchesInRecognizer = evt.TouchesForGestureRecognizer(this); if (!UserHasBegunGesture) { UITouch touch = (UITouch)touches.AnyObject; TrackingTouch = touch; AnchorLocation = touch.LocationInView(this.View); UserHasBegunGesture = true; State = UIGestureRecognizerState.Began; } // Ignore any touches above 2 if (AllTouchesInRecognizer.Count > 2) { HasSingleTouch = false; HasTwoTouches = false; HasMoreThanTwoTouches = true; Reset(); } if (AllTouchesInRecognizer.Count == 1) { HasSingleTouch = true; HasTwoTouches = false; HasMoreThanTwoTouches = false; } if (AllTouchesInRecognizer.Count == 2) { MidpointLocation = MidPointBetweenTouches(AllTouchesInRecognizer); StartLocation = MidpointLocation; HasSingleTouch = false; HasTwoTouches = true; HasMoreThanTwoTouches = false; } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); UITouch touch = touches.AnyObject as UITouch; if (touch != null) { var touchLocation = touch.LocationInView(View); if (touchLocation.X >= 250 && touchLocation.Y >= 22) { DatePickerView.Hidden = true; PickerUIViewInt.Frame = new RectangleF((float)PickerUIViewInt.Frame.X, 239, (float)UIScreen.MainScreen.Bounds.Width, (float)PickerUIViewInt.Frame.Height); if (leftmenu.Frame.X >= 0) { leftmenu.Frame = new RectangleF(-250, 0, 250, (float)UIScreen.MainScreen.Bounds.Height); ReserverMainTouchView.Frame = new RectangleF(0, 0, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height); } } } }
public override void TouchesMoved(NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); // get the touch UITouch touch = touches.AnyObject as UITouch; if (touch != null) { CustomContentPage page = ((CustomContentPage)this.Element); PointF posc = (PointF)touch.LocationInView(this.View); var circle = page.circles[0]; bool found = false; foreach (var item in page.circles) { if (item.active) { circle = item; found = true; break; } } if (found) { if (circle.startX - circle.sizeX <= posc.X && posc.X <= circle.startX + circle.sizeX && circle.startY - circle.sizeY <= posc.Y && posc.Y <= circle.startY + circle.sizeY) { if (touch.TapCount == 1) { circle.startX = posc.X; circle.startY = posc.Y; circle.Update = !circle.Update; } } } lastClick = DateTime.Now; } }
public override void TouchesBegan(Foundation.NSSet touches, UIEvent evt) { //Create a new path and set the options. currentPath = UIBezierPath.Create(); currentPath.LineWidth = StrokeWidth; currentPath.LineJoinStyle = CGLineJoin.Round; currentPoints.Clear(); UITouch touch = touches.AnyObject as UITouch; //Obtain the location of the touch, move the path to that position and add it to the //current_points array. CGPoint touchLocation = touch.LocationInView(this); currentPath.MoveTo(touchLocation); currentPoints.Add(touchLocation); resetBounds(touchLocation); btnClear.Hidden = false; }
UISwipeGestureRecognizerDirection GetGestureDirectionWithTouch(UITouch touch) { CGPoint gestureEndPoint = touch.LocationInView(this); double dx = Math.Abs(this.GestureStartPoint.X - gestureEndPoint.X); nfloat dy = -1 * (gestureEndPoint.Y - this.GestureStartPoint.Y); if (dx > 20) { return(UISwipeGestureRecognizerDirection.Right); } if (dy < 0) { return(UISwipeGestureRecognizerDirection.Down); } else if (dy > 0) { return(UISwipeGestureRecognizerDirection.Up); } return(UISwipeGestureRecognizerDirection.Down); }
public bool ShouldReceiveTouch (UIGestureRecognizer gestureRecognizer, UITouch touch) { // Ignore drags outside of the region of interest (plus some padding). if (gestureRecognizer == resizeRegionOfInterestGestureRecognizer) { var touchLocation = touch.LocationInView (gestureRecognizer.View); var paddedRegionOfInterest = RegionOfInterest.Inset (-regionOfInterestCornerTouchThreshold, -regionOfInterestCornerTouchThreshold); if (!paddedRegionOfInterest.Contains (touchLocation)) return false; } return true; }
public void ButtonFinished (ButtonView button, UIView trackingView, UITouch location) { double delayInSeconds = 0; buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; CGPoint point = location.LocationInView (miniPadView); if (miniPadView.PointInside (point, null)) { updateScoreForDroppedButton (button); UIView.Animate (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180), async () => { await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (-10f * (float)Math.PI / 180)); await UIView.AnimateAsync (.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation (0)); }); } delayInSeconds = 0.5; var popTime = new DispatchTime (DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC)); DispatchQueue.MainQueue.DispatchAfter (popTime, async () => { await UIView.AnimateAsync (0.35f, () => { CGRect bounds = trackingView.Bounds; bounds.Size = new CGSize (10, 10); trackingView.Bounds = bounds; }); trackingView.RemoveFromSuperview (); }); }
public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { // PointF previousLocation = uitouch.PreviousLocationInView(this); // PointF currentLocation = uitouch.LocationInView(this); // float trackingOffset = currentLocation.X - previousLocation.X; // // // Find the scrubbing speed that corresponds to the touch's vertical offset // float verticalOffset = Math.Abs(currentLocation.Y - beganTrackingLocation.Y); // int scrubbingSpeedChangePosIndex = IndexOfLowerScrubbingSpeed(_scrubbingSpeedChangePositions, verticalOffset); // if(scrubbingSpeedChangePosIndex == -1) // scrubbingSpeedChangePosIndex = _scrubbingSpeeds.Count; // this.scrubbingSpeed = _scrubbingSpeeds[scrubbingSpeedChangePosIndex - 1]; // // RectangleF trackRect = TrackRectForBounds(Bounds); // this.realPositionValue = this.realPositionValue * (MaxValue - MinValue) * (trackingOffset / trackRect.Size.Width); // // float valueAdjustment = this.scrubbingSpeed * (MaxValue - MinValue) * (trackingOffset / trackRect.Size.Width); // float thumbAdjustment = 0; // if(((this.beganTrackingLocation.Y < currentLocation.Y) && (currentLocation.Y < previousLocation.Y)) || // ((this.beganTrackingLocation.Y > currentLocation.Y) && (currentLocation.Y > previousLocation.Y))) // { // thumbAdjustment = (this.realPositionValue - Value) / (1 + Math.Abs(currentLocation.Y - this.beganTrackingLocation.Y)); // } // Value += valueAdjustment + thumbAdjustment; // // if(Continuous) // SendActionForControlEvents(UIControlEvent.ValueChanged); // // OnContinueTrackingEvent(new EventArgs()); // return Tracking; PointF ptPrev = uitouch.PreviousLocationInView(this); PointF pt = uitouch.LocationInView(this); //float relativeX = pt.X - Frame.X; //float ratioX = relativeX / Frame.Width; float widthWithFinger = Frame.Width + 44; float normalizedX = (pt.X < 0) ? 0 : pt.X; normalizedX = (pt.X > widthWithFinger) ? widthWithFinger : normalizedX; float ratioX = normalizedX / widthWithFinger; // Determine type of scrubbing var scrubbingType = SliderScrubbingType.HighSpeed; if(pt.Y - Frame.Y + Frame.Height > 300) { scrubbingType = SliderScrubbingType.Fine; } else if(pt.Y - Frame.Y + Frame.Height > 200) { scrubbingType = SliderScrubbingType.QuarterSpeed; } else if(pt.Y - Frame.Y + Frame.Height > 100) { scrubbingType = SliderScrubbingType.HalfSpeed; } // Check if event needs to be raised if(scrubbingType != ScrubbingType) { //Console.WriteLine("Slider - Changed scrubbing type to " + scrubbingType.ToString()); ScrubbingType = scrubbingType; OnScrubbingTypeChanged(new EventArgs()); } // Calculate new value float newValueDelta = (ratioX * 10000) - Value; switch(scrubbingType) { case SliderScrubbingType.HalfSpeed: newValueDelta = newValueDelta * 0.5f; break; case SliderScrubbingType.QuarterSpeed: newValueDelta = newValueDelta * 0.25f; break; case SliderScrubbingType.Fine: newValueDelta = newValueDelta * 0.1f; break; } // float newValue = Value + newValueDelta; // if(newValue < MinValue) // newValue = MinValue; // if(newValue > MaxValue) // newValue = MaxValue; // // Value = newValue; // // //SetValue(newValue, true); // Console.WriteLine("Slider - ContinueTracking - newValue: " + newValue.ToString() + " newValueDelta: " + newValueDelta.ToString() + " (" + ptPrev.X.ToString() + ", " + ptPrev.Y.ToString() + ") (" + pt.X.ToString() + ", " + pt.Y.ToString() + ") normalizedX: " + normalizedX.ToString() + " ratioX: " + ratioX.ToString()); // // // // if(Continuous) // SendActionForControlEvents(UIControlEvent.ValueChanged); // // return true; return base.ContinueTracking(uitouch, uievent); }
bool shouldAutomaticallyRemoveFingerTipForTouch(UITouch touch) { // We don't reliably get UITouchPhaseEnded or UITouchPhaseCancelled // events via -sendEvent: for certain touch events. Known cases // include swipe-to-delete on a table view row, and tap-to-cancel // swipe to delete. We automatically remove their associated // fingertips after a suitable timeout. // // It would be much nicer if we could remove all touch events after // a suitable time out, but then we'll prematurely remove touch and // hold events that are picked up by gesture recognizers (since we // don't use UITouchPhaseStationary touches for those. *sigh*). So we // end up with this more complicated setup. var view = touch.View; if (view != null) { view = view.HitTest (touch.LocationInView (view), null); while (view != null) { if (view is UITableViewCell) { foreach (UIGestureRecognizer recognizer in touch.GestureRecognizers) { if (recognizer is UISwipeGestureRecognizer) { return true; } } } if (view is UITableView) { if (touch.GestureRecognizers.Length == 0) { return true; } } view = view.Superview; } } return false; }
public override bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch) { if (!_controller.PanGestureEnabled) return false; if (_controller.IsOpen) return true; var locationInView = touch.LocationInView(_controller.ContainerView); if (locationInView.Y <= _controller._slideHandleHeight) { // This is a hack that I don't like but need for now var topNavigationController = _controller.MainViewController as UINavigationController; if (topNavigationController != null && topNavigationController.ViewControllers.Length == 1) return true; if (_controller.EnableInteractivePopGestureRecognizer && locationInView.X <= 10f) return false; return true; } return false; }
private bool SelectDayView(UITouch touch) { var p = touch.LocationInView (this); int index = ((int)p.Y / 44) * 7 + ((int)p.X / 46); if (index < 0 || index >= _dayTiles.Count) return false; var newSelectedDayView = _dayTiles[index]; if (newSelectedDayView == SelectedDayView) return false; if (!newSelectedDayView.Active && touch.Phase != UITouchPhase.Moved) { var day = int.Parse (newSelectedDayView.Text); if (day > 15) _calendarMonthView.MoveCalendarMonths (false, true); else _calendarMonthView.MoveCalendarMonths (true, true); return false; } else if (!newSelectedDayView.Active) { return false; } SelectedDayView.Selected = false; this.BringSubviewToFront (newSelectedDayView); newSelectedDayView.Selected = true; SelectedDayView = newSelectedDayView; SetNeedsDisplay (); return true; }
private MenuItem ItemForTouch(UITouch touch) { PointF touchLocation = touch.LocationInView(touch.View); touchLocation = Director.Instance.ConvertCoordinate(touchLocation); foreach (MenuItem item in Children) { PointF local = item.ConvertToNodeSpace(touchLocation); RectangleF r = item.Rect; r.X = 0; r.Y = 0; if (r.Contains(local) && item.IsEnabled) { return item; } } return null; }
private System.Drawing.PointF GetPosition(UITouch touch) { var p = touch.LocationInView(touch.View); // convert point to pixels var scale = touch.View.ContentScaleFactor; p.X *= scale; p.Y *= scale; return p; }
public void ButtonDragged (ButtonView button, UITouch location) { CGPoint point = location.LocationInView (miniPadView); if (miniPadView.PointInside (point, null)) { if (!buttonDraggedToPad) { CATransaction.Begin (); CATransaction.AnimationDuration = 1; miniPadView.Layer.BorderColor = UIColor.Yellow.CGColor; miniPadView.Layer.BorderWidth = 2; CATransaction.Commit (); buttonDraggedToPad = true; if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification (UIAccessibilityPostNotification.Announcement, (NSString)"Memory object near the zombies, Lift to deploy"); } } } else { if (buttonDraggedToPad) { if (!isVoiceOverSpeaking) { isVoiceOverSpeaking = true; UIAccessibility.PostNotification (UIAccessibilityPostNotification.Announcement, (NSString)"Memory object outside iPad. Lift to Cancel"); } } buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; } }
bool OnShouldReceiveTouch(UIGestureRecognizer r, UITouch t) { var scrollPos = t.LocationInView(_scrollView); var rect = new RectangleF(0, 0, _scrollView.ContentSize.Width, _scrollView.ContentSize.Height); return !rect.Contains(scrollPos); }
// #pragma mark - UIControl functions public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { base.ContinueTracking(uitouch, uievent); CGPoint lastPoint = uitouch.LocationInView(this); MoveHandle(lastPoint); SendActionForControlEvents(UIControlEvent.ValueChanged); return true; }
private float GetTouchPoint(UITouch touch) { var location = touch.LocationInView(this); var x = location.X; var y = location.Y; if (x < _bounds.Left) x = _bounds.Left; if (x > _bounds.Right) x = _bounds.Right; if (y < _bounds.Top) y = _bounds.Top; if (y > _bounds.Bottom) y = _bounds.Bottom; _sliderPositionRaw = new CGPoint(x, _bounds.GetMidY()); var scaleX = _bounds.Width / 2f; x = (x - scaleX) * 100f / scaleX; System.Diagnostics.Debug.WriteLine($"GetTouchPoint: x={x}"); return (float)x; }
public bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch) { if (leftRingControl.HitTest (touch.LocationInView (leftRingControl), null) != null) return false; foreach(var button in buttons) { if (button.HitTest (touch.LocationInView (clearButton), null) != null) return false; } return true; }
public override bool ShouldReceiveTouch (UIGestureRecognizer recognizer, UITouch touch) { return (_controller.Visible || (touch.LocationInView (_controller._internalTopView.View).Y <= _controller.SlideHeight)) && (_controller.LeftMenuEnabled || _controller.RightMenuEnabled); }
private CustomMDP GetTouchTarget(UITouch touch) { CustomMDP target = null; var grid = Element.FindByName<ContentPage>("Detail"); var point = touch.LocationInView(this.View); var x = point.X - grid.X; var y = point.Y - grid.Y; var content = grid.Content as StackLayout; foreach (var child in content.Children) { if (child.Bounds.Contains(x, y)) { break; } } return target; }
public override bool BeginTracking(UITouch touch, UIEvent uievent) { _previousTouchPoint = (CGPoint)touch.LocationInView((UIView)this); // hit test the knob layers if (_lowerKnobLayer.PaintFrame.Contains(_previousTouchPoint)) { _lowerKnobLayer.Highlighted = true; _lowerKnobLayer.SetNeedsDisplay(); } else if (_upperKnobLayer.PaintFrame.Contains(_previousTouchPoint)) { _upperKnobLayer.Highlighted = true; _upperKnobLayer.SetNeedsDisplay(); } RawHighValue = HighValue; RawLowValue = LowValue; return _upperKnobLayer.Highlighted || _lowerKnobLayer.Highlighted; }
UISwipeGestureRecognizerDirection GetGestureDirectionWithTouch(UITouch touch) { CGPoint gestureEndPoint = touch.LocationInView(this); double dx = Math.Abs(this.GestureStartPoint.X - gestureEndPoint.X); nfloat dy = -1 * (gestureEndPoint.Y - this.GestureStartPoint.Y); if (dx > 20) { return UISwipeGestureRecognizerDirection.Right; } if (dy < 0) { return UISwipeGestureRecognizerDirection.Down; } else if (dy > 0) { return UISwipeGestureRecognizerDirection.Up; } return UISwipeGestureRecognizerDirection.Down; }
void UpdateReticleView (UITouch touch, bool predicated = false) { if (touch == null) return; ReticleView.PredictedDotLayer.Hidden = !predicated; ReticleView.PredictedLineLayer.Hidden = !predicated; ReticleView.Center = touch.LocationInView (touch.View); var azimuthAngle = touch.GetAzimuthAngle (touch.View); var azimuthUnitVector = touch.GetAzimuthUnitVector (touch.View); var altitudeAngle = touch.AltitudeAngle; if (predicated) { ReticleView.PredictedAzimuthAngle = azimuthAngle; ReticleView.PredictedAzimuthUnitVector = azimuthUnitVector; ReticleView.PredictedAzimuthAngle = altitudeAngle; } else { ReticleView.ActualAzimuthAngle = azimuthAngle; ReticleView.ActualAzimuthUnitVector = azimuthUnitVector; ReticleView.ActualAzimuthAngle = altitudeAngle; } }
public override bool ContinueTracking(UITouch touch, UIEvent uievent) { CGPoint touchPoint = (CGPoint)touch.LocationInView((UIView)this); // 1. determine by how much the user has dragged var delta = touchPoint.X - _previousTouchPoint.X; var valueDelta = (MaxValue - MinValue) * delta / _useableTrackLength; _previousTouchPoint = touchPoint; // 2. update the values if (_lowerKnobLayer.Highlighted) { RawLowValue += valueDelta; RawLowValue = (nfloat)Math.Min(Math.Max(RawLowValue, MinValue), HighValue); //(_lowerValue, _upperValue, _minimumValue); if (increment > 0) { LowValue = (int)(RawLowValue / increment) * increment; } else { LowValue = RawLowValue; } } if (_upperKnobLayer.Highlighted) { RawHighValue += valueDelta; RawHighValue = (nfloat)Math.Max(Math.Min(RawHighValue, MaxValue), LowValue); if (increment > 0) { HighValue = (int)(RawHighValue / increment) * increment; } else { HighValue = RawHighValue; } } // 3. Update the UI state CATransaction.Begin(); CATransaction.DisableActions = true; setLayerFrames(); CATransaction.Commit(); if (_lowerKnobLayer.Highlighted) { LowerSliderChanged(this, new EventArgs()); } else { UpperSliderChanged(this, new EventArgs()); } if (_lowerKnobLayer.Highlighted || _upperKnobLayer.Highlighted) return true; return false; //return true; }
bool TouchIsInRect (UITouch touch, CGRect rect) { rect = CGAffineTransform.CGRectApplyAffineTransform (rect, CGAffineTransform.MakeScale (Bounds.Width, Bounds.Height)); return rect.Contains (touch.LocationInView (this)); }
Crayon GetTouchingCrayon(UITouch touch) { var location = touch.LocationInView (this); var pos = CRAYON_START - CRAYON_SPACING; foreach (var crayon in Crayons) { switch (Orientation) { case UIInterfaceOrientation.Portrait: case UIInterfaceOrientation.PortraitUpsideDown: if ((location.X > Frame.Width - crayon.Length) && (location.Y > pos) && (location.Y < pos + CRAYON_SPACING / 2 + crayon.Width + CRAYON_SPACING / 2)) return crayon; break; case UIInterfaceOrientation.LandscapeLeft: case UIInterfaceOrientation.LandscapeRight: if ((location.Y > Frame.Height - crayon.Length) && (location.X < Frame.Width - pos) && (location.X > Frame.Width - pos - CRAYON_SPACING / 2 - crayon.Width - CRAYON_SPACING / 2)) return crayon; break; } pos += crayon.Width + CRAYON_SPACING; } return null; }
private Core.Models.Point GetTouchPoint(UITouch touch) { var location = touch.LocationInView(this); var x = location.X; var y = location.Y; if (x < _bounds.Left) x = _bounds.Left; if (x > _bounds.Right) x = _bounds.Right; if (y < _bounds.Top) y = _bounds.Top; if (y > _bounds.Bottom) y = _bounds.Bottom; _joystickPositionRaw = new CGPoint(x, y); var scaleX = _bounds.Width / 2f; var scaleY = _bounds.Height / 2f; x = (x - scaleX) * 100f / scaleX; y = (y - scaleY) * 100f / scaleY; System.Diagnostics.Debug.WriteLine($"GetTouchPoint: x={x}, y={y}"); return new Core.Models.Point((float)x, (float)y); }
bool GestureRecognizerShouldReceiveTouch(UIGestureRecognizer gestureRecognizer, UITouch touch) { if (_ios7) { if (_interactivePopGestureRecognizerEnabled && (_contentViewController is UINavigationController)) { UINavigationController navigationController = _contentViewController as UINavigationController; if (navigationController.ViewControllers.Length > 1 && navigationController.InteractivePopGestureRecognizer.Enabled) { return false; } } } if (_panFromEdge && gestureRecognizer is UIPanGestureRecognizer && !Visible) { var point = touch.LocationInView(gestureRecognizer.View); if (point.X < 20.0 || point.X > View.Frame.Size.Width - 20.0) { return true; } else { return false; } } return true; }
public bool UpdateWithTouch (UITouch touch) { if (!touch.EstimationUpdateIndex.IsEqualTo(EstimationUpdateIndex)) return false; // An array of the touch properties that may be of interest. UITouchProperties[] touchProperties = { UITouchProperties.Location, UITouchProperties.Force, UITouchProperties.Altitude, UITouchProperties.Azimuth }; // Iterate through possible properties. foreach (var expectedProperty in touchProperties) { // If an update to this property is not expected, continue to the next property. if (EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty)) continue; switch (expectedProperty) { case UITouchProperties.Force: Force = touch.Force; break; case UITouchProperties.Azimuth: AzimuthAngle = touch.GetAzimuthAngle (touch.View); break; case UITouchProperties.Altitude: AltitudeAngle = touch.AltitudeAngle; break; case UITouchProperties.Location: Location = touch.LocationInView (touch.View); PreciseLocation = touch.PreviousLocationInView (touch.View); break; } // Flag that this point now has a 'final' value for this property. if (!touch.EstimatedProperties.HasFlag (expectedProperty)) EstimatedProperties &= ~expectedProperty; // Flag that this point is no longer expecting updates for this property. if (!touch.EstimatedPropertiesExpectingUpdates.HasFlag (expectedProperty)) { EstimatedPropertiesExpectingUpdates &= ~expectedProperty; if (EstimatedPropertiesExpectingUpdates == 0) { PointType &= ~PointType.NeedsUpdate; PointType |= PointType.Updated; } } } return true; }