Exemplo n.º 1
0
        private double distanceBetweenFingers(TouchActionEventArgs args)
        {
            double disX = Math.Abs(args.Location[0].X - args.Location[1].X);
            double disY = Math.Abs(args.Location[0].Y - args.Location[1].Y);

            return(Math.Sqrt(disX * disX + disY * disY));
        }
Exemplo n.º 2
0
 private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
 {
     if (_level.StateLevel == StateLevel.Finished)
     {
         Application.Current.MainPage = new MainPage();
     }
 }
Exemplo n.º 3
0
        /*
         * Event touch su schermo con relativi casi per la bounding box
         */
        private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            switch (args.Type)
            {
            case TouchActionType.Pressed:
                foreach (RectangleArea rectangleArea in allRectangleArea)
                {
                    if (rectangleArea.CheckIfInAnyRectangle(UtilityFunctions.ConvertToPixel(args.Location, canvasBitMap)) && !allTouchEffect.Contains(args.Id))
                    {
                        allTouchEffect.Add(args.Id);
                        if (removeRectangleState)
                        {
                            allRectangleArea.Remove(rectangleArea);
                            break;
                        }
                        else
                        {
                            rectangleArea.RectangleSelected = true;
                        }
                    }
                }
                if (removeRectangleState)
                {
                    canvasBitMap.InvalidateSurface();
                }
                break;

            case TouchActionType.Moved:
                foreach (RectangleArea rectangleArea in allRectangleArea)
                {
                    if (allTouchEffect.Contains(args.Id) && rectangleArea.RectangleSelected)
                    {
                        rectangleArea.ResizeInfo = CheckIfResize(args.Location, rectangleArea);
                        if (rectangleArea.ResizeInfo != ResizeInfo.none)
                        {
                            ResizeRect(rectangleArea.PixelCoordinateDetected, rectangleArea.ResizeInfo, rectangleArea);
                        }
                        else if (rectangleArea.CheckIfInAnyRectangle(UtilityFunctions.ConvertToPixel(args.Location, canvasBitMap)))
                        {
                            RectangleMoveArea(args.Location, rectangleArea);
                        }
                    }
                }
                break;

            case TouchActionType.Released:
                if (allTouchEffect.Contains(args.Id))
                {
                    foreach (RectangleArea rectangleArea in allRectangleArea)
                    {
                        if (rectangleArea.RectangleSelected)
                        {
                            rectangleArea.RectangleSelected = false;
                        }
                    }
                    allTouchEffect.Remove(args.Id);
                }
                break;
            }
        }
Exemplo n.º 4
0
 void OnTouch(object sender, TouchActionEventArgs args)
 {
     if (args.Type == TouchActionType.Pressed && BindingContext is FlagSemaphoreVM vm)
     {
         vm.SetAngle(Math.Atan2(args.Location.Y - canvas.Height / 2, args.Location.X - canvas.Width / 2));
     }
 }
Exemplo n.º 5
0
        //--------------------------------------INTERACTIVITY-------------------------------------------------------------------------------------------
        private void OnTouchEffectAction(object sender, TouchActionEventArgs e)
        {
            /*
             * This code triggers when the user clicks on the petContainer, which spans the entire screen
             * 1. Detect X and Y coordinates
             * 2. Update the pet upon those coordinates
             * 3. Restart Timer
             *
             *
             * NAME: PLUGIN.CURRENTACTIVITY
             * PURPOSE: To allow for fingerprint plugin to work for android
             * DATE: 2/10/19
             * SOURCE OF CODE AND ASSISTANCE: https://github.com/jamesmontemagno/CurrentActivityPlugin
             * AUTHOR: James Montemagno
             * DESCRIPTION OF ASSISTANCE: Included in the same code tutorial as PLUGIN.FINGERPRINT to read and authenticate fingerprint
             *
             */
            PetTimer.Stop();
            PetTimer.Interval = 5 * 1000; // 5 SECONDS
            PetTimer.Start();
            New_Position_X = (int)e.Location.X;
            New_Position_Y = (int)e.Location.Y;
            MoveToPosition();

            //when user touches the screen make a sound effect
        }
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            switch (args.Type)
            {
            case TouchActionType.Pressed:
                if (!isBeingDragged)
                {
                    isBeingDragged = true;
                    touchId        = args.Id;
                    pressPoint     = args.Location;
                }
                break;

            case TouchActionType.Moved:
                if (isBeingDragged && touchId == args.Id)
                {
                    TranslationX += args.Location.X - pressPoint.X;
                    TranslationY += args.Location.Y - pressPoint.Y;
                }
                break;

            case TouchActionType.Released:
                if (isBeingDragged && touchId == args.Id)
                {
                    isBeingDragged = false;
                }
                break;
            }
        }
