Exemple #1
0
        void OnTouchFrameReported(object sender, TouchFrameEventArgs args)
        {
            TouchPoint touchPoint = args.GetPrimaryTouchPoint(this);

            if (touchPoint != null && touchPoint.Action == TouchAction.Down)
            {
                args.SuspendMousePromotionUntilTouchUp();
            }

            if (touchPoint != null && touchPoint.TouchDevice.DirectlyOver is Rectangle)
            {
                Rectangle rectangle = (touchPoint.TouchDevice.DirectlyOver as Rectangle);

                // This DataContext is an object of type Student
                object dataContext = rectangle.DataContext;
                studentDisplay.DataContext = dataContext;

                if (touchPoint.Action == TouchAction.Down)
                {
                    studentDisplay.Visibility = Visibility.Visible;
                }

                else if (touchPoint.Action == TouchAction.Up)
                {
                    studentDisplay.Visibility = Visibility.Collapsed;
                }
            }
        }
Exemple #2
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (draggingNow == true)
            {
                TouchPoint tp = e.GetPrimaryTouchPoint(map1);

                if (tp.Action == TouchAction.Move)
                {
                    if (draggingArea == true)
                    {
                        if (twoMarker != null)
                        {
                            twoMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(tp.Position);
                            areaRadius = (int)twoMarker.GeoCoordinate.GetDistanceTo(oneMarker.GeoCoordinate);
                            DoCreateTheAreaCircle();
                        }
                    }
                    else if (oneMarker != null)
                    {
                        oneMarker.GeoCoordinate = map1.ConvertViewportPointToGeoCoordinate(tp.Position);
                        DoCreateTheAreaCircle();
                        if (twoMarker != null && PolyCircle != null && PolyCircle.Path != null)
                        {
                            twoMarker.GeoCoordinate = PolyCircle.Path[0];
                        }
                    }
                }
                else if (tp.Action == TouchAction.Up)
                {
                    draggingArea   = draggingNow = false;
                    map1.IsEnabled = true;
                }
            }
        }
Exemple #3
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
                     )
                 );
         }
     }
 }
Exemple #4
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 { }
        }
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPoint mainTouch = e.GetPrimaryTouchPoint(this);

            if (mainTouch.Action == TouchAction.Down)
            {
                first = mainTouch;
            }
            else if (mainTouch.Action == TouchAction.Up)
            {
                if (mainTouch.Position.X - first.Position.X > 25)
                {
                    string clicktype = "";
                    string imgqual   = "";
                    for (int i = 0; i < this.RadioGrid.Children.Count; i++)
                    {
                        RadioButton rb = (RadioButton)this.RadioGrid.Children[i];
                        if (rb.IsChecked == true && rb.GroupName == "ImgQual")
                        {
                            imgqual = (i + 1).ToString();
                        }
                        else if (rb.IsChecked == true && rb.GroupName == "ClickType")
                        {
                            clicktype = (i - 3).ToString();
                        }
                    }
                    NavigationService.Navigate(new Uri("/MainPage.xaml?imgqual=" + imgqual + "&" + "clicktype=" + clicktype, UriKind.Relative));
                    Touch.FrameReported -= Touch_FrameReported;
                }
                //myPivot.SelectedIndex--;
            }
        }
Exemple #6
0
        void OnFrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPoint touchPoint;

            try
            {
                touchPoint = e.GetPrimaryTouchPoint(this);
            }
            catch (Exception)
            {
                return;
            }

            if (touchPoint == null || touchPoint.Action != TouchAction.Move)
            {
                return;
            }

            System.Windows.Point position = touchPoint.Position;

            if (IsInPullToRefresh)
            {
                double delta = position.Y - _lastPosition.Y;
                PullToRefreshStatus += delta / 150.0;
            }

            _lastPosition = position;
        }
Exemple #7
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;
                }
            }
        }
Exemple #8
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;
            }
        }
        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;
                }
            }
        }
