示例#1
0
        /// <summary>
        /// Captures touch frame reported on screen of the table, so that it can detect touch points for the binary conversion
        /// </summary>
        /// <param name="sender">object sender</param>
        /// <param name="e">touch frame event arguements</param>
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            Console.WriteLine(e.GetTouchPoints(this.myGrid).Count);

            foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.myGrid))
            {
                int id = _touchPoint.TouchDevice.Id;
                myGrid.InvalidateVisual();
                if (!_touchPoint.TouchDevice.GetIsTagRecognized() && !_touchPoint.TouchDevice.GetIsFingerRecognized())
                {
                    bool flag = false;
                    for (int i = 0; i < AllPoints.Count; i++)
                    {
                        if (AllPoints[i].TouchDevice.Id == id)
                        {
                            flag = true;
                        }
                    }

                    if (!flag)
                    {
                        AllPoints.Add(_touchPoint);
                        flag = false;
                    }
                }
            }

            if (e.GetTouchPoints(this.myGrid).Count == 1 && AllPoints.Count > 0)
            {
                //Game stuff recieve
            }
        }
示例#2
0
 /// <summary>
 /// Bir touch algılanırsa
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     //Point _FirstTouch = new Point(0, 0);
     //Point _SecondTouch = new Point(0, 0);
     if ((e.GetPrimaryTouchPoint(this) != null))
     {
         IlkDokunus = e.GetPrimaryTouchPoint(this);
         if (IlkDokunus.Action == TouchAction.Down)
         {
             //_FirstTouch = new Point(0, 0);
             //_SecondTouch = new Point(0, 0);
         }
         else if (IlkDokunus.Action == TouchAction.Move)
         {
             if (e.GetTouchPoints(this).Count > 1)
             {
                 IkinciDokunus = e.GetTouchPoints(this)[1];
             }
         }
         if (IkinciDokunus != null)
         {
             var matrix = ((MatrixTransform)this.RenderTransform).Matrix;
             TouchCenter = matrix.Transform(
                 AnaliticGeometryHelper.CenterPoint(
                     IlkDokunus.Position,
                     IkinciDokunus.Position
                     )
                 );
         }
     }
 }