Exemplo n.º 7
0
        private void TouchEffect_TouchAction(object sender, TouchActionEventArgs e)
        {
            lock (touchEffect_lock)
            {
                switch (e.Type)
                {
                case TouchActionType.Pressed:
                    this.Scale     = 0.98;
                    this.HasShadow = false;
                    break;

                case TouchActionType.Exited:
                case TouchActionType.Cancelled:
                    this.Scale     = 1;
                    this.HasShadow = true;
                    break;

                case TouchActionType.Released:
                    if (this.Scale != 1)
                    {
                        this.TabCommand?.Execute(null);
                        this.Scale     = 1;
                        this.HasShadow = true;
                    }
                    break;
                }
            }
        }
Exemplo n.º 8
0
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            switch (args.Type)
            {
            case TouchActionType.Pressed:
                if (!inProgressCircles.ContainsKey(args.Id))
                {
                    inProgressCircles.Add(args.Id, ConvertToPixel(args.Location));
                    //DisplayAlert(null, "x: " + ConvertToPixel(args.Location).X + "  y: " + ConvertToPixel(args.Location).Y, "cancel");

                    canvasView.InvalidateSurface();
                }
                break;

            case TouchActionType.Moved:
                break;

            case TouchActionType.Released:

                if (inProgressCircles.ContainsKey(args.Id))
                {
                    completedCircles.Add(inProgressCircles[args.Id]);
                    canvasView.InvalidateSurface();
                }
                break;

            case TouchActionType.Cancelled:
                break;
            }
        }
        /// <summary>
        ///     Events sent from the TouchEffect attached to the SkiaSharp Canvas (detects drag)
        /// </summary>
        /// <param name="args">Arguments.</param>
        void Handle_TouchAction(object sender, TouchActionEventArgs args)
        {
            //First touch, just mark the location
            if (args.Type == TouchActionType.Pressed)
            {
                _previousTouchPoint = args.Location;
                return;
            }

            //User is dragging/moving the chart
            if (args.Type == TouchActionType.Moved)
            {
                //Calculate Deltas in the drag
                var _touchYDelta = (float)Math.Round((_previousTouchPoint.Y - args.Location.Y) * 2, 0);
                var _touchXDelta = (float)Math.Round((_previousTouchPoint.X - args.Location.X) * 2, 0);

                //Re-Draw the Chart
                if (_touchYDelta >= 1 || _touchYDelta <= -1 || _touchXDelta >= 1 || _touchXDelta <= 1)
                {
                    _YDelta            -= _touchYDelta;
                    _XDelta            -= _touchXDelta;
                    _previousTouchPoint = args.Location;
                }
            }
            canvasChart.InvalidateSurface();
        }
        private void ImageControls_TouchAction(object sender, TouchActionEventArgs args)
        {
            // https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/graphics/skiasharp/transforms/touch

            var point = new SKPoint((float)(CanvasView.CanvasSize.Width * args.Location.X / CanvasView.Width),
                                    (float)(CanvasView.CanvasSize.Height * args.Location.Y / CanvasView.Height));

            switch (args.Type)
            {
            case TouchActionType.Pressed:
                var rect = new SKRect(0, 0, Design.Bitmap.Width, Design.Bitmap.Height);
                rect = Matrix.MapRect(rect);

                if (rect.Contains(point) && !Touches.ContainsKey(args.Id))
                {
                    Touches.Add(args.Id, point);
                }
                break;

            case TouchActionType.Moved:
                MoveOrScaleCanvas(args.Id, point);
                break;

            case TouchActionType.Released:
            case TouchActionType.Exited:
            case TouchActionType.Cancelled:
                if (Touches.ContainsKey(args.Id))
                {
                    Touches.Remove(args.Id);
                }
                return;
            }
        }
        private async void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            if (args.Type == TouchActionType.Released)
            {
                var pnt = args.Location.ToPixelSKPoint(canvasView);

                // loop through all colors
                foreach (var cp in ColorPicks)
                {
                    // check if selecting a color
                    if (cp.IsTouched(pnt))
                    {
                        _colorChanged = true;
                        _pickedColor  = cp;
                        break; // get out of loop
                    }
                }

                canvasView.InvalidateSurface();

                if (_colorChanged)
                {
                    ColorChanged?.Invoke(this, new ColorChangedEventArgs(_pickedColor.Color));
                    _colorChanged = false;
                    await Navigation.PopPopupAsync();
                }
            }
        }