Exemple #10
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);
                }
            }
        }
        //   الداله دى لو الجهاز بتاعك بيدعم التاتش اسكرين

        /*
         * 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);
                    }
                }
            }
        }
Exemple #12
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
            }
        }
Exemple #13
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            TouchPoint mainTouch = e.GetPrimaryTouchPoint(image);

            if (mainTouch.Action == TouchAction.Down)
            {
                first = mainTouch;
            }
            else if (mainTouch.Action == TouchAction.Up)
            {
                if (mainTouch.Position.X - first.Position.X < -350)
                {
                    Touch.FrameReported -= Touch_FrameReported;
                    NavigationService.Navigate(new Uri("/Options.xaml?", UriKind.Relative));
                    client.Send("7");
                }
                else if (mainTouch.Position.Y - first.Position.Y < -150)
                {
                    sendType.Visibility   = Visibility.Visible;
                    SendButton.Visibility = Visibility.Visible;
                    sendType.Focus();
                }
                //myPivot.SelectedIndex--;
            }
        }
Exemple #14
0
 void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     if (!UserData.Instance.IsAuthenticated)
     {
         return;
     }
     UserActivity.Instance.ResetTimer();
 }
 void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     if (e.GetPrimaryTouchPoint(this.FirstPivot_PV).Action == TouchAction.Up)
     {
         //this.pivot.IsHitTestVisible = true;
         //this.pivot.IsLocked = false;
     }
 }
        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
            {
            }
        }
Exemple #17
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (_manipulationStartedArgs == null)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            var point = e.GetPrimaryTouchPoint(null);

            if (point.Action == TouchAction.Up)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            var manipulationPoint = e.GetPrimaryTouchPoint(_manipulationStartedArgs.ManipulationContainer);
            var length            = Math.Pow(manipulationPoint.Position.X - _manipulationStartedArgs.ManipulationOrigin.X, 2.0)
                                    + Math.Pow(manipulationPoint.Position.Y - _manipulationStartedArgs.ManipulationOrigin.Y, 2.0);

            if (length > 30.0 * 30.0)
            {
                Touch.FrameReported -= Touch_FrameReported;
                return;
            }

            if (_startTime.HasValue && _startTime.Value.AddSeconds(0.5) <= DateTime.Now)
            {
                Touch.FrameReported -= Touch_FrameReported;
                VirtPanel.DisableVerticalScrolling();

                _loadedStoryboard = EmojiControl.GetScaleStoryboard(_fromItem, 0.85, 1.0);

                Preview.Visibility = Visibility.Visible;
                var stickerImage = _fromItem as Image;
                if (stickerImage != null)
                {
                    PreviewImage.Source = stickerImage.Source;

                    var stickerItem = stickerImage.DataContext as TLStickerItem;
                    if (stickerItem != null)
                    {
                        Image.DataContext = stickerItem;
                    }
                }

                var grid = Preview;
                grid.Children.Remove(PreviewGrid);

                Execute.BeginOnUIThread(() =>
                {
                    PreviewGrid.RenderTransform = new CompositeTransform();
                    PreviewGrid.Opacity         = 0.0;
                    grid.Children.Add(PreviewGrid);
                });
            }
        }
 private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
 {
     Debug.WriteLine("Touch_FrameReported");
     if (_notYetOpened)
     {
         AttachedProperties.SetLastClickWasTouch(AssociatedObject, true);
         SetExpiration(true);
     }
 }
Exemple #19
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);
            });
        }
        /* 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;
                    }
                }
            }
        }
        /// <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;
            }
        }
Exemple #22
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>
            }
        }
Exemple #23
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();
        }
        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
            }
        }
        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;
                }
            }
        }
        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;
                    }
                }
            }
        }
Exemple #27
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);
                }
            }
        }
Exemple #28
0
        void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            if (TouchPanel.IsGestureAvailable)
            {
                GestureSample gesture = TouchPanel.ReadGesture();

                PageTitle.Text = gesture.GestureType.ToString();

                if (gesture.GestureType == GestureType.Flick)
                {
                    PageTitle.Text += " " + gesture.Delta.ToString();
                }
            }
        }
        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();
            }
        }
        /// <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;
                }
            }
        }