public bool OnDoubleTap(Android.Views.MotionEvent ev) { if (photoViewAttacher == null) { return(false); } try { float scale = photoViewAttacher.GetScale(); float x = ev.GetX(); float y = ev.GetY(); if (scale > photoViewAttacher.GetMinimumScale()) { photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true); } else { photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true); } /* * if (scale < photoViewAttacher.GetMediumScale()) { * photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true); * } else if (scale >= photoViewAttacher.GetMediumScale() && scale < photoViewAttacher.GetMaximumScale()) { * photoViewAttacher.SetScale(photoViewAttacher.GetMaximumScale(), x, y, true); * } else { * photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true); * }*/ } catch (Java.Lang.ArrayIndexOutOfBoundsException e) { // Can sometimes happen when getX() and getY() is called } return(true); }
public bool OnDoubleTap(Android.Views.MotionEvent e) { if (_attacher == null) { return(false); } try { float scale = _attacher.GetScale(); float x = e.GetX(); float y = e.GetY(); if (scale < _attacher.GetMediumScale()) { _attacher.SetScale(_attacher.GetMediumScale(), x, y, true); } else if (scale >= _attacher.GetMediumScale() && scale < _attacher.GetMaximumScale()) { _attacher.SetScale(_attacher.GetMaximumScale(), x, y, true); } else { _attacher.SetScale(_attacher.GetMinimumScale(), x, y, true); } } catch (Java.Lang.ArrayIndexOutOfBoundsException ex) { // Can sometimes happen when getX() and getY() is called } return(true); }
public override bool DispatchTouchEvent(Android.Views.MotionEvent e) { if (e.ActionMasked == Android.Views.MotionEventActions.Down) { //Record the position the list the touch landed on _mPosition = this.Control.PointToPosition((int)e.GetX(), (int)e.GetY()); } if (e.ActionMasked == Android.Views.MotionEventActions.Move) { //Ignore move events return(true); } if (e.ActionMasked == Android.Views.MotionEventActions.Up) { //Check if we are still within the same view if (this.Control.PointToPosition((int)e.GetX(), (int)e.GetY()) == _mPosition) { base.DispatchTouchEvent(e); } else { //Clear pressed state, cancel action Pressed = false; Invalidate(); return(true); } } return(base.DispatchTouchEvent(e)); }
private void AndroidMap_MapSingleTap(object sender, Android.Views.MotionEvent e) { PointF location = new PointF(e.GetX(), e.GetY()); PointShape position = ExtentHelper.ToWorldCoordinate(androidMap.CurrentExtent, location.X, location.Y, androidMap.Width, androidMap.Height); LayerOverlay worldOverlay = (LayerOverlay)androidMap.Overlays["WorldOverlay"]; LayerOverlay highlightOverlay = (LayerOverlay)androidMap.Overlays["HighlightOverlay"]; FeatureLayer worldLayer = (FeatureLayer)worldOverlay.Layers["WorldLayer"]; InMemoryFeatureLayer highlightLayer = (InMemoryFeatureLayer)highlightOverlay.Layers["HighlightLayer"]; worldLayer.Open(); Collection <Feature> selectedFeatures = worldLayer.QueryTools.GetFeaturesContaining(position, new string[1] { "CNTRY_NAME" }); worldLayer.Close(); highlightLayer.Open(); highlightLayer.InternalFeatures.Clear(); if (selectedFeatures.Count > 0) { highlightLayer.InternalFeatures.Add(selectedFeatures[0]); } highlightLayer.Close(); highlightOverlay.Refresh(); }
public bool OnSingleTapConfirmed(Android.Views.MotionEvent e) { if (this.photoViewAttacher == null) { return(false); } ImageView imageView = photoViewAttacher.GetImageView(); if (null != photoViewAttacher.GetOnPhotoTapListener()) { RectF displayRect = photoViewAttacher.GetDisplayRect(); if (null != displayRect) { float x = e.GetX(), y = e.GetY(); if (displayRect.Contains(x, y)) { float xResult = (x - displayRect.Left) / displayRect.Width(); float yResult = (y - displayRect.Top) / displayRect.Height(); photoViewAttacher.GetOnPhotoTapListener().OnPhotoTap(imageView, xResult, yResult); return(true); } } } if (null != photoViewAttacher.GetOnViewTapListener()) { photoViewAttacher.GetOnViewTapListener().OnViewTap(imageView, e.GetX(), e.GetY()); } return(false); }
public static TouchData FromAndroid(Android.Views.MotionEvent e) { TouchData t = new TouchData(); switch (e.Action) { case Android.Views.MotionEventActions.Up: t.state = TouchState.Up; break; case Android.Views.MotionEventActions.Down: t.state = TouchState.Down; break; case Android.Views.MotionEventActions.Move: t.state = TouchState.Move; break; default: break; } t.x = e.GetX(); t.y = e.GetY(); return(t); }
public override bool OnTouchEvent(Android.Views.MotionEvent motionEvent) { var toReturn = base.OnTouchEvent(motionEvent); NotifyTouchState(); return(toReturn); }
public override bool DispatchTouchEvent(Android.Views.MotionEvent e) { if (e.Action == Android.Views.MotionEventActions.Move && !((ExtendedListView)Element).IsScrollable) { return(true); } return(base.DispatchTouchEvent(e)); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { if (this.enabled) { return(base.OnInterceptTouchEvent(ev)); } return(false); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { if (!Enabled || Element?.IsEnabled == false) { return(true); } return(base.OnInterceptTouchEvent(ev)); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { try { return(base.OnInterceptTouchEvent(ev)); } catch (Exception ex) { Log.Error("FixedDrawerLayout", $"Exception: {ex.Message}"); return(false); } }
public override bool OnTouchEvent(MotionEvent e) { var touchX = e.GetX(); var touchY = e.GetY(); PathMeasure pm = new PathMeasure(DrawPath, false); //coordinates will be here float[] PrevCoords = { 0f, 0f }; //get coordinates of the middle point pm.GetPosTan(pm.Length, PrevCoords, null); switch (e.Action) { case MotionEventActions.Down: DrawPath.MoveTo(touchX, touchY); PointerDown = true; try { Invalidate(); } catch (ObjectDisposedException) { return(false); } PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Down, new Point(PrevCoords[0], PrevCoords[1]), new Point(touchX, touchY), PointerDown)); break; case MotionEventActions.Move: DrawPath.LineTo(touchX, touchY); try { Invalidate(); } catch (ObjectDisposedException) { return(false); } PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Move, new Point(PrevCoords[0], PrevCoords[1]), new Point(touchX, touchY), PointerDown)); break; case MotionEventActions.Up: DrawCanvas.DrawPath(DrawPath, DrawPaint); DrawPath.Reset(); PointerDown = false; try { Invalidate(); } catch (ObjectDisposedException) { return(false); } PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Up, new Point(PrevCoords[0], PrevCoords[1]), new Point(touchX, touchY), PointerDown)); break; case MotionEventActions.Cancel: DrawCanvas.DrawPath(DrawPath, DrawPaint); DrawPath.Reset(); PointerDown = false; try { Invalidate(); } catch (ObjectDisposedException) { return(false); } PointerEvent?.Invoke(this, new PointerEventArgs(PointerEventArgs. PointerEventType.Cancel, new Point(PrevCoords[0], PrevCoords[1]), new Point(touchX, touchY), PointerDown)); break; default: return(false); } return(true); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { if (isEnabled) { if (e.Action == Android.Views.MotionEventActions.Up) { Toggle(); } } return(base.OnTouchEvent(e)); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { if (this.Element is CustomPageView) { var view = this.Control; TouchData data = TouchData.FromAndroid(e); CustomPageView custom = (CustomPageView)this.Element; custom.OnTouch(data); } return(true); }
public static bool IsComplete(this MotionEvent e) { switch (e.Action) { case MotionEventActions.Cancel: case MotionEventActions.Outside: case MotionEventActions.PointerUp: case MotionEventActions.Up: return(true); default: return(false); } }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { if (e.Action == Android.Views.MotionEventActions.Up) { IsChecked = !IsChecked; customSwitch.UpdateBoxPosition(IsChecked); if (Change != null) { Change(this, EventArgs.Empty); } } return(true); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { if (e.Action == Android.Views.MotionEventActions.Down) { Alpha = 0.6f; } else if (e.Action == Android.Views.MotionEventActions.Up) { Alpha = 1.0f; } else if (e.Action == Android.Views.MotionEventActions.Cancel) { Alpha = 1.0f; } return(base.OnTouchEvent(e)); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { double x = (e.GetX() * LayoutElement.Width) / this.Width; double y = (e.GetY() * LayoutElement.Height) / this.Height; switch (e.Action) { case Android.Views.MotionEventActions.Down: HandleTouchStart(x, y); startX = x; startY = y; break; case Android.Views.MotionEventActions.Move: if (LayoutElement.Dragging) { LayoutElement.HandleTouch(x, y); } break; case Android.Views.MotionEventActions.Up: if (currentDraggable != null && ((currentDraggable.Status == DragState.None || currentDraggable.Status == DragState.Started) || BelowTapThreshold(x, y))) { if (currentDraggable.TapEnabled) { currentDraggable.OnTapped(); } currentDraggable = null; } if (LayoutElement.Dragging) { MessagingCenter.Send <DragAndDropLayoutRenderer, bool>(this, "IsDragging", false); LayoutElement.StopDragging(); LayoutElement.Dragging = false; currentDraggable = null; } break; default: break; } return(true); }
public bool OnTouch(AView v, AMotionEvent e) { var renderer = v.Tag as ButtonRenderer; if (renderer != null) { var buttonController = renderer.Element as IButtonController; if (e.Action == AMotionEventActions.Down) { Device.BeginInvokeOnMainThread(() => buttonController?.SendPressed()); } else if (e.Action == AMotionEventActions.Up) { Device.BeginInvokeOnMainThread(() => buttonController?.SendReleased()); } } return(false); }
public bool OnTouch(AView v, AMotionEvent e) { var renderer = v.Tag as ContentButtonViewRenderer; if (renderer != null) { var buttonController = renderer.Element as IButtonController; if (e.Action == AMotionEventActions.Down) { buttonController?.SendPressed(); } else if (e.Action == AMotionEventActions.Up) { buttonController?.SendReleased(); } } return(false); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { if (!LayoutElement.GestureEnabled) { return(false); } double x = (ev.GetX() * LayoutElement.Width) / this.Width; double y = (ev.GetY() * LayoutElement.Height) / this.Height; IDrag draggable; if (LayoutElement.IDragTouched(x, y, out draggable)) { currentDraggable = draggable; return(true); } return(false); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { int action = MotionEventCompat.GetActionMasked(e); switch (action) { case (int)Android.Views.MotionEventActions.Down: { _lastPoint = new Point(e.RawX, e.RawY); break; } case (int)Android.Views.MotionEventActions.Move: { Element.UpdateGrid(Context.FromPixels(e.RawX - _lastPoint.X), Context.FromPixels(e.RawY - _lastPoint.Y)); _lastPoint = new Point(e.RawX, e.RawY); break; } } return(base.OnTouchEvent(e)); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public override bool OnHandleMotionEvent(MotionEvent pMotionEvent) { //return this.fireTouchEvent(pMotionEvent.getX(), pMotionEvent.getY(), pMotionEvent.getAction(), 0, pMotionEvent); return(this.FireTouchEvent(pMotionEvent.GetX(), pMotionEvent.GetY(), pMotionEvent.Action, 0, pMotionEvent)); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { return(!DisableSwipePaging && base.OnInterceptTouchEvent(ev)); }
public override bool DispatchTouchEvent(Android.Views.MotionEvent ev) { LongPressDetector.OnTouchEvent(ev); return(base.DispatchTouchEvent(ev)); }
public void ProcessTouchEvent(Android.Views.MotionEvent e) { try { switch(e.ActionMasked) { case Android.Views.MotionEventActions.Down: case Android.Views.MotionEventActions.PointerDown: { var ptProp = mPointerPropPool.QueryObjectSync(); e.GetPointerProperties(e.ActionIndex, ptProp); if(ptProp.Id >= Input.InputServer.MaxMultiTouchNumber) { mPointerPropPool.ReleaseObject(ptProp); return; } mStartX[ptProp.Id] = e.GetX(e.ActionIndex); mStartY[ptProp.Id] = e.GetY(e.ActionIndex); var touch = mTouchArgs[ptProp.Id]; if(touch == null) { touch = new EngineNS.Input.Device.TouchDevice.TouchInputEventArgs(); mTouchArgs[ptProp.Id] = touch; } touch.TouchEvent.State = Input.Device.TouchDevice.enTouchState.Down; touch.TouchEvent.PosX = mStartX[ptProp.Id]; touch.TouchEvent.PosY = mStartY[ptProp.Id]; touch.TouchEvent.FingerIdx = ptProp.Id; touch.TouchEvent.ToolType = (EngineNS.Input.Device.TouchDevice.enToolType)e.GetToolType(e.ActionIndex); EngineNS.CEngine.Instance.InputServerInstance.OnInputEvnet(touch); mPointerPropPool.ReleaseObject(ptProp); } break; case Android.Views.MotionEventActions.Up: case Android.Views.MotionEventActions.PointerUp: { var ptProp = mPointerPropPool.QueryObjectSync(); e.GetPointerProperties(e.ActionIndex, ptProp); if(ptProp.Id >= Input.InputServer.MaxMultiTouchNumber) { mPointerPropPool.ReleaseObject(ptProp); return; } mStartX[ptProp.Id] = e.GetX(e.ActionIndex); mStartY[ptProp.Id] = e.GetY(e.ActionIndex); var touch = mTouchArgs[ptProp.Id]; if (touch == null) { touch = new EngineNS.Input.Device.TouchDevice.TouchInputEventArgs(); mTouchArgs[ptProp.Id] = touch; } touch.TouchEvent.State = Input.Device.TouchDevice.enTouchState.Up; touch.TouchEvent.PosX = mStartX[ptProp.Id]; touch.TouchEvent.PosY = mStartY[ptProp.Id]; touch.TouchEvent.FingerIdx = ptProp.Id; touch.TouchEvent.ToolType = (EngineNS.Input.Device.TouchDevice.enToolType)e.GetToolType(e.ActionIndex); EngineNS.CEngine.Instance.InputServerInstance.OnInputEvnet(touch); mPointerPropPool.ReleaseObject(ptProp); } break; case Android.Views.MotionEventActions.Move: { var ptProp = mPointerPropPool.QueryObjectSync(); for(int acindex = 0; acindex < e.PointerCount; acindex++) { e.GetPointerProperties(acindex, ptProp); if (ptProp.Id >= Input.InputServer.MaxMultiTouchNumber) continue; float x = e.GetX(acindex); float y = e.GetY(acindex); var deltaX = x - mStartX[ptProp.Id]; var deltaY = y - mStartY[ptProp.Id]; mStartX[ptProp.Id] = x; mStartY[ptProp.Id] = y; // 去除微小抖动 if (System.Math.Abs(deltaX) < 0.5f && System.Math.Abs(deltaY) < 0.5f) continue; var touch = mTouchArgs[ptProp.Id]; if (touch == null) { touch = new EngineNS.Input.Device.TouchDevice.TouchInputEventArgs(); mTouchArgs[ptProp.Id] = touch; } touch.TouchEvent.State = Input.Device.TouchDevice.enTouchState.Move; touch.TouchEvent.PosX = x; touch.TouchEvent.PosY = y; touch.TouchEvent.DeltaX = deltaX; touch.TouchEvent.DeltaY = deltaY; touch.TouchEvent.FingerIdx = ptProp.Id; touch.TouchEvent.ToolType = (EngineNS.Input.Device.TouchDevice.enToolType)e.GetToolType(acindex); EngineNS.CEngine.Instance.InputServerInstance.OnInputEvnet(touch); } mPointerPropPool.ReleaseObject(ptProp); } break; } } catch(System.Exception) { } }
public bool OnDoubleTapEvent(Android.Views.MotionEvent e) { return(false); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== public override bool OnHandleMotionEvent(MotionEvent pMotionEvent) { //return this.fireTouchEvent(pMotionEvent.getX(), pMotionEvent.getY(), pMotionEvent.getAction(), 0, pMotionEvent); return this.FireTouchEvent(pMotionEvent.GetX(), pMotionEvent.GetY(), pMotionEvent.Action, 0, pMotionEvent); }
protected bool FireTouchEvent(float pX, float pY, /* int pAction */ Android.Views.MotionEventActions pAction, int pPointerID, MotionEvent pMotionEvent) { bool handled; if (this.mRunOnUpdateThread) { TouchEvent touchEvent = TouchEvent.Obtain(pX, pY, pAction, pPointerID, MotionEvent.Obtain(pMotionEvent)); TouchEventRunnablePoolItem touchEventRunnablePoolItem = this.mTouchEventRunnablePoolUpdateHandler.ObtainPoolItem(); touchEventRunnablePoolItem.Set(touchEvent); this.mTouchEventRunnablePoolUpdateHandler.PostPoolItem(touchEventRunnablePoolItem); handled = true; } else { TouchEvent touchEvent = TouchEvent.Obtain(pX, pY, pAction, pPointerID, pMotionEvent); handled = this.mTouchEventCallback.OnTouchEvent(touchEvent); touchEvent.Recycle(); } return(handled); }
public override bool OnInterceptTouchEvent(Android.Views.MotionEvent ev) { return(false); }
public override bool OnTouchEvent(Android.Views.MotionEvent e) { return(false); }