Exemplo n.º 12
0
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            ContentView view = sender as ContentView;

            // identify the dragged contentView
            for (int i = 0; i < NoCV; i++)
            {
                if (view == contentViews[i])
                {
                    drag = i; break;
                }
            }

            switch (args.Type)
            {
            case TouchActionType.Pressed:
                // Don't allow a second touch on an already touched BoxView
                if (!dragDictionary.ContainsKey(view))
                {
                    dragDictionary.Add(view, new DragInfo(args.Id, args.Location));

                    // Set Capture property to true
                    TouchEffect touchEffect = (TouchEffect)view.Effects.FirstOrDefault(e => e is TouchEffect);
                    touchEffect.Capture = true;
                }

                OffScroll();

                break;

            case TouchActionType.Moved:
                if (dragDictionary.ContainsKey(view) && dragDictionary[view].Id == args.Id)
                {
                    Rectangle rect            = AbsoluteLayout.GetLayoutBounds(view);
                    Point     initialLocation = dragDictionary[view].PressPoint;
                    rect.X += args.Location.X - initialLocation.X;
                    rect.Y += args.Location.Y - initialLocation.Y;
                    AbsoluteLayout.SetLayoutBounds(view, rect);
                }
                break;

            case TouchActionType.Released:
                if (dragDictionary.ContainsKey(view) && dragDictionary[view].Id == args.Id)
                {
                    Rectangle rect = AbsoluteLayout.GetLayoutBounds(view);

                    localpositions[drag].X = rect.X;
                    localpositions[drag].Y = rect.Y;

                    Label2.Text = "Position in absoluteLayout: X = " + rect.X.ToString() +
                                  ", Y = " + rect.Y.ToString();

                    dragDictionary.Remove(view);
                }

                OnScroll();

                break;
            }
        }
Exemplo n.º 13
0
 private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
 {
     // TODO LHE: https://docs.microsoft.com/de-de/xamarin/xamarin-forms/user-interface/graphics/skiasharp/transforms/touch#pinching-and-scaling
     Console.WriteLine("OnTouchEffectAction");
     Log(args.Type.ToString());
     Log(args.Location.ToString());
 }
