Exemplo n.º 1
0
        /// <summary>
        /// Called, when mouse/finger/pen click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchStart(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            // We have a new interaction with the screen, so stop all navigator animations
            Navigator.StopRunningAnimation();

            var args = new TouchedEventArgs(touchPoints);

            TouchStarted?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            if (touchPoints.Count == 2)
            {
                (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                _mode          = TouchMode.Zooming;
                _innerRotation = Viewport.Rotation;
            }
            else
            {
                _mode           = TouchMode.Dragging;
                _previousCenter = touchPoints.First();
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called, when mouse/finger/pen click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchStart(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            var args = new TouchedEventArgs(touchPoints);

            TouchStarted?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            if (touchPoints.Count == 2)
            {
                (_previousCenter, _previousRadius, _previousAngle) = GetPinchValues(touchPoints);
                _mode          = TouchMode.Zooming;
                _innerRotation = Viewport.Rotation;
            }
            else
            {
                _mode           = TouchMode.Dragging;
                _previousCenter = touchPoints.First();
            }

            return(true);
        }
Exemplo n.º 3
0
        public async Task MapTouchStarted(object sender, TouchedEventArgs e)
        {
            // if we have a touch start, all move and TouchEnd events are processed
            // this can be:
            //  - a new user action (click, doubleClick, drag, longTap)
            //  - a second click following a first TouchStart, (move .... ), TouchEnd

            if (!waitingFirstTimer && !waitingSecondTimerForClick)
            {
                TouchMoveCount = 0;

                userActionCompleted = false;

                touchEndInsideFirsTimerOccured           = false;
                touchEndInsideSecondTimerForClickOccured = false;

                secondTouchStartedInsideFirsTimerOccured             = false;
                secondTouchStartedInsideSecondClickTimerTimerOccured = false;

                waitingFirstTimer          = true;
                waitingSecondTimerForClick = false;

                savedSender           = sender;
                savedTouchedEventArgs = e;

                Logger.Clear();

                Logger.Log($" MapTouchStarted : First MapTouch\r\n\t Double Tap Enabled = {((MapControl)sender).UseDoubleTap} ;  MapInfo Enabled = {IsMapInfoLayer}\r\n\t starting first timer for {RBGlobals.RBG_MillisecondsBeforeDragging} ms");

                Device.StartTimer(TimeSpan.FromMilliseconds(RBGlobals.RBG_MillisecondsBeforeDragging), MapTouchFirstTimerHandler);

                Device.StartTimer(TimeSpan.FromMilliseconds(2000), () =>
                {
                    Logger.WriteToDebugLabel(RBG_DebugLabel);
                    // logger.FlushOnDiagnosticDebug();
                    return(false);
                });
            }
            else
            {
                if (waitingFirstTimer)
                {
                    Logger.Log($" MapTouchStarted : Second mapTouch during the first timer period");
                    secondTouchStartedInsideFirsTimerOccured = true;
                }
                else if (waitingSecondTimerForClick)
                {
                    Logger.Log($" MapTouchStarted : Second mapTouch during the second timer period (waiting for second click)");
                    secondTouchStartedInsideSecondClickTimerTimerOccured = true;
                }
                else
                {
                    throw new Exception("RBLayer: MapTouchStarted : Having both timers active is not possible, there is a fault in the logic !");
                }
            }
        }
Exemplo n.º 4
0
        private void MapControlOnTouchEnded(object sender, TouchedEventArgs e)
        {
            if (polyDraw == null)
            {
                return;
            }
            //MapMarkersLayer.Delayer.MillisecondsToWait = 500;
            GameState.Instance.marker.CreateMarker(polyDraw);
            var markerProvider = MapMarkersLayer.DataSource as MapMarkerProvider;

            markerProvider?.RemoveMarker(polyDraw.id);
            polyDraw = null;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called when touch enters map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchEntered(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            var args = new TouchedEventArgs(touchPoints);

            TouchEntered?.Invoke(this, args);

            return(args.Handled);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                _mode = TouchMode.None;
                _map.RefreshData(_viewport.Extent, _viewport.Resolution, true);
            }

            return(args.Handled);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Called, when mouse/finger/pen anymore click/touch map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        /// <param name="releasedPoint">Released point, which was touched before</param>
        private bool OnTouchEnd(List <Geometries.Point> touchPoints, Geometries.Point releasedPoint)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchEnded?.Invoke(this, args);

            // Last touch released
            if (touchPoints.Count == 0)
            {
                InvalidateCanvas();
                _mode = TouchMode.None;
                _map.ViewChanged(true);
            }

            return(args.Handled);
        }
Exemplo n.º 8
0
        private void MapControlOnMouseMove(object sender, TouchedEventArgs e)
        {
            if (polyDraw == null)
            {
                return;
            }

            var info = MapControl.GetMapInfo(e.ScreenPoints.First(), 12);

            var lastPos = polyDraw.polyline.Last();


            if (new Point(lastPos[0], lastPos[1]).Distance(new Point(info.WorldPosition.X, info.WorldPosition.Y)) > 5)
            {
                polyDraw.polyline.Add(new float[] { (float)info.WorldPosition.X, (float)info.WorldPosition.Y });
                MapMarkersLayer.DataHasChanged();
            }
        }
Exemplo n.º 9
0
        private void MapControlOnMouseLeftButtonDown(object sender, TouchedEventArgs e)
        {
            var info = MapControl.GetMapInfo(e.ScreenPoints.First(), 12);

            //GPSEditPopup.IsOpen = false;
            if (info.Feature is GPSTrackerFeature gpsTrackerFeature)
            {
                //GPSEdit.Tracker = gpsTrackerFeature.Tracker;
                //GPSEditPopup.Placement = PlacementMode.Mouse;
                //GPSEditPopup.StaysOpen = false;
                //GPSEditPopup.AllowsTransparency = true;
                //GPSEditPopup.IsOpen = true;
                //e.Handled = true;
            }

            if (polyDraw == null && CanDraw)
            {
                polyDraw = new ActiveMarker
                {
                    id      = GameState.Instance.marker.GenerateMarkerName(MarkerChannel.Global),
                    channel = 0,
                    color   = "ColorBlack",
                    type    = "hd_dot",
                    shape   = "POLYLINE",
                    text    = "",
                    size    = "1,1",
                    alpha   = 1,
                    dir     = 0,
                    brush   = "Solid"
                };

                polyDraw.pos.Clear();
                polyDraw.pos.Add((float)info.WorldPosition.X);
                polyDraw.pos.Add((float)info.WorldPosition.Y);

                polyDraw.polyline.Add(new float[] { (float)info.WorldPosition.X, (float)info.WorldPosition.Y });

                var markerProvider = MapMarkersLayer.DataSource as MapMarkerProvider;
                markerProvider?.AddMarker(polyDraw, false);
                MapMarkersLayer.DataHasChanged();
            }
        }
Exemplo n.º 10
0
 public async Task MapTouchEnd(object sender, TouchedEventArgs e)
 {
     if (waitingFirstTimer)
     {
         touchEndInsideFirsTimerOccured = true;
         Logger.Log($" MapTouchEnd : Occured during first timer");
     }
     else if (waitingSecondTimerForClick)
     {
         touchEndInsideSecondTimerForClickOccured = true;
         Logger.Log($" MapTouchEnd : Occured during second timer");
     }
     else if (userActionCompleted == true)
     {
         Logger.Log($" MapTouchEnd : MapTouchEnd occured with no timer active and useraction terminated !");
     }
     else
     {
         Logger.Log($" MapTouchEnd : MapTouchEnd occured with no timer active and useraction still pending !");
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Called when touch enters map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchEntered(List <Geometries.Point> touchPoints)
        {
            // Sanity check
            if (touchPoints.Count == 0)
            {
                return(false);
            }

            var args = new TouchedEventArgs(touchPoints);

            TouchEntered?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            // We have an interaction with the screen, so stop all animations
            Navigator.StopRunningAnimation();

            return(true);
        }
Exemplo n.º 12
0
 private async void MapTouchEnded(object sender, TouchedEventArgs e)
 {
     await RBLayer.MapTouchEnd(sender, e);
 }
Exemplo n.º 13
0
 private async void MapTouchMouve(object sender, TouchedEventArgs e)
 {
     await RBLayer.MapTouchMove(sender, e);
 }
Exemplo n.º 14
0
 private async Task MapLongTapEndOrDraggingStarted(object sender, TouchedEventArgs e)
 {
     // no touchend since delay sarted, we assume it is drag !
     Logger.Log($" MapLongTapEndOrDraggingStarted : TODO Handle lonTap versus drag ....");
     //await ((IRBLayer)this).LayerTouchStarted(sender, e);
 }
Exemplo n.º 15
0
 public async Task MapTouchMove(object sender, TouchedEventArgs e)
 {
     TouchMoveCount++;
     Logger.Log($" MapTouchMove # {TouchMoveCount} : ");
 }
Exemplo n.º 16
0
        /// <summary>
        /// Called, when mouse/finger/pen moves over map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchMove(List <Geometries.Point> touchPoints)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchMove?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            switch (_mode)
            {
            case TouchMode.Dragging:
            {
                if (touchPoints.Count != 1)
                {
                    return(false);
                }

                var touchPosition = touchPoints.First();

                if (!Map.PanLock && _previousCenter != null && !_previousCenter.IsEmpty())
                {
                    _viewport.Transform(touchPosition, _previousCenter);

                    RefreshGraphics();
                }

                _previousCenter = touchPosition;
            }
            break;

            case TouchMode.Zooming:
            {
                if (touchPoints.Count != 2)
                {
                    return(false);
                }

                var(prevCenter, prevRadius, prevAngle) = (_previousCenter, _previousRadius, _previousAngle);
                var(center, radius, angle)             = GetPinchValues(touchPoints);

                double rotationDelta = 0;

                if (!Map.RotationLock)
                {
                    _innerRotation += angle - prevAngle;
                    _innerRotation %= 360;

                    if (_innerRotation > 180)
                    {
                        _innerRotation -= 360;
                    }
                    else if (_innerRotation < -180)
                    {
                        _innerRotation += 360;
                    }

                    if (Viewport.Rotation == 0 && Math.Abs(_innerRotation) >= Math.Abs(UnSnapRotationDegrees))
                    {
                        rotationDelta = _innerRotation;
                    }
                    else if (Viewport.Rotation != 0)
                    {
                        if (Math.Abs(_innerRotation) <= Math.Abs(ReSnapRotationDegrees))
                        {
                            rotationDelta = -Viewport.Rotation;
                        }
                        else
                        {
                            rotationDelta = _innerRotation - Viewport.Rotation;
                        }
                    }
                }

                _viewport.Transform(center, prevCenter, Map.ZoomLock ? 1 : radius / prevRadius, rotationDelta);

                (_previousCenter, _previousRadius, _previousAngle) = (center, radius, angle);

                RefreshGraphics();
            }
            break;
            }

            return(true);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Called, when mouse/finger/pen moves over map
        /// </summary>
        /// <param name="touchPoints">List of all touched points</param>
        private bool OnTouchMove(List <Geometries.Point> touchPoints)
        {
            var args = new TouchedEventArgs(touchPoints);

            TouchMove?.Invoke(this, args);

            if (args.Handled)
            {
                return(true);
            }

            switch (_mode)
            {
            case TouchMode.Dragging:
            {
                if (touchPoints.Count != 1)
                {
                    return(false);
                }

                var touchPosition = touchPoints.First();

                if (_previousCenter != null && !_previousCenter.IsEmpty())
                {
                    _map.Viewport.Transform(touchPosition.X, touchPosition.Y, _previousCenter.X, _previousCenter.Y);

                    ViewportLimiter.LimitExtent(_map.Viewport, _map.PanMode, _map.PanLimits, _map.Envelope);

                    InvalidateCanvas();
                }

                _previousCenter = touchPosition;
            }
            break;

            case TouchMode.Zooming:
            {
                if (touchPoints.Count < 2)
                {
                    return(false);
                }

                var(prevCenter, prevRadius, prevAngle) = (_previousCenter, _previousRadius, _previousAngle);
                var(center, radius, angle)             = GetPinchValues(touchPoints);

                double rotationDelta = 0;

                if (RotationLock)
                {
                    _innerRotation += angle - prevAngle;
                    _innerRotation %= 360;

                    if (_innerRotation > 180)
                    {
                        _innerRotation -= 360;
                    }
                    else if (_innerRotation < -180)
                    {
                        _innerRotation += 360;
                    }

                    if (_map.Viewport.Rotation == 0 && Math.Abs(_innerRotation) >= Math.Abs(UnSnapRotationDegrees))
                    {
                        rotationDelta = _innerRotation;
                    }
                    else if (_map.Viewport.Rotation != 0)
                    {
                        if (Math.Abs(_innerRotation) <= Math.Abs(ReSnapRotationDegrees))
                        {
                            rotationDelta = -_map.Viewport.Rotation;
                        }
                        else
                        {
                            rotationDelta = _innerRotation - _map.Viewport.Rotation;
                        }
                    }
                }

                _map.Viewport.Transform(center.X, center.Y, prevCenter.X, prevCenter.Y, radius / prevRadius, rotationDelta);

                (_previousCenter, _previousRadius, _previousAngle) = (center, radius, angle);

                ViewportLimiter.Limit(_map.Viewport,
                                      _map.ZoomMode, _map.ZoomLimits, _map.Resolutions,
                                      _map.PanMode, _map.PanLimits, _map.Envelope);

                InvalidateCanvas();
            }
            break;
            }

            return(true);
        }