public static void Execute(this EventHandler<View.TouchEventArgs> handler , object sender , MotionEvent e) { if (handler != null) { var args = new View.TouchEventArgs(true, e); handler(sender, args); } }
public virtual bool OnDoubleTap(MotionEvent e) { var args = new View.TouchEventArgs(false, e); var handler = this.DoubleTap; if (handler != null) { handler(this, args); } return args.Handled; }
//Open DatePicker And Get Short Date private void EdtBirthdayOnClick(object sender, View.TouchEventArgs e) { try { if (e.Event.Action != MotionEventActions.Down) { return; } var frag = DatePickerFragment.NewInstance(delegate(DateTime time) { EdtBirthday.Text = time.Date.ToString("dd-MM-yyyy"); }); frag.Show(SupportFragmentManager, DatePickerFragment.Tag); } catch (Exception exception) { Console.WriteLine(exception); } }
private void Sview_Touch(object sender, View.TouchEventArgs e) { var view = sender as View; for (int i = 0; i < e.Event.PointerCount; i++) { int id = e.Event.GetPointerId(i); double x = e.Event.GetX(); double y = e.Event.GetY(); x /= view.Width; y /= view.Height; x *= 1920; y *= 1080; BinaryWriter mwriter = new BinaryWriter(connection); byte opcode = 0; switch (e.Event.Action) { case MotionEventActions.Down: opcode = 1; break; case MotionEventActions.Up: opcode = 2; break; case MotionEventActions.Move: opcode = 3; break; } lock (connection) { mwriter.Write(opcode); mwriter.Write((int)x); mwriter.Write((int)y); mwriter.Write(id); } } lock (connection) { connection.Flush(); } }
//Interest private void EdtInterestOnClick(object sender, View.TouchEventArgs e) { try { TypeDialog = "Interest"; var dialog = new MaterialDialog.Builder(Context).Theme(AppSettings.SetTabDarkTheme ? Theme.Dark : Theme.Light); dialog.Title(GetString(Resource.String.Lbl_Interest)); dialog.Input(Resource.String.Lbl_EnterTextInterest, 0, false, this); dialog.InputType(InputTypes.TextFlagImeMultiLine); dialog.PositiveText(GetText(Resource.String.Lbl_Submit)).OnPositive(this); dialog.NegativeText(GetText(Resource.String.Lbl_Cancel)).OnNegative(this); dialog.AlwaysCallSingleChoiceCallback(); dialog.Build().Show(); } catch (Exception exception) { Console.WriteLine(exception); } }
private void SvOnTouch(object sender, View.TouchEventArgs touchEventArgs) { Camera.Parameters cameraParams = _camera.GetParameters(); var action = touchEventArgs.Event.Action; if (touchEventArgs.Event.PointerCount > 1) { if (action == MotionEventActions.PointerDown) { _dist = GetFingerSpacing(touchEventArgs.Event); } else if (action == MotionEventActions.Move && cameraParams.IsZoomSupported) { _camera.CancelAutoFocus(); HandleZoom(touchEventArgs.Event, cameraParams); } } touchEventArgs.Handled = true; }
private void OnTagLayoutOnClick(object sender, View.TouchEventArgs e) { switch (e.Event.Action) { case MotionEventActions.Down: case MotionEventActions.Move: _buttonState.SetImageResource(_type == TagType.Local ? Resource.Drawable.ic_close_tag_active : Resource.Drawable.ic_add_tag_active); break; case MotionEventActions.Up: _buttonState.SetImageResource(_type == TagType.Local ? Resource.Drawable.ic_close_tag : Resource.Drawable.ic_add_tag); _click?.Invoke(_text); break; default: _buttonState.SetImageResource(_type == TagType.Local ? Resource.Drawable.ic_close_tag : Resource.Drawable.ic_add_tag); break; } }
public void FeedTouchEvent(object sender, View.TouchEventArgs e, object userData) { mUserData = userData; mTapGestureDetector.Detected -= InternalOnTap; mLongGestureDetector.Detected -= InternalOnLongPress; mPanGestureDetector.Detected -= InternalOnPan; mPinchGestureDetector.Detected -= InternalOnPinch; if (e != null && (e.Touch.GetState(0) != PointStateType.Finished || e.Touch.GetState(0) != PointStateType.Up || e.Touch.GetState(0) != PointStateType.Interrupted)) { mTapGestureDetector.Detected += InternalOnTap; mLongGestureDetector.Detected += InternalOnLongPress; mPanGestureDetector.Detected += InternalOnPan; mPinchGestureDetector.Detected += InternalOnPinch; } }
void _contentView_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action != MotionEventActions.Down || !_dlgView.IsCanceledOnTouchOutside) { e.Handled = false; return; } Android.Graphics.Rect rect = new Android.Graphics.Rect(); _renderer.View.GetHitRect(rect); if (!rect.Contains((int)e.Event.GetX(), (int)e.Event.GetY())) { _dlgView.DialogNotifierInternal.Cancel(); return; } e.Handled = false; }
private bool LabelTouched(object sender, View.TouchEventArgs e) { if (e.Touch.GetState(0) == PointStateType.Down) { Animation textColorAnimation = new Animation(1000); if (_colorToggle) { textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Blue); _colorToggle = false; } else { textColorAnimation.AnimateTo(_pointLabel, "TextColorAnimatable", Color.Green); _colorToggle = true; } textColorAnimation.Play(); } return(true); }
private void OnCanvasTouch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { if (scoreButton.IntersectsWith(new SKRect(e.Event.GetX() - 5, e.Event.GetY() - 5, e.Event.GetX() + 5, e.Event.GetY() + 5))) { Intent scoreActivityIntent = new Intent(this, typeof(ScoreActivity)); scoreActivityIntent.SetFlags(ActivityFlags.SingleTop); StartActivity(scoreActivityIntent); } else { Intent gameActivityIntent = new Intent(this, typeof(GameActivity)); gameActivityIntent.SetFlags(ActivityFlags.SingleTop); gameActivityIntent.SetFlags(ActivityFlags.ClearTop); StartActivity(gameActivityIntent, ActivityOptions.MakeSceneTransitionAnimation(this).ToBundle()); } } }
private void callFree(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { var phoneCallTask = MessagingPlugin.PhoneDialer; if (phoneCallTask.CanMakePhoneCall) { phoneCallTask.MakePhoneCall("8052477919", "Roadrunner Support"); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this.Activity); alert.SetTitle("error"); alert.SetMessage("You can't email on emulator"); alert.SetPositiveButton("OK", (senderAlert, args) => { }); alert.Show(); } } }
private void sendEmail(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { var emailTask = MessagingPlugin.EmailMessenger; if (emailTask.CanSendEmail) { emailTask.SendEmail("*****@*****.**", "roadrunner support team", "this is email"); } else { AlertDialog.Builder alert = new AlertDialog.Builder(this.Activity); alert.SetTitle("error"); alert.SetMessage("You can't email on emulator"); alert.SetPositiveButton("OK", (senderAlert, args) => { }); alert.Show(); } } }
private void handleTouches(object sender, View.TouchEventArgs e) { var basicState = new Framework.Input.MouseState { Position = new Vector2(e.Event.GetX(), e.Event.GetY()) }; switch (e.Event.ActionMasked) { case MotionEventActions.Down: case MotionEventActions.Move: basicState.SetPressed(MouseButton.Left, true); PendingStates.Enqueue(new InputState { Mouse = basicState }); break; case MotionEventActions.Up: PendingStates.Enqueue(new InputState { Mouse = basicState }); break; } /* Multi-touch? * * var pointerIndex = e.Event.ActionIndex; * * var pointerId = e.Event.GetPointerId(pointerIndex); * * switch (e.Event.ActionMasked) * { * case MotionEventActions.Down: * case MotionEventActions.PointerDown: * * break; * case MotionEventActions.Up: * case MotionEventActions.PointerUp: * * break; * }*/ }
// function that executes when the tile is touched void TextTile_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { MyTextView thisTile = (MyTextView)sender; // just write the position of the tile in the Xamarin console, to see each tile when moves Console.WriteLine("\r tile is at: \r x={0} \r y={1}", thisTile.xPos, thisTile.yPos); // compute the distace between the tile which was pressed and the empty space float xDif = (float)Math.Pow(thisTile.xPos - emptySpot.X, 2); float yDif = (float)Math.Pow(thisTile.yPos - emptySpot.Y, 2); float dist = (float)Math.Sqrt(xDif + yDif); // if the tile was near the empty space if (dist == 1) { // memorize the current position of the tile Point curPoint = new Point(thisTile.xPos, thisTile.yPos); // we want to put the tile on the place of the empty space GridLayout.Spec rowSpec = GridLayout.InvokeSpec(emptySpot.Y); GridLayout.Spec colSpec = GridLayout.InvokeSpec(emptySpot.X); GridLayout.LayoutParams newLocParams = new GridLayout.LayoutParams(rowSpec, colSpec); // the tile moves in the empty space thisTile.xPos = emptySpot.X; thisTile.yPos = emptySpot.Y; // we set the appearance of the tile newLocParams.Width = tileWidth - 10; newLocParams.Height = tileWidth - 10; newLocParams.SetMargins(5, 5, 5, 5); thisTile.LayoutParameters = newLocParams; // the empty place goes where was the pressed tile before emptySpot = curPoint; } } }
void TextTile_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Up) { if (tilesArr.Contains(sender)) { MyTextView thisTile = (MyTextView)sender; Console.WriteLine("Tile Position X:{0} -- Y:{1}", thisTile.xPos, thisTile.yPos); Console.WriteLine("Empty Position X:{0} -- Y:{1}", emptySpot.X, emptySpot.Y); float xDif = (float)Math.Pow(thisTile.xPos - emptySpot.X, 2); float yDif = (float)Math.Pow(thisTile.yPos - emptySpot.Y, 2); float dist = (float)Math.Sqrt(xDif + yDif); if (dist == 1) // si es verdadero, puede mover { // memoriza donde estaba el tile Point curPoint = new Point(thisTile.xPos, thisTile.yPos); // mueve el tile al lugar vacio GridLayout.Spec rowSpec = GridLayout.InvokeSpec(emptySpot.Y); GridLayout.Spec colSpec = GridLayout.InvokeSpec(emptySpot.X); GridLayout.LayoutParams newLocParams = new GridLayout.LayoutParams(rowSpec, colSpec); thisTile.xPos = emptySpot.X; thisTile.yPos = emptySpot.Y; newLocParams.Width = tileWidth - 10; newLocParams.Height = tileWidth - 10; newLocParams.SetMargins(5, 5, 5, 5); thisTile.LayoutParameters = newLocParams; // el vacio se mueve donde estaba el tile que tocamos emptySpot = curPoint; } } } }
private async void RootViewOnTouch(object sender, View.TouchEventArgs touchEventArgs) { touchEventArgs.Handled = false; if (touchEventArgs.Event.Action == MotionEventActions.Up || touchEventArgs.Event.Action == MotionEventActions.Cancel) { await Task.Delay(200); //why? because fling... I should listen for when it ends but 200ms seem to do the job just fine /shrug if (_disableNestedScrollingOnTouchUp) { if (ProfilePageGeneralTabScrollingContainer.GetChildAt(0).Bottom > ProfilePageGeneralTabScrollingContainer.Height + ProfilePageGeneralTabScrollingContainer.ScrollY) { ProfilePageGeneralTabCommentsList.NestedScrollingEnabled = false; } _disableNestedScrollingOnTouchUp = false; } } }
private void ListenerTouchIV(object sender, View.TouchEventArgs e) { var view = (ImageView)sender; if (e.Event.Action == MotionEventActions.Down) { view.Background.SetColorFilter(0x30000000); } else if (e.Event.Action == MotionEventActions.Up) { view.Background.SetColorFilter(0x00000000); } else if (e.Event.Action == MotionEventActions.Cancel) { view.Background.SetColorFilter(0x00000000); view.Invalidate(); } e.Handled = false; }
protected override void View_TouchInvoke(object sender, View.TouchEventArgs e) { base.View_TouchInvoke(sender, e); if (Scrolled) { if (e.Event.Action == MotionEventActions.Up || e.Event.Action == MotionEventActions.Cancel) { float?offset = Behavour.HandleSwipe(_view.ScrollY, _startY); if (offset != null) { Scroll(offset.Value); Scrolled = false; ScrollPerGesture = 0; e.Handled = true; } } } }
private void EditTextTouchUp(object sender, View.TouchEventArgs e) { // if (MotionEventActions.Up == e.Event.Action ) { disallow text edit ? switch (e.Event.Action & MotionEventActions.Mask) { case MotionEventActions.Up: if (TransDetAdapter.lastFocusedControl != null) { TransDetAdapter.lastFocusedControl.SetBackgroundResource(Resource.Drawable.my_edit_text_background_normal); } TransDetAdapter.lastFocusedControl = (EditText)sender; TransDetAdapter.lastFocusedControl.SetBackgroundResource(Resource.Drawable.my_edit_text_background_focused); TransDetAdapter.lastFocusedControl.RequestFocus(); EditText yourEditText = (EditText)sender; Android.Views.InputMethods.InputMethodManager imm = (Android.Views.InputMethods.InputMethodManager)context.GetSystemService(Android.Content.Context.InputMethodService); imm.ShowSoftInput(yourEditText, Android.Views.InputMethods.ShowFlags.Implicit); break; } }
private void OnListTouch(object sender, View.TouchEventArgs e) { switch (e.Event.Action) { case MotionEventActions.Down: // Disable SnappyList intercepting list view scroll events listView.Parent.RequestDisallowInterceptTouchEvent(true); // Enable view pager to intercept swiping gesture snappyLayout.Parent.RequestDisallowInterceptTouchEvent(false); break; case MotionEventActions.Up: case MotionEventActions.Cancel: listView.Parent.RequestDisallowInterceptTouchEvent(false); break; } // Run the usual touch logic for ListView e.Handled = listView.OnTouchEvent(e.Event); }
public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e) { if (e == null) { return(false); } if (e.Touch.GetState(0) == PointStateType.Up) { ClearWindowGesture(); if (BorderWindow.IsMaximized()) { BorderWindow.Maximize(false); } else { BorderWindow.Maximize(true); } } return(true); }
private void View1_Touch(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { _singlePointerEvent = true; } if (!_gestureLock && e.Event.Action == MotionEventActions.Move) { var coordinates = new List <TouchObject>(); foreach (var i in Enumerable.Range(0, e.Event.PointerCount)) { coordinates.Add(new TouchObject(e.Event.GetX(i), e.Event.GetY(i), _engine.ValuePerClick.ToString(ValueFormat.Scientific))); _engine.Click(); } DrawableView view1 = FindViewById <DrawableView>(Resource.Id.drawable_view1); view1.AddClickCoordinates(coordinates); view1.Invalidate(); _singlePointerEvent = false; _gestureLock = true; } if (e.Event.Action == MotionEventActions.Up) { if (_singlePointerEvent) { var coordinates = new List <TouchObject>(); coordinates.Add(new TouchObject(e.Event.GetX(), e.Event.GetY(), _engine.ValuePerClick.ToString(ValueFormat.Scientific))); _engine.Click(); DrawableView view1 = FindViewById <DrawableView>(Resource.Id.drawable_view1); view1.AddClickCoordinates(coordinates); view1.Invalidate(); } //The last finger has left the screen so we are ready to process a new Move action. _gestureLock = false; } }
private void RecyclerViewTouchHandler(object sender, View.TouchEventArgs e) { e.Handled = false; var motionEvent = e.Event; if (_swipedPosition < 0) { return; } var swipedViewHolder = _recyclerViewRef.Target.FindViewHolderForAdapterPosition(_swipedPosition); if (swipedViewHolder == null) { return; } var swipedItem = swipedViewHolder.ItemView; var rect = new Rect(); swipedItem.GetGlobalVisibleRect(rect); if (motionEvent.Action == MotionEventActions.Down || motionEvent.Action == MotionEventActions.Up || motionEvent.Action == MotionEventActions.Move) { var point = new Point((int)motionEvent.RawX, (int)motionEvent.RawY); if (rect.Top < point.Y && rect.Bottom > point.Y) { _gestureDetector.OnTouchEvent(motionEvent); } else { _recoverQueue.Enqueue(_swipedPosition); _swipedPosition = -1; RecoverSwipedItem(); } } }
private void TxtStartDateOnTouch(object sender, View.TouchEventArgs e) { try { if (e?.Event?.Action != MotionEventActions.Down) { return; } var frag = DatePickerFragment.NewInstance(delegate(DateTime time) { TxtStartDate.Text = time.Date.ToString("yyyy-MM-dd"); }); frag.Show(SupportFragmentManager, DatePickerFragment.Tag); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void OnTouchCropView(object sender, View.TouchEventArgs e) { e.Handled = true; if (e.Event.PointerCount <= 1 && cropView.ImageBitmap != null) { switch (e.Event.ActionMasked) { case MotionEventActions.Down: case MotionEventActions.Move: cropButton.Visibility = ViewStates.Invisible; pickMiniButton.Visibility = ViewStates.Invisible; break; default: cropButton.Visibility = ViewStates.Visible; pickMiniButton.Visibility = ViewStates.Visible; break; } } }
/// <summary> /// Method which is called when the view is touched /// </summary> /// <param name="sender">View instance</param> /// <param name="e">Event arguments</param> private bool OnViewTouch(object sender, View.TouchEventArgs e) { View TouchedView = sender as View; if (e.Touch.GetState(0) == PointStateType.Down) { if (ViewTouched) { // If the view is in ViewTouched state, change the BackgroundColor TouchedView.BackgroundColor = new Color(0.8f, 0.2f, 0.1f, 1.0f); ViewTouched = false; } else { // Otherwise, change back the BackgroundColor TouchedView.BackgroundColor = new Color(0.26f, 0.85f, 0.95f, 1.0f); ViewTouched = true; } } return(true); }
private void TouchMeImageViewOnTouch(object sender, View.TouchEventArgs touchEventArgs) { string message; if (elapTime.ElapsedMilliseconds < sleepTime * 1000) { elapTime.Reset(); _player.Start(); } switch (touchEventArgs.Event.Action & MotionEventActions.Mask) { //Happens one time case MotionEventActions.Down: message = "Program running"; timer = timer + 1; break; //Happens many times case MotionEventActions.Move: // Handle both the Down and Move actions. message = "Program running"; timer = timer + 1; break; //Happens one time case MotionEventActions.Up: elapTime.Start(); message = "Wake up in!" + (elapTime.ElapsedMilliseconds); //milliseconds timer = 0; break; //Never default: message = "default"; break; } _touchInfoTextView.Text = message; _touchTimerTextView.Text = timer.ToString(); }
protected override void View_TouchingInvoke(object sender, View.TouchEventArgs e) { Screen scr = CurrentContext.CurrentNativeScreen; if (Scrollable && !scr.GestureHoldedExcept(this)) { switch (e.Event.Action) { case MotionEventActions.Down: _startY = _view.ScrollY; _lastY = e.Event.GetY(); ScrollPerGesture = 0; break; case MotionEventActions.Move: float y = e.Event.GetY(); float delta = _lastY - y; if (Math.Abs(delta) > 0.001) { ScrollPerGesture += delta; delta = CutBorders(delta, _view.ScrollY); if (Math.Abs(ScrollPerGesture) >= TouchSlop) { Scrolled = scr.TryHoldGesture(this); } if (Scrolled) { _view.ScrollBy(0, (int)delta); } _lastY = y; } break; } } }
private void TxtSubCategoriesOnTouch(object sender, View.TouchEventArgs e) { try { if (e?.Event?.Action != MotionEventActions.Down) { return; } if (CategoriesController.ListCategoriesGroup.Count > 0) { TypeDialog = "SubCategories"; var dialogList = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light); var arrayAdapter = new List <string>(); var subCat = CategoriesController.ListCategoriesGroup.FirstOrDefault(a => a.CategoriesId == CategoryId)?.SubList; if (subCat?.Count > 0) { arrayAdapter = subCat.Select(item => item.Lang).ToList(); } dialogList.Title(GetText(Resource.String.Lbl_SelectCategories)); dialogList.Items(arrayAdapter); dialogList.NegativeText(GetText(Resource.String.Lbl_Close)).OnNegative(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); } else { Methods.DisplayReportResult(this, "Not have List Categories Group"); } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
private void Btn_Center_Touch(object sender, View.TouchEventArgs e) { var _view = (Button)sender; if (e.Event.Action == MotionEventActions.Down) { _view.Background.SetColorFilter(0x10000000); _view.Invalidate(); } else if (e.Event.Action == MotionEventActions.Up) { _view.Background.SetColorFilter(0x00000000); _view.Invalidate(); } else if (e.Event.Action == MotionEventActions.Cancel) { _view.Background.SetColorFilter(0x00000000); _view.Invalidate(); } e.Handled = false; }
private void TxtCurrencyOnTouch(object sender, View.TouchEventArgs e) { try { if (e?.Event?.Action != MotionEventActions.Down) { return; } if (ListUtils.SettingsSiteList?.CurrencySymbolArray.CurrencyList != null) { TypeDialog = "Currency"; var arrayAdapter = WoWonderTools.GetCurrencySymbolList(); switch (arrayAdapter?.Count) { case > 0: { var dialogList = new MaterialDialog.Builder(this).Theme(AppSettings.SetTabDarkTheme ? AFollestad.MaterialDialogs.Theme.Dark : AFollestad.MaterialDialogs.Theme.Light); dialogList.Title(GetText(Resource.String.Lbl_SelectCurrency)).TitleColorRes(Resource.Color.primary); dialogList.Items(arrayAdapter); dialogList.NegativeText(GetText(Resource.String.Lbl_Close)).OnNegative(this); dialogList.AlwaysCallSingleChoiceCallback(); dialogList.ItemsCallback(this).Build().Show(); break; } } } else { Methods.DisplayReportResult(this, "Not have List Currency"); } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
public virtual bool OnSingleTapConfirmed(MotionEvent e) { var args = new View.TouchEventArgs(false, e); var handler = this.SingleTapConfirmed; if (handler != null) { handler(this, args); } return args.Handled; }
public virtual void OnShowPress(MotionEvent e) { var args = new View.TouchEventArgs(false, e); var handler = this.ShowPress; if (handler != null) { handler(this, args); } }