示例#3
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            int pointsNumber = e.GetTouchPoints(drawCanvas).Count;
            TouchPointCollection pointCollection = e.GetTouchPoints(drawCanvas);


            for (int i = 0; i < pointsNumber; i++)
            {
                if (pointCollection[i].Action == TouchAction.Down)
                {
                    preXArray[i] = pointCollection[i].Position.X;
                    preYArray[i] = pointCollection[i].Position.Y;
                }
                if (pointCollection[i].Action == TouchAction.Move)
                {
                    Line line = new Line();


                    line.X1 = preXArray[i];
                    line.Y1 = preYArray[i];
                    line.X2 = pointCollection[i].Position.X;
                    line.Y2 = pointCollection[i].Position.Y;


                    line.Stroke          = new SolidColorBrush(Colors.Red);
                    line.Fill            = new SolidColorBrush(Colors.Red);
                    line.StrokeThickness = 5;
                    drawCanvas.Children.Add(line);


                    preXArray[i] = pointCollection[i].Position.X;
                    preYArray[i] = pointCollection[i].Position.Y;
                }
            }
        }
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            try
            {
                int pointsNumber = e.GetTouchPoints(ellipseSense).Count;
                TouchPointCollection pointCollection = e.GetTouchPoints(ellipseSense);


                for (int i = 0; i < pointsNumber; i++)
                {
                    if (pointCollection[i].Position.X > 0 && pointCollection[i].Position.X < ellipseSense.ActualWidth)
                    {
                        if (pointCollection[i].Position.Y > 0 && pointCollection[i].Position.Y < ellipseSense.ActualHeight)
                        {
                            // Update Shpero speed and direction
                            Point p      = pointCollection[i].Position;
                            Point center = new Point(ellipseSense.ActualWidth / 2, ellipseSense.ActualHeight / 2);

                            double distance = Math.Sqrt(Math.Pow((p.X - center.X), 2) + Math.Pow((p.Y - center.Y), 2));

                            double distanceRel = distance * 255 / (ellipseSense.ActualWidth / 2);
                            if (distanceRel > 255)
                            {
                                distanceRel = 255;
                            }

                            double angle = Math.Atan2(p.Y - center.Y, p.X - center.X) * 180 / Math.PI;
                            if (angle > 0)
                            {
                                angle += 90;
                            }
                            else
                            {
                                angle = 270 + (180 + angle);
                                if (angle >= 360)
                                {
                                    angle -= 360;
                                }
                            }
                            direction = Convert.ToInt16(angle);
                            speed     = Convert.ToInt16(distanceRel);

                            // Set Joystick Pos
                            newX = p.X - (ellipseSense.ActualWidth / 2);
                            newY = p.Y - (ellipseSense.ActualWidth / 2);
                            if (moveJoystick)
                            {
                                MoveJoystick(newX, newY);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
示例#5
0
        void TouchFrameReported(object sender, TouchFrameEventArgs e)
        {
            if (!AssociatedObject.DesiredSize.Equals(new Size(0, 0))) //Code Fix by Devix: enables Multi-Page support
            {
                _processor.Process(e.GetTouchPoints(AssociatedObject));

#if DEBUG
                HandleDebugInfoAndFingers(
                    e.GetTouchPoints(RootVisual),
                    e.GetPrimaryTouchPoint(RootVisual));
#endif
            }
        }
示例#6
0
        // support pinch zooming
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            var touchpoints = e.GetTouchPoints(myDiagram.Panel);

            if (touchpoints.Count > 1)
            {
                var tp0     = touchpoints[0].Position;
                var tp1     = touchpoints[1].Position;
                var newDist = Math.Sqrt((tp0.X - tp1.X) * (tp0.X - tp1.X) + (tp0.Y - tp1.Y) * (tp0.Y - tp1.Y));
                if (Double.IsNaN(startDist))
                {
                    startDist  = newDist;
                    startScale = myDiagram.Panel.Scale;
                    var primary = e.GetPrimaryTouchPoint(myDiagram.Panel);
                    if (primary != null)
                    {
                        myDiagram.Panel.ZoomPoint = primary.Position;
                    }
                }
                else
                {
                    myDiagram.Panel.Scale = startScale * newDist / startDist;
                }
            }
            else
            {
                startDist = Double.NaN;
            }
        }
示例#7
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            try
            {
                var touchPoints = e.GetTouchPoints(Map);

                SuppressMapGestures = touchPoints.Count == 3;

                if (touchPoints.Count == 3)
                {
                    if (!_initialPitchYLocation.HasValue)
                    {
                        _initialPitchYLocation = touchPoints[0].Position.Y;
                    }

                    double delta    = touchPoints[0].Position.Y - _initialPitchYLocation.Value;
                    double newPitch = Math.Max(0, Math.Min(75, (Map.Pitch + delta * Sensitivity)));
                    Map.Pitch = newPitch;
                    _initialPitchYLocation = touchPoints[0].Position.Y;
                }
                else
                {
                    _initialPitchYLocation = null;
                }
            }
            catch { }
        }
示例#8
0
        private static void TouchFrameReported(object sender, TouchFrameEventArgs e)
        {
            if (_internalPanningControl == null)
            {
                return;
            }

            // (When the parent Panorama/Pivot is suspended)
            // Wait for the first touch to end (touchaction up). When it is, restore standard
            // panning behavior, otherwise let the control behave normally (no code for this)
            var lastTouchPoint    = _internalPanningControl.GetValue(LastTouchPointProperty) as TouchPoint;
            var isScrollSuspended = (bool)_internalPanningControl.GetValue(IsScrollSuspendedProperty);

            var touchPoint = e.GetTouchPoints(ApplicationSpace.RootFrame);

            if (lastTouchPoint == null || lastTouchPoint != touchPoint.Last())
            {
                lastTouchPoint = touchPoint.Last();
            }

            if (isScrollSuspended)
            {
                // Touch is up, custom behavior is over reset to original values
                if (lastTouchPoint != null && lastTouchPoint.Action == TouchAction.Up)
                {
                    Touch.FrameReported -= TouchFrameReported;
                    _internalPanningControl.IsHitTestVisible = true;
                    _internalPanningControl.SetValue(IsScrollSuspendedProperty, false);
                }
            }
        }
示例#9
0
        private static void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            // (When the parent Panorama/Pivot is suspended)
            // Wait for the first touch to end (touchaction up). When it is, restore standard
            // panning behavior, otherwise let the control behave normally (no code for this)
            var lastTouchPoint    = InternalPanningControl.GetValue(BlocksPan.LastTouchPointProperty) as TouchPoint;
            var isScrollSuspended = (bool)InternalPanningControl.GetValue(BlocksPan.IsScrollSuspendedProperty);
            var touchPoints       = e.GetTouchPoints(InternalPanningControl);

            if (lastTouchPoint != touchPoints.Last() || lastTouchPoint == null)
            {
                lastTouchPoint = touchPoints.Last();
            }

            if (isScrollSuspended)
            {
                // Touch is up, custom behavior is over reset to original values
                if (lastTouchPoint.Action == TouchAction.Up)
                {
                    Touch.FrameReported -= Touch_FrameReported;
                    lastTouchPoint       = null;
                    InternalPanningControl.IsHitTestVisible = true;
                    isScrollSuspended = false;
                }
            }
        }
示例#10
0
        //   الداله دى لو الجهاز بتاعك بيدعم التاتش اسكرين

        /*
         * Action=====>Gets the last action that occurred at this location.
         * Bounds=====>Gets the bounds of the area that the finger has in contact with the screen.
         * Position====>Gets the location of the touch point.
         * Size========>Gets the size of the Bounds property.
         * TouchDevice=>Gets the touch device that generated this TouchPoint.
         */

        private void Touch_FrameReportedRed(object sender, TouchFrameEventArgs e)
        {
            if (this.canvas1 != null)
            {
                foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1))
                {
                    if (_touchPoint.Action == TouchAction.Down)
                    {
                        _touchPoint.TouchDevice.Capture(this.canvas1);
                    }
                    else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null)
                    {
                        if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                        {
                            Canvas.SetLeft(rectangleRed, _touchPoint.Position.X);
                        }
                        else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                        {
                            Canvas.SetLeft(rectangleBlue, _touchPoint.Position.X);
                        }
                    }
                    else if (_touchPoint.Action == TouchAction.Up)
                    {
                        this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice);
                    }
                }
            }
        }