Exemplo n.º 14
0
        // For each touch event, simply store information in idDictionary.
        // Do not draw at this time!
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            switch (args.Type)
            {
            case TouchActionType.Pressed:
                if (args.IsInContact)
                {
                    idDictionary.Add(args.Id, new FingerInfo
                    {
                        ThisPosition = args.Location,
                        LastPosition = new SKPoint(float.PositiveInfinity, float.PositiveInfinity)
                    });
                }
                break;

            case TouchActionType.Moved:
                if (idDictionary.ContainsKey(args.Id))
                {
                    idDictionary[args.Id].ThisPosition = args.Location;
                }
                break;

            case TouchActionType.Released:
            case TouchActionType.Cancelled:
                if (idDictionary.ContainsKey(args.Id))
                {
                    idDictionary.Remove(args.Id);
                }
                break;
            }
        }
Exemplo n.º 15
0
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            try
            {
                switch (args.Type)
                {
                case TouchActionType.Pressed:
                    Debug.WriteLine(args.Id);
                    if (!inProgressPaths.ContainsKey(args.Id))
                    {
                        SKPath path = new SKPath();
                        path.MoveTo(ConvertToPixel(args.Location));
                        try
                        {
                            inProgressPaths.TryAdd(args.Id, path);
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e);
                        }
                        canvasView.InvalidateSurface();
                    }
                    break;

                case TouchActionType.Moved:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        SKPath path = inProgressPaths[args.Id];
                        path.LineTo(ConvertToPixel(args.Location));
                        canvasView.InvalidateSurface();
                    }
                    break;

                case TouchActionType.Released:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        completedPaths.Add(new PaintPath()
                        {
                            Path = inProgressPaths[args.Id], Paint = paint.Clone()
                        });
                        inProgressPaths.TryRemove(args.Id, out _);
                        canvasView.InvalidateSurface();
                    }
                    break;

                case TouchActionType.Cancelled:
                    if (inProgressPaths.ContainsKey(args.Id))
                    {
                        inProgressPaths.TryRemove(args.Id, out _);
                        canvasView.InvalidateSurface();
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
        }
Exemplo n.º 16
0
        private void MakeNewPathFromPoint(TouchActionEventArgs args, SKPoint pt)
        {
            inProgressPaths.Remove(args.Id);
            BondPath newPath = new BondPath();

            newPath.MoveTo(pt);
            inProgressPaths.Add(args.Id, newPath);
        }
Exemplo n.º 17
0
        private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            SKPoint point = new SKPoint((float)(CanvasView.CanvasSize.Width * args.Location.X / CanvasView.Width),
                                        (float)(CanvasView.CanvasSize.Height * args.Location.Y / CanvasView.Height));

            CanvasView.InvalidateSurface();
            WasTouched(this, false); //Might need to change boolean in the future
        }
 private static void TouchEffect_TouchAction(object sender, TouchActionEventArgs e)
 {
     if (e.Type == TouchActionType.Pressed)
     {
         HideCurrentContextMenu();
     }
     ;
 }
        private void ConfirmOnPressAndRelease(object sender_, TouchActionEventArgs touchActionEventArgs_)
        {
            var welcomePage = Userinterface.Pages.PageControl(Tsw560.Pages.Welcome);

            welcomePage.Show();
            Subpage.Hide();
            ControlSystem.Room.Power = false;
        }
        /// <summary>
        /// Handles touch down events.
        /// </summary>
        /// <param name="e">The motion event arguments.</param>
        /// <returns><c>true</c> if the event was handled.</returns>
        private bool OnTouchDownEvent(TouchActionEventArgs e)
        {
            var args    = ToTouchEventArgs(e, Scale);
            var handled = this.ActualController.HandleTouchStarted(this, args);

            this.previousTouchPoints = GetTouchPoints(e, Scale);
            return(handled);
        }
        /// <summary>
        /// Handles touch move events.
        /// </summary>
        /// <param name="e">The motion event arguments.</param>
        /// <returns><c>true</c> if the event was handled.</returns>
        private bool OnTouchMoveEvent(TouchActionEventArgs e)
        {
            var currentTouchPoints = GetTouchPoints(e, Scale);
            var args    = new XamarinOxyTouchEventArgs(currentTouchPoints, this.previousTouchPoints);
            var handled = this.ActualController.HandleTouchDelta(this, args);

            this.previousTouchPoints = currentTouchPoints;
            return(handled);
        }
