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 void EndTracking(UITouch uitouch, UIEvent uievent) { _leftKnobLayer.Highlighted = false; _rightKnobLayer.Highlighted = false; _leftKnobLayer.SetNeedsDisplay (); _rightKnobLayer.SetNeedsDisplay (); }
public override bool ContinueTracking (UITouch uitouch, UIEvent uievent) { var touch = uievent.AllTouches.AnyObject as UITouch; if (Bounds.Contains (touch.LocationInView (this))) isPressed = true; else isPressed = false; return base.ContinueTracking (uitouch, uievent); }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { if (uievent.Type == UIEventType.Touches) { SetNeedsDisplay(); } return base.BeginTracking(uitouch, uievent); }
public override void EndTracking (UITouch uitouch, UIEvent uievent) { if (isPressed && Enabled){ if (Tapped != null) Tapped (this); } isPressed = false; SetNeedsDisplay (); base.EndTracking (uitouch, uievent); }
public override void EndTracking(UITouch uitouch, UIEvent uievent) { if (pressed && Enabled) { Tapped?.Invoke(this); } pressed = false; SetNeedsDisplay(); base.EndTracking(uitouch, uievent); }
public bool UpdateWithTouch (UITouch touch) { NSNumber estimationUpdateIndex = touch.EstimationUpdateIndex; if (estimationUpdateIndex != 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.Has (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; } if (!touch.EstimatedProperties.Has (expectedProperty)) { // Flag that this point now has a 'final' value for this property. EstimatedProperties = EstimatedProperties.Remove (expectedProperty); } if (!touch.EstimatedPropertiesExpectingUpdates.Has (expectedProperty)) { // Flag that this point is no longer expecting updates for this property. EstimatedPropertiesExpectingUpdates = EstimatedPropertiesExpectingUpdates.Remove (expectedProperty); if (EstimatedPropertiesExpectingUpdates == 0) { PointType = this.PointType.Remove (PointType.NeedsUpdate); PointType = this.PointType.Add (PointType.Updated); } } } return true; }
public CGRect AddPointOfType(PointType pointType, UITouch touch) { var previousPoint = Points.LastOrDefault (); var previousSequenceNumber = previousPoint != null ? previousPoint.SequenceNumber : -1; var point = new LinePoint (touch, previousSequenceNumber + 1, pointType); if (point.EstimationUpdateIndex != null && point.EstimatedPropertiesExpectingUpdates != 0) pointsWaitingForUpdatesByEstimationIndex [point.EstimationUpdateIndex] = point; Points.Add (point); return UpdateRectForLinePoint (point, previousPoint); }
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; }
private PointerState GetState(UITouch touch) { switch (touch.Phase) { case UITouchPhase.Began: return PointerState.Down; case UITouchPhase.Moved: case UITouchPhase.Stationary: return PointerState.Move; case UITouchPhase.Ended: return PointerState.Up; case UITouchPhase.Cancelled: return PointerState.Cancel; } throw new ArgumentException("Got an invalid Touch event in GetState"); }
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 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 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 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 void TouchesMoved(MonoTouch.Foundation.NSSet touches, UIEvent evt) { // Create a path under the finger following the grid if (touches.Count == 1) { // Valid movement if (mParent.IsCreatingPath) { UITouch touch = (UITouch)touches.AnyObject; PointF fingerLocation = touch.LocationInView(this); Cell cell = getCellFromViewCoordinates(fingerLocation); mParent.CreatePath(cell); } } base.TouchesMoved(touches, evt); }
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 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); }
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) { UITouch touch = (UITouch)touches.AnyObject; UIView.PerformWithoutAnimation(() => { X = X + touch.LocationInView(Screen.GlobalScreen).X - touch.PreviousLocationInView(Screen.GlobalScreen).X; Y = Y + touch.LocationInView(Screen.GlobalScreen).Y - touch.PreviousLocationInView(Screen.GlobalScreen).Y; Clamp(); }); CGPoint newVelocity = CGPoint.Empty; newVelocity.X = touch.LocationInView(Screen.GlobalScreen).X - (nfloat)(touch.PreviousLocationInView(Screen.GlobalScreen).X / (touch.Timestamp - lastTime)); newVelocity.Y = touch.LocationInView(Screen.GlobalScreen).Y - (nfloat)(touch.PreviousLocationInView(Screen.GlobalScreen).Y / (touch.Timestamp - lastTime)); velocity.X = 0.25f * velocity.X + 0.75f * newVelocity.X; velocity.Y = 0.25f * velocity.Y + 0.75f * newVelocity.Y; lastTime = touch.Timestamp; }
public override void TouchesEnded(NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); ActivePanel.TouchesEnded( ); UITouch touch = (UITouch)touches.AnyObject; CGPoint posInMain = touch.LocationInView(MainPanel); // if they tap outside the window (in the shaded area) dismiss this. if ((posInMain.X < 0 || posInMain.X > MainPanel.Bounds.Width) || (posInMain.Y < 0 || posInMain.Y > MainPanel.Bounds.Height)) { // confirm they want to cancel //ConfirmCancel( ); DismissAnimated(false, null); } }
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(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); // we can get the number of fingers from the touch count, but Multitouch must be enabled lblNumberOfFingers.Text = "Number of fingers: " + touches.Count.ToString(); // get the touch UITouch touch = touches.AnyObject as UITouch; if (touch != null) { Console.WriteLine("screen touched"); //==== IMAGE TOUCH if (imgTouchMe.Frame.Contains(touch.LocationInView(View))) { lblTouchStatus.Text = "TouchesBegan"; } //==== IMAGE DOUBLE TAP if (touch.TapCount == 2 && imgTapMe.Frame.Contains(touch.LocationInView(View))) { if (imageHighlighted) { imgTapMe.Image = UIImage.FromBundle("Images/DoubleTapMe.png"); } else { imgTapMe.Image = UIImage.FromBundle("Images/DoubleTapMe_Highlighted.png"); } imageHighlighted = !imageHighlighted; } //==== IMAGE DRAG // check to see if the touch started in the dragme image if (imgDragMe.Frame.Contains(touch.LocationInView(View))) { touchStartedInside = true; } } }
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 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 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 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 PointerState GetState(UITouch touch) { switch (touch.Phase) { case UITouchPhase.Began: return(PointerState.Down); case UITouchPhase.Moved: case UITouchPhase.Stationary: return(PointerState.Move); case UITouchPhase.Ended: return(PointerState.Up); case UITouchPhase.Cancelled: return(PointerState.Cancel); } throw new ArgumentException("Got an invalid Touch event in GetState"); }
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 touchEvent) { foreach (UITouch touch in touches) { if (TouchIsInRect(touch, padRect)) { padTouch = padTouch ?? touch; } else if (panningTouch == null) { panningTouch = (UITouch)touches.AnyObject; } if (padTouch != null && panningTouch != null) { break; } } base.TouchesBegan(touches, touchEvent); }
public override void TouchesMoved(NSSet touches, UIEvent theEvent) { // base.TouchesMoved(touches, evt); UITouch touch = (UITouch)touches.AnyObject; CGPoint gestureEndPoint = touch.LocationInView(this); this.GestureDirection = this.GetGestureDirectionWithTouch(touch); bool canScroll = this.CanScroll(this.GestureDirection); if (canScroll) { if (this.TheDelegate != null) { this.TheDelegate.iOSCardsView_Scrolling(this.GestureDirection); } } if ((this.GestureDirection == UISwipeGestureRecognizerDirection.Up | this.GestureDirection == UISwipeGestureRecognizerDirection.Down) && canScroll) { var offsetFrame = new CGRect(new CGPoint(this.Frame.X, this.Frame.Location.Y + (gestureEndPoint.Y - this.GestureStartPoint.Y)), this.Frame.Size); this.Frame = offsetFrame; } else if (this.GestureDirection == UISwipeGestureRecognizerDirection.Left | this.GestureDirection == UISwipeGestureRecognizerDirection.Right) { if (this.GestureView.IsEqual(this) | !this.ViewCanSwipe(this.GestureView)) { return; } gestureEndPoint = touch.LocationInView(this.GestureView); var offsetFrame = new CGRect(new CGPoint(this.GestureView.Frame.X + (gestureEndPoint.X - this.GestureStartPoint.X), this.GestureView.Frame.Y), this.GestureView.Frame.Size); this.GestureView.Frame = offsetFrame; if (this.GestureView.Alpha > 0.4) { this.GestureView.Alpha = this.GestureView.Alpha - 0.03f; } } }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); // If Multitouch is enabled, report the number of fingers down TouchStatus.Text = string.Format("Number of fingers {0}", touches.Count); // Get the current touch UITouch touch = touches.AnyObject as UITouch; if (touch != null) { // Check to see if any of the images have been touched if (TouchImage.Frame.Contains(touch.LocationInView(TouchView))) { // Fist image touched TouchImage.Image = UIImage.FromBundle("TouchMe_Touched.png"); TouchStatus.Text = "Touches Began"; } else if (touch.TapCount == 2 && DoubleTouchImage.Frame.Contains(touch.LocationInView(TouchView))) { // Second image double-tapped, toggle bitmap if (imageHighlighted) { DoubleTouchImage.Image = UIImage.FromBundle("DoubleTapMe.png"); TouchStatus.Text = "Double-Tapped Off"; } else { DoubleTouchImage.Image = UIImage.FromBundle("DoubleTapMe_Highlighted.png"); TouchStatus.Text = "Double-Tapped On"; } imageHighlighted = !imageHighlighted; } else if (DragImage.Frame.Contains(touch.LocationInView(View))) { // Third image touched, prepare to drag touchStartedInside = true; } } }
public override bool ShouldReceiveTouch(UIGestureRecognizer recognizer, UITouch touch) { if (recognizer.View.IsDescendantOfView(touch.View)) { return(true); } if (recognizer.View is not IVisualNativeElementRenderer elementRenderer || elementRenderer.Control == null) { return(false); } if (elementRenderer.Control == touch.View || elementRenderer.Control.Subviews.Any(view => view == touch.View)) { return(true); } return(false); }
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 void TouchesBegan(NSSet touches, UIEvent evt) { if (trackedTouch == null) { trackedTouch = (UITouch)touches.FirstOrDefault(); initialTimestamp = trackedTouch.Timestamp; if (!IsForPencil) { BeginIfNeeded(null); } fingerStartTimer = NSTimer.CreateScheduledTimer(cancellationTimeInterval, BeginIfNeeded); } if (Append(Touches(touches), evt)) { if (IsForPencil) { State = Began; } } }
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); }
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 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 void TouchesMoved(NSSet touches, UIEvent evt) { CanvasView.DrawTouches(touches, evt); var touch = (UITouch)touches.FirstOrDefault(); if (touch == null) { return; } UpdateReticleView(touch); // Use the last predicted touch to update the reticle. UITouch[] predictedTouches = evt?.GetPredictedTouches(touch); UITouch predictedTouch = predictedTouches?.LastOrDefault(); if (predictedTouch != null) { UpdateReticleView(predictedTouch, true); } }
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 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(); }
// handle touch events public override void TouchesEnded(NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); // Get the touch that was activated within the view UITouch myTouch = (UITouch)touches.AnyObject; if (gameTileImagesArray.Contains(myTouch.View) && selAllowed) { // get the image at the postion within the view UIImageView gameBoardTile = (UIImageView)myTouch.View; // Get the index of the image within out array int tileIndex = gameTileImagesArray.IndexOf(gameBoardTile); int imageIndex = (tileIndex < gameBoardSize ? tileIndex : tileIndex - gameBoardSize); // call our instance method to handle flipping of the chosen tiles flipGameBoardTiles(gameBoardTile, tileIndex, imageIndex); } }
private bool chart_clickBackGround(UIGestureRecognizer recognizer, UITouch touch) { //Console.WriteLine("BackGround clicked"); return false; }
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; } }
bool ShouldReceiveTouch (UIGestureRecognizer gestureRecognizer, UITouch touch) { if (touch.View != View) return false; return true; }
internal bool shouldReceiveTouch(UIGestureRecognizer gesture, UITouch touch) { if (ShouldReceiveTouch != null) return ShouldReceiveTouch(gesture, touch); return true; }
public bool beginTrackingWithTouch( UITouch touch ,/*withEvent*/ UIEvent @event){ bool begins = base.BeginTracking(touch ,/*withEvent*/ @event); /*const*/ double continuousPressTimeInterval = this.continuousPressTimeInterval; if (begins && continuousPressTimeInterval > 0f) { this._beginContinuousPressDelayed(); } return begins; }
internal void RemoveTouch(UITouch touch) { if(touchState.ContainsKey(touch.Handle)) touchState.Remove(touch.Handle); }
public override bool BeginTracking (UITouch uitouch, UIEvent uievent) { SetNeedsDisplay (); isPressed = true; return base.BeginTracking (uitouch, uievent); }
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 override void TouchesBegan (NSSet touches, UIEvent evt) { if (trackedTouch == null) { trackedTouch = (UITouch)touches.FirstOrDefault (); initialTimestamp = trackedTouch.Timestamp; if (!IsForPencil) BeginIfNeeded (null); fingerStartTimer = NSTimer.CreateScheduledTimer (cancellationTimeInterval, BeginIfNeeded); } if (Append (Touches(touches), evt)) { if (IsForPencil) State = Began; } }
void Collect (Stroke stroke, UITouch touch, UIView view, bool coalesced, bool predicted) { if (view == null) throw new ArgumentNullException (); // Only collect samples that actually moved in 2D space. var location = touch.GetPreciseLocation (view); var previousSample = stroke.Samples.LastOrDefault (); if (Distance (previousSample?.Location, location) < 0.003) return; var sample = new StrokeSample { Timestamp = touch.Timestamp, Location = location, Coalesced = coalesced, Predicted = predicted }; bool collectForce = touch.Type == UITouchType.Stylus || view.TraitCollection.ForceTouchCapability == UIForceTouchCapability.Available; if (collectForce) sample.Force = touch.Force; if (touch.Type == UITouchType.Stylus) { var estimatedProperties = touch.EstimatedProperties; sample.EstimatedProperties = estimatedProperties; sample.EstimatedPropertiesExpectingUpdates = touch.EstimatedPropertiesExpectingUpdates; sample.Altitude = touch.AltitudeAngle; sample.Azimuth = touch.GetAzimuthAngle (view); if (stroke.Samples.Count == 0 && estimatedProperties.HasFlag (UITouchProperties.Azimuth)) { stroke.ExpectsAltitudeAzimuthBackfill = true; } else if (stroke.ExpectsAltitudeAzimuthBackfill && !estimatedProperties.HasFlag (UITouchProperties.Azimuth)) { for (int index = 0; index < stroke.Samples.Count; index++) { var priorSample = stroke.Samples [index]; var updatedSample = priorSample; if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Altitude)) { updatedSample.EstimatedProperties &= ~UITouchProperties.Altitude; updatedSample.Altitude = sample.Altitude; } if (updatedSample.EstimatedProperties.HasFlag (UITouchProperties.Azimuth)) { updatedSample.EstimatedProperties &= ~UITouchProperties.Azimuth; updatedSample.Azimuth = sample.Azimuth; } stroke.Update (updatedSample, index); } stroke.ExpectsAltitudeAzimuthBackfill = false; } } if (predicted) { stroke.AddPredicted (sample); } else { var index = stroke.Add (sample); if (touch.EstimatedPropertiesExpectingUpdates != 0) { outstandingUpdateIndexes [touch.EstimationUpdateIndex] = new StrokeIndex { Stroke = stroke, Index = index }; } } }
public override bool BeginTracking(UITouch uitouch, UIEvent uievent) { return Wrap.Function("BeginTracking", delegate() { if (SelectedToken != null && uitouch.View == this) { this.DeselectSelectedToken(); } return base.BeginTracking(uitouch, uievent); }); }
public void endTrackingWithTouch( UITouch touch ,/*withEvent*/ UIEvent @event){ base.EndTracking(touch ,/*withEvent*/ @event); this._cancelContinousPressIfNeeded(); }
public override bool ContinueTracking(UITouch uitouch, UIEvent uievent) { var touch = uievent.AllTouches.AnyObject as UITouch; if (touch != null) pressed = Bounds.Contains(touch.LocationInView(this)); return base.ContinueTracking(uitouch, uievent); }
bool OnShouldReceiveTouch(UIGestureRecognizer recognizer, UITouch touch) { foreach (UIView v in ViewAndSuperviewsOfView(touch.View)) { if (v is UITableView || v is UITableViewCell || v.CanBecomeFirstResponder) return false; } return true; }
public override void Reset () { Stroke = new Stroke (); trackedTouch = null; var timer = fingerStartTimer; if (timer != null) { timer.Invalidate (); fingerStartTimer = null; } base.Reset (); }
internal void UpdateTouch(UITouch touch, object theObject) { if(touchState.ContainsKey(touch.Handle)) touchState[touch.Handle] = theObject; else touchState.Add(touch.Handle,theObject); }