示例#11
0
        private void Touch_OnFrameReported(object sender, TouchFrameEventArgs e)
        {
            int num1 = Math.Min(1, ((PresentationFrameworkCollection <TouchPoint>)e.GetTouchPoints((UIElement)this.drawCanvas)).Count);
            TouchPointCollection touchPoints = e.GetTouchPoints((UIElement)this.drawCanvas);

            for (int index = 0; index < num1; ++index)
            {
                TouchPoint touchPoint      = ((PresentationFrameworkCollection <TouchPoint>)touchPoints)[index];
                Point      position        = touchPoint.Position;
                bool       isPointInBounds = this.GetIsPointInBounds(position);
                position.Y = position.Y - 20.0;
                switch (touchPoint.Action)
                {
                case TouchAction.Down:
                    if (isPointInBounds)
                    {
                        this._isDrawing = true;
                        this.gridPallete.IsHitTestVisible = false;
                        this.HandleTouchPoint(position, false);
                        this.UpdateUndoOpacity();
                        break;
                    }
                    break;

                case TouchAction.Move:
                    if (this._isDrawing)
                    {
                        this.HandleTouchPoint(position, false);
                        break;
                    }
                    break;

                case TouchAction.Up:
                    if (this._isDrawing)
                    {
                        this.HandleTouchPoint(position, true);
                        this._isDrawing = false;
                        this.gridPallete.IsHitTestVisible = true;
                        break;
                    }
                    break;
                }
            }
        }
示例#12
0
        void TouchFrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPointCollection tpc = e.GetTouchPoints(ContentCanvas);

            tpc.ToList().ForEach(p =>
            {
                // p.Action of type ActionType: Up, Down, Move
                Ellipse el = TouchUtils.CreateEllipse(p.Position);
                ContentCanvas.Children.Add(el);
            });
        }