Exemplo n.º 22
0
        private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            foreach (EditorObject o in EditorObjectssList)
            {
                o.TouchEffectAction(args, uzorFieldCanvasView);
            }

            uzorFieldCanvasView.InvalidateSurface();
        }
        private void Grid_Touched(object sender, TouchActionEventArgs e)
        {
            double drawSize    = Math.Min(canvasView.Width, canvasView.Height);
            double strokeWidth = drawPaint.StrokeWidth / 6;
            Point  location    = new Point(MinMax(e.Location.X, strokeWidth, drawSize - strokeWidth), MinMax(e.Location.Y, strokeWidth, drawSize - strokeWidth));

            float MinMax(double value, double min, double max)
            {
                return((float)Math.Min(Math.Max(value, min), max));
            }

            switch (e.Type)
            {
            case TouchActionType.Pressed:
                if (!inProgressPaths.ContainsKey(e.Id))
                {
                    SKPath path = new SKPath();
                    path.MoveTo(ConvertToPixel(location));
                    inProgressPaths.Add(e.Id, path);
                    canvasView.InvalidateSurface();
                }
                break;

            case TouchActionType.Moved:
                if (inProgressPaths.ContainsKey(e.Id))
                {
                    SKPath path = inProgressPaths[e.Id];
                    path.LineTo(ConvertToPixel(location));
                    canvasView.InvalidateSurface();
                }
                break;

            case TouchActionType.Released:
                if (inProgressPaths.ContainsKey(e.Id))
                {
                    completedPaths.Add(inProgressPaths[e.Id]);
                    inProgressPaths.Remove(e.Id);
                    canvasView.InvalidateSurface();
                }
                break;

            case TouchActionType.Cancelled:
                if (inProgressPaths.ContainsKey(e.Id))
                {
                    inProgressPaths.Remove(e.Id);
                    canvasView.InvalidateSurface();
                }
                break;
            }

            SKPoint ConvertToPixel(Point pt)
            {
                return(new SKPoint((float)(canvasView.CanvasSize.Width * pt.X / canvasView.Width),
                                   (float)(canvasView.CanvasSize.Height * pt.Y / canvasView.Height)));
            }
        }
 /// <summary>
 /// Converts an <see cref="TouchActionEventArgs" /> to a <see cref="OxyTouchEventArgs" />.
 /// </summary>
 /// <param name="e">The event arguments.</param>
 /// <param name = "scale">The resolution scale factor.</param>
 /// <returns>The converted event arguments.</returns>
 public static OxyTouchEventArgs ToTouchEventArgs(TouchActionEventArgs e, double scale)
 {
     return(new XamarinOxyTouchEventArgs
     {
         Position = new ScreenPoint(e.Location.X / scale, e.Location.Y / scale),
         DeltaTranslation = new ScreenVector(0, 0),
         DeltaScale = new ScreenVector(1, 1),
         PointerCount = e.Locations.Length
     });
 }
Exemplo n.º 25
0
        public void execMensaje(object sender, TouchActionEventArgs args, string Mensaje, int Estado)
        {
            MensajeEventArgs tArgs = new MensajeEventArgs(args.Id, args.Type, args.Location, args.IsInContact, Mensaje, Estado);
            EventHandler <MensajeEventArgs> handler = evMensaje;

            if (handler != null)
            {
                handler(this, tArgs);
            }
        }