示例#13
0
        /// <summary>
        /// Handles raw touch events.
        /// </summary>
        void FrameReported(object sender, TouchFrameEventArgs e)
        {
            var touchPoints = e.GetTouchPoints(this.viewport);

            if (touchPoints.Count >= 2 && touchPoints[0].Action == TouchAction.Up)
            {
                this.TouchLine.X1 = touchPoints[0].Position.X;
                this.TouchLine.X2 = touchPoints[1].Position.X;
                this.TouchLine.Y1 = touchPoints[0].Position.Y;
                this.TouchLine.Y2 = touchPoints[1].Position.Y;
            }
        }
        /* OLD CODE
         * private void onTouchDown(object sender, Microsoft.Surface.Core.TouchEventArgs e)
         * {
         *  //Console.Write(string.Format("Touchpoint Coordinates - {0},{1}\n", e.TouchPoint.CenterX, e.TouchPoint.CenterY));
         *      //Old Code in if statement
         *      if ((e.TouchPoint.CenterX > lynx.xSendFirst && e.TouchPoint.CenterX < lynx.xSendFirst + lynx.distance * 8) &&
         *           (e.TouchPoint.CenterY > lynx.ySendFirst && e.TouchPoint.CenterY < lynx.ySendFirst + lynx.distance * 2))
         *      {
         *          isReading = true;
         *          Console.Write(string.Format("xFirst = {0}, yFirst = {1}, point received {2},{3} x should be {4}, y should be {5}\n", lynx.xSendFirst, lynx.ySendFirst, e.TouchPoint.CenterX, e.TouchPoint.CenterY, (int)((e.TouchPoint.CenterX - lynx.xSendFirst) / lynx.distance), (int)((e.TouchPoint.CenterY - lynx.ySendFirst) / lynx.distance)));
         *          int matrixIndex = (int)((e.TouchPoint.CenterX - lynx.xSendFirst) / lynx.distance) + (8 * ((int)((e.TouchPoint.CenterY - lynx.ySendFirst) / lynx.distance)));
         *          lightMatrix[matrixIndex] = 1;
         *          Console.Write(string.Format("{0} bit changed to 1\n",matrixIndex));
         *      }
         *
         *      if ((e.TouchPoint.CenterX > lynx.xSendFirst && e.TouchPoint.CenterX < lynx.xSendFirst + lynx.distance) &&
         *               (e.TouchPoint.CenterY > lynx.ySendFirst && e.TouchPoint.CenterY < lynx.ySendFirst + lynx.distance))
         *      {
         *          Console.Write("Write Bit Detected\n");
         *          //Console.Write(string.Format("xFirst = {0}, yFirst = {1}, point received {2},{3} x should be {4}, y should be {5}\n", lynx.xSendFirst, lynx.ySendFirst, e.TouchPoint.CenterX, e.TouchPoint.CenterY, (int)((e.TouchPoint.CenterX - lynx.xSendFirst) / lynx.distance), (int)((e.TouchPoint.CenterY - lynx.ySendFirst) / lynx.distance)));
         *          lightMatrix[0] = 1;
         *          receive();
         *      }
         *      else if ((e.TouchPoint.CenterX < lynx.xSendFirst && e.TouchPoint.CenterX > lynx.xSendFirst - lynx.distance) &&
         *               (e.TouchPoint.CenterY > lynx.ySendFirst && e.TouchPoint.CenterY < lynx.ySendFirst + lynx.distance))
         *      {
         *          Console.Write("Read Bit Detected\n");
         *          lightMatrix[8] = 1;
         *      }
         *  //receive();//test code, comment for normal use
         * }*/

        private void onFrameReported(object sender, TouchFrameEventArgs e)
        {
            foreach (System.Windows.Input.TouchPoint _touchPoint in e.GetTouchPoints(grid))
            {
                int id = _touchPoint.TouchDevice.Id;
                if (!_touchPoint.TouchDevice.GetIsTagRecognized() && !_touchPoint.TouchDevice.GetIsFingerRecognized())
                {
                    /* bool flag = false;
                     * for (int i = 0; i < AllPoints.Count; i++)
                     * {
                     *   if (AllPoints[i].TouchDevice.Id == id)
                     *   {
                     *       flag = true;
                     *   }
                     * }
                     *
                     * if (!flag)
                     * {
                     *   AllPoints.Add(_touchPoint);
                     *   flag = false;
                     * }*/

                    if ((_touchPoint.Position.X > lynx.xSendFirst - (lynx.distance / 2) && _touchPoint.Position.X < lynx.xSendFirst + (lynx.distance * 2) - (lynx.distance / 2)) &&
                        (_touchPoint.Position.Y > lynx.ySendFirst && _touchPoint.Position.Y < lynx.ySendFirst + lynx.distance * 8))
                    {
                        //Console.Write(string.Format("xFirst = {0}, yFirst = {1}, point received {2},{3} x should be {4}, y should be {5}\n", lynx.xSendFirst, lynx.ySendFirst, e.TouchPoint.CenterX, e.TouchPoint.CenterY, (int)((e.TouchPoint.CenterX - lynx.xSendFirst) / lynx.distance), (int)((e.TouchPoint.CenterY - lynx.ySendFirst) / lynx.distance)));
                        int matrixIndex = (int)(((_touchPoint.Position.X - lynx.xSendFirst) / lynx.distance) * -8) + (((int)((_touchPoint.Position.Y - lynx.ySendFirst) / lynx.distance)));
                        lightMatrix[matrixIndex] = 1;
                        //Console.Write(string.Format("{0} bit changed to 1\n", matrixIndex));
                    }

                    if (lightMatrix[0] == 1 && lynxHasWritten == true)
                    {
                        receive();
                        lynxHasWritten = false;
                    }
                    else if (lightMatrix[0] == 0)
                    {
                        lynxHasWritten = true;
                    }

                    if (lightMatrix[8] == 1 && lynxHasRead == true)
                    {
                        DataReset   = true;
                        lynxHasRead = false;
                    }
                    else if (lightMatrix[8] == 0)
                    {
                        lynxHasRead = true;
                    }
                }
            }
        }
示例#15
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (this.canvas1 != null)
            {
                // <snippet120>
                foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1))
                {
                    if (_touchPoint.Action == TouchAction.Down)
                    {
                        // Clear the canvas and capture the touch to it.
                        this.canvas1.Children.Clear();
                        _touchPoint.TouchDevice.Capture(this.canvas1);
                    }

                    else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null)
                    {
                        // This is the first (primary) touch point. Just record its position.
                        if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                        {
                            pt1.X = _touchPoint.Position.X;
                            pt1.Y = _touchPoint.Position.Y;
                        }

                        // This is not the first touch point. Draw a line from the first point to this one.
                        else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                        {
                            pt2.X = _touchPoint.Position.X;
                            pt2.Y = _touchPoint.Position.Y;

                            Line _line = new Line();
                            _line.Stroke          = new RadialGradientBrush(Colors.White, Colors.Black);
                            _line.X1              = pt1.X;
                            _line.X2              = pt2.X;
                            _line.Y1              = pt1.Y;
                            _line.Y2              = pt2.Y;
                            _line.StrokeThickness = 2;
                            this.canvas1.Children.Add(_line);
                        }
                    }

                    else if (_touchPoint.Action == TouchAction.Up)
                    {
                        // If this touch is captured to the canvas, release it.
                        if (_touchPoint.TouchDevice.Captured == this.canvas1)
                        {
                            this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice);
                        }
                    }
                }
                // </snippet120>
            }
        }
示例#16
0
        /// <summary>
        /// Handles TouchFrameReported event and raise TouchDown/Up/Move events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void TouchFrameReported(object sender, TouchFrameEventArgs e)
        {
            // get the root

            UIElement root = rootNode;

            if (root == null)
            {
                return;
            }

            foreach (TouchPoint touchPoint in e.GetTouchPoints(null))
            {
                int id = touchPoint.TouchDevice.Id;

                // check if the touchDevice is captured or not.
                UIElement captured;
                currentCaptures.TryGetValue(id, out captured);

                switch (touchPoint.Action)
                {
                // TouchDown
                case TouchAction.Down:
                    HitTestAndRaiseDownEvent(root, touchPoint);
                    currentTouchPoints[id] = touchPoint;
                    break;

                // TouchUp
                case TouchAction.Up:
                    // handle only captured touches
                    if (captured != null)
                    {
                        RaiseUpEvent(captured, touchPoint);

                        // release capture
                        Capture(touchPoint.TouchDevice, null);
                        captured = null;
                    }
                    currentTouchPoints.Remove(id);
                    break;

                // TouchMove
                case TouchAction.Move:
                    // just remember the new touchPoint, the event will be raised in bulk later
                    currentTouchPoints[id] = touchPoint;
                    break;
                }
            }

            // raise CapturedReportEvents
            RaiseCapturedReportEvent();
        }