Exemplo n.º 26
0
        public void TapHandler(UITapGestureRecognizer tgr)
        {
            CGPoint touchPoint = tgr.LocationInView(nativeElement);
            Point   point      = new Point((double)touchPoint.X, (double)touchPoint.Y);
            double  xInterest  = ((double)touchPoint.X / nativeElement.Frame.Size.Width) * 10000;
            double  yInterest  = ((double)touchPoint.Y / nativeElement.Frame.Size.Height) * 10000;

            MDispatch.NewElement.TouchCordinate.TouchActionEventArgs TouchActionEventArgs = new TouchActionEventArgs(point, nativeElement.Frame.Size.Height, nativeElement.Frame.Size.Width, xInterest, yInterest);
            (Element as TouchImage).FireClick(TouchActionEventArgs);
        }
        private void TouchEffect_TouchAction(object sender, TouchActionEventArgs e)
        {
            // We don't care if Middle or Right Mouse button is used.
            if ((e.MouseButton == TouchMouseButton.Middle) ||
                (e.MouseButton == TouchMouseButton.Right))
            {
                return;
            }

            Boolean cancelLongPress = false;
            Boolean startLongPress  = false;

            switch (e.Type)
            {
            case TouchActionType.Cancelled:
            case TouchActionType.Entered:
            case TouchActionType.Exited:
            case TouchActionType.Released:
                if (longPressStarted)
                {
                    cancelLongPress = true;
                }
                break;

            case TouchActionType.Moved:
                if (longPressStarted)
                {
                    cancelLongPress = (Math.Abs(e.Location.X - longPressInitialLocation.X) > 15) ||
                                      (Math.Abs(e.Location.Y - longPressInitialLocation.Y) > 15);
                }
                break;

            case TouchActionType.Pressed:
                cancelLongPress = true;
                startLongPress  = true;
                break;
            }

            if (cancelLongPress)
            {
                longPressStarted = false;
                if (cancelableDelayForLongPress != null)
                {
                    cancelableDelayForLongPress.Cancel();
                    cancelableDelayForLongPress = null;
                }
            }

            if (startLongPress)
            {
                longPressStarted            = true;
                longPressInitialLocation    = e.Location; // Here e.Location get the press Location relatively to the MessageContext UI Component
                cancelableDelayForLongPress = CancelableDelay.StartAfter(Helper.DELAY_FOR_LONG_PRESS, () => NeedToDisplayActionMenu(sender, longPressInitialLocation));
            }
        }
Exemplo n.º 28
0
 private void OnTouch(object sender, TouchEventArgs e)
 {
     if (e.Event.Action == MotionEventActions.Up)
     {
         Point  point     = new Point(e.Event.GetX(), e.Event.GetY());
         double xInterest = (e.Event.GetX() / Control.Width) * 10000;
         double yInterest = (e.Event.GetY() / Control.Height) * 10000;
         MDispatch.NewElement.TouchCordinate.TouchActionEventArgs TouchActionEventArgs = new TouchActionEventArgs(point, Control.Height, Control.Width, xInterest, yInterest);
         (Element as TouchImage).FireClick(TouchActionEventArgs);
     }
 }
        /// <summary>
        /// Gets the touch points from the specified <see cref="TouchActionEventArgs" /> argument.
        /// </summary>
        /// <param name="e">The event arguments.</param>
        /// <param name = "scale">The resolution scale factor.</param>
        /// <returns>The touch points.</returns>
        public static ScreenPoint[] GetTouchPoints(TouchActionEventArgs e, double scale)
        {
            var result = new ScreenPoint[e.Locations.Length];

            for (int i = 0; i < e.Locations.Length; i++)
            {
                result[i] = new ScreenPoint(e.Locations[i].X / scale, e.Locations[i].Y / scale);
            }

            return(result);
        }
Exemplo n.º 30
0
        private void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            var     viewPoint = args.Location;
            SKPoint point     =
                new SKPoint((float)(canvasView.CanvasSize.Width * viewPoint.X / canvasView.Width),
                            (float)(canvasView.CanvasSize.Height * viewPoint.Y / canvasView.Height));

            var actionType = args.Type;

            _touchGestureRecognizer.ProcessTouchEvent(args.Id, actionType, point);
        }