示例#17
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            foreach (TouchPoint tp in e.GetTouchPoints(DrawCanvas))
            {
                TrackedTouchPoint ttp = null;
                var query             = from point in trackedTouchPoints
                                        where point.ID == tp.TouchDevice.Id
                                        select point;
                if (query.Count() != 0)
                {
                    ttp = query.First();
                }

                switch (tp.Action)
                {
                case TouchAction.Down: ttp = new TrackedTouchPoint();
                    ttp.ID = tp.TouchDevice.Id;
                    if (trackedTouchPoints.Count == 0)
                    {
                        ttp.IsPrimary = true;
                        DrawCanvas.Children.Clear();
                    }
                    trackedTouchPoints.Add(ttp);
                    ttp.Position = tp.Position;
                    ttp.Draw(DrawCanvas);
                    break;

                case TouchAction.Up: ttp.UnDraw(DrawCanvas);
                    trackedTouchPoints.Remove(ttp);
                    break;

                default:
                    ttp.Position = tp.Position;
                    ttp.Draw(DrawCanvas);
                    break;
                }
            }
            CleanUp(e.GetTouchPoints(DrawCanvas));
        }
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (rotate)
            {
                TouchPointCollection touchPoints;
                try
                {
                    touchPoints = e.GetTouchPoints(Map);
                }
                catch
                {
                    return;
                }

                if (touchPoints.Count == 2)
                {
                    // for the initial touch, record the angle between the fingers
                    if (!_previousAngle.HasValue)
                    {
                        _previousAngle = AngleBetweenPoints(touchPoints[0], touchPoints[1]);
                    }

                    // should we rotate?
                    if (!_isRotating)
                    {
                        double angle = AngleBetweenPoints(touchPoints[0], touchPoints[1]);
                        double delta = angle - _previousAngle.Value;
                        if (Math.Abs(delta) > MinimumRotation)
                        {
                            _isRotating         = true;
                            SuppressMapGestures = true;
                        }
                    }

                    // rotate me
                    if (_isRotating && rotate)
                    {
                        double angle = AngleBetweenPoints(touchPoints[0], touchPoints[1]);
                        double delta = angle - _previousAngle.Value;
                        Map.Heading   -= delta;
                        _previousAngle = angle;
                    }
                }
                else
                {
                    _previousAngle      = null;
                    _isRotating         = false;
                    SuppressMapGestures = false;
                }
            }
        }
示例#19
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPoint primaryTouchPoint = e.GetPrimaryTouchPoint(null);

            TouchPointCollection touchPoints = e.GetTouchPoints(null);

            foreach (TouchPoint tp in touchPoints)
            {
                if (tp.Action == TouchAction.Move)
                {
                    var t           = TransformToVisual(ContentPanel);
                    var absposition = t.Transform(new Point(tp.Position.X, tp.Position.Y));

                    if (absposition.X > 0 &&
                        absposition.X < btnBreak.ActualHeight &&
                        absposition.Y > 0 &&
                        absposition.Y < btnBreak.ActualWidth)
                    {
                        //btn BREAK
                        tbBrakeInfo.Text = "b-> x: " + absposition.X + " y:" + absposition.Y;
                        double val = Normalize(absposition.X, absposition.Y, btnBreak.ActualHeight);
                        tbBrakeInfo.Text += " " + (1 - val);

                        if (val > 1)
                        {
                            btnBreak_MouseLeave(null, null);
                        }

                        input.breakVal = 1 - (float)val;
                    }

                    if (absposition.X < btnAcceleration.ActualHeight &&
                        absposition.X > 0 &&
                        absposition.Y < ContentPanel.ActualWidth &&
                        absposition.Y > ContentPanel.ActualWidth - btnAcceleration.ActualWidth)
                    {
                        //btn ACCEL
                        var yp = absposition.Y - (ContentPanel.ActualWidth - btnAcceleration.ActualWidth);
                        tbAccelInfo.Text = "a-> x: " + absposition.X + " y:" + yp;

                        double val = Normalize(absposition.X, yp, btnAcceleration.ActualHeight);
                        tbAccelInfo.Text += " " + (1 - val);
                        if (val > 1)
                        {
                            btnAcceleration_MouseLeave(null, null);
                        }
                        input.acceleration = 1 - (float)val;
                    }
                }
            }
        }
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            try
            {
                int pointsNumber = e.GetTouchPoints(ellipseSense).Count;
                TouchPointCollection pointCollection = e.GetTouchPoints(ellipseSense);


                for (int i = 0; i < pointsNumber; i++)
                {
                    if (pointCollection[i].Position.X > 0 && pointCollection[i].Position.X < ellipseSense.ActualWidth)
                    {
                        if (pointCollection[i].Position.Y > 0 && pointCollection[i].Position.Y < ellipseSense.ActualHeight)
                        {
                            Touch_FrameReported(pointCollection[i].Position);
                        }
                    }
                }
            }
            catch
            {
            }
        }
示例#21
0
        public void on_touch_event(object sender, TouchFrameEventArgs args)
        {
            if (input_enabled == false)
            {
                return;
            }
            var tps = args.GetTouchPoints(this);

            foreach (var tp in tps)
            {
                var ta = tp.Action;
                int x = (int)tp.Position.X, y = (int)tp.Position.Y;
                int id = tp.TouchDevice.Id;
                if (ta == TouchAction.Down)
                {
                    var ppe = new eq.gui.PointerPressEvent();
                    ppe.set_button(1);
                    ppe.set_id(id);
                    ppe.set_x(x);
                    ppe.set_y(y);
                    ppe.set_pointer_type(eq.gui.PointerEvent.TOUCH);
                    _event(ppe);
                }
                else if (ta == TouchAction.Up)
                {
                    var pre = new eq.gui.PointerReleaseEvent();
                    pre.set_button(1);
                    pre.set_id(id);
                    pre.set_x(x);
                    pre.set_y(y);
                    pre.set_pointer_type(eq.gui.PointerEvent.TOUCH);
                    _event(pre);
                    var ple = new eq.gui.PointerLeaveEvent();
                    ple.set_id(id);
                    ple.set_x(x);
                    ple.set_y(y);
                    ple.set_pointer_type(eq.gui.PointerEvent.TOUCH);
                    _event(ple);
                }
                else if (ta == TouchAction.Move)
                {
                    var pme = new eq.gui.PointerMoveEvent();
                    pme.set_id(id);
                    pme.set_x(x);
                    pme.set_y(y);
                    pme.set_pointer_type(eq.gui.PointerEvent.TOUCH);
                    _event(pme);
                }
            }
        }
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPointCollection touches = e.GetTouchPoints(ContentPanel);

            if (touches.Count == 2)
            {
                if ((onePoint.X - e.GetTouchPoints(ContentPanel)[0].Position.X) < (towPoint.X - e.GetTouchPoints(ContentPanel)[1].Position.X))
                {
                    player.Height += 2;
                    player.Width  += 2;
                }
                else if ((towPoint.X - onePoint.X) < (e.GetTouchPoints(ContentPanel)[1].Position.X - e.GetTouchPoints(ContentPanel)[0].Position.X))
                {
                    if (player.Height > 50)
                    {
                        player.Height -= 2;
                        player.Width  -= 2;
                    }
                }

                onePoint = touches[0].Position;
                towPoint = touches[1].Position;
            }
        }
示例#23
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            var touchPoints    = e.GetTouchPoints(LayoutRoot);
            var pointsInBounds = touchPoints.Where(p => IsInBounds(p.Position) && p.Action != TouchAction.Up).Select(p => p.Position);
            var pointArray     = pointsInBounds as Point[] ?? pointsInBounds.ToArray();

            if (Visibility == Visibility.Visible && pointArray.Any())
            {
                SetJoystickToNewPoint(pointArray.First());
            }
            else
            {
                ResetHandleToOrigin();
            }
        }
示例#24
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPointCollection touches = e.GetTouchPoints(viewPort);

            if (touches.Count == 2)
            {
                if ((onePoint.X - e.GetTouchPoints(viewPort)[0].Position.X) < (towPoint.X - e.GetTouchPoints(viewPort)[1].Position.X))
                {
                    viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width, viewPort.Bounds.Height + 10);
                    viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width + 10, viewPort.Bounds.Height);
                }
                else if ((towPoint.X - onePoint.X) < (e.GetTouchPoints(viewPort)[1].Position.X - e.GetTouchPoints(viewPort)[0].Position.X))
                {
                    if (image.Height > 50)
                    {
                        viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width, viewPort.Bounds.Height - 10);
                        viewPort.Bounds = new Rect(0, 0, viewPort.Bounds.Width - 10, viewPort.Bounds.Height);
                    }
                }

                onePoint = touches[0].Position;
                towPoint = touches[1].Position;
            }
        }
        /// <summary>
        ///     Touches the frame reported.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="TouchFrameEventArgs" /> instance containing the event data.</param>
        private void TouchFrameReported(object sender, TouchFrameEventArgs e)
        {
            Debug.WriteLine(e);

            var points = e.GetTouchPoints(WebView);

            if (points.Count == 1)
            {
                var point = points[0];

                if (point.Action == TouchAction.Move)
                {
                    var pos = point.Position;
                }
            }
        }
示例#26
0
        /// <summary>
        /// Touch handling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            var parent = VisualTreeHelper.GetParent(this);

            while (parent != null)
            {
                if (parent is PhoneApplicationPage)
                {
                    var page = parent as PhoneApplicationPage;

                    // Get this' position on screen
                    var transform        = this.TransformToVisual(page);
                    var absolutePosition = transform.Transform(new System.Windows.Point(0, 0));
                    var ourRect          = new Xamarin.Forms.Rectangle(absolutePosition.X, absolutePosition.Y, this.Width, this.Height);

                    // Get main touch point
                    var mainTouchPoint = e.GetPrimaryTouchPoint(page);

                    // Make sure our control is actually in the touch zone
                    if (!ourRect.Contains(mainTouchPoint.Position.X, mainTouchPoint.Position.Y))
                    {
                        return;
                    }

                    var touches = e.GetTouchPoints(this).Select(t => new NGraphics.Point(t.Position.X, t.Position.Y));

                    if (mainTouchPoint.Action == TouchAction.Move)
                    {
                        Element.TouchesMoved(touches);
                    }
                    else if (mainTouchPoint.Action == TouchAction.Down)
                    {
                        Element.TouchesBegan(touches);
                    }
                    else if (mainTouchPoint.Action == TouchAction.Up)
                    {
                        Element.TouchesEnded(touches);
                    }

                    break;
                }

                parent = VisualTreeHelper.GetParent(parent);
            }
        }
示例#27
0
 void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     foreach (TouchPoint p in e.GetTouchPoints(DrawCanvas))
     {
         if ((InDrawingMode) && (p.Action == TouchAction.Move))
         {
             Ellipse ellipse = new Ellipse();
             ellipse.SetValue(Canvas.LeftProperty, p.Position.X);
             ellipse.SetValue(Canvas.TopProperty, p.Position.Y);
             ellipse.Width            = _touchRadius;
             ellipse.Height           = _touchRadius;
             ellipse.IsHitTestVisible = false;
             ellipse.Stroke           = ((ColorClass)ColorListBox.SelectedItem).ColorBrush;
             ellipse.Fill             = ((ColorClass)ColorListBox.SelectedItem).ColorBrush;
             DrawCanvas.Children.Add(ellipse);
         }
     }
 }
示例#28
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            var touchPoints = e.GetTouchPoints(SceneViewport);

            // HitTest(touchPoints[0].Position);

            //if (touchPoints.Count >= 3 && touchPoints[0].Action == TouchAction.Move )
            //{

            //    lastposition = touchPoints[0].Position;

            //    SceneTrackball.UpdateTouchPan(touchPoints[0].Position);
            //    //this.TouchLine.X1 = touchPoints[0].Position.X;
            //    //this.TouchLine.X2 = touchPoints[1].Position.X;
            //    //this.TouchLine.Y1 = touchPoints[0].Position.Y;
            //    //this.TouchLine.Y2 = touchPoints[1].Position.Y;
            //}
        }
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(e);

            var points = e.GetTouchPoints(this.WebView);

            if (points.Count == 1)
            {
                var point = points[0];



                if (point.Action == TouchAction.Move)
                {
                    var pos = point.Position;
                }
            }
        }
示例#30
0
        /// <summary>
        /// Handle touch events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            bool  newIsInTouch  = false;
            Point gestureOrigin = new Point(0, 0);

            foreach (TouchPoint point in e.GetTouchPoints(null))
            {
                if (point.Action != TouchAction.Up)
                {
                    gestureOrigin = point.Position;
                    newIsInTouch  = true;
                    break;
                }
            }

            if (!_isInTouch && newIsInTouch)
            {
                // The user was not in the middle of a gesture, but one has started.
                _gestureOrigin    = gestureOrigin;
                _useGestureOrigin = true;
                TouchStart();
            }
            else if (_isInTouch && !newIsInTouch)
            {
                // The user was in the middle of a gesture, but there are no active
                // touch points anymore.
                TouchComplete();
            }
            else if (_isInTouch)
            {
                // The state has not changed, and the user was in the middle of a gesture.
                TouchDelta();
            }
            else
            {
                // Possible error condition? The user was not in the middle of a
                // gesture, but a Touch.FrameReported event was received with no
                // active touch points. We should poll the TouchPanel just to be
                // safe, but do so in such a way that resets the state.
                TouchStart();
            }

            _isInTouch = newIsInTouch;
        }