/// <summary>
        /// The mouse leftButton is up
        /// </summary>
        /// <param name="sender">The mapViewModel</param>
        /// <param name="args">The mouse event args</param>
        protected override void OnMouseLeftButtonUp(MapViewModel sender, MapMouseEventArgs args)
        {
            _interactionLayer = args.InteractionLayer;

            // By default, add the coordinate if the mouse was not down
            bool addCoordinate = !IsMouseDown;

            if (IsMouseDown)
            {
                // Only add the coordinate, when there is enough spacing between coordinates
                addCoordinate = Math.Abs(_lastMouseMoveX - _mouseDownX) < 3 && Math.Abs(_lastMouseMoveY - _mouseDownY) < 3;
            }

            // Now, actually add the coordinate
            if (addCoordinate)
            {
                _activeMeasurer.AddCoordinate(new SpatialEye.Framework.Geometry.Coordinate(args.X, args.Y));
            }

            // Mouse is no longer down
            IsMouseDown = false;

            // We have handled the event
            args.Handled = true;
            base.OnMouseLeftButtonUp(sender, args);
        }
Пример #2
0
        /// <summary>
        /// Handler for mouse leftButton down events; records the active state of the mouse
        /// </summary>
        /// <param name="sender">The mapViewModel</param>
        /// <param name="args">The mouse event arguments</param>
        protected override void OnMouseLeftButtonDown(MapViewModel sender, MapMouseEventArgs args)
        {
            _interactionLayer = args.InteractionLayer;

            if (_activeMeasurer.CanMoveScreen)
            {
                IsMouseDown     = true;
                _mouseDownX     = args.X;
                _mouseDownY     = args.Y;
                _lastMouseMoveX = args.X;
                _lastMouseMoveY = args.Y;
            }
        }
Пример #3
0
        /// <summary>
        /// Handle the double click event
        /// </summary>
        /// <param name="sender">The mapViewModel</param>
        /// <param name="args">The mouse event args</param>
        protected override void OnMouseLeftButtonDoubleClick(MapViewModel sender, MapMouseEventArgs args)
        {
            base.OnMouseLeftButtonDoubleClick(sender, args);

            _interactionLayer = args.InteractionLayer;

            // Detiene el trazo y limpia las geometrías
            _interactionLayer.Clear();
            _geometry.Clear();

            // We've handled the double click event
            args.Handled = true;
        }
        /// <summary>
        /// Override for the leftButtonUp event on the Map
        /// </summary>
        protected override async void OnMouseLeftButtonUp(MapViewModel sender, MapMouseEventArgs args)
        {
            /*MapMouseEventArgs resultArgs = null;
            *  var downArgs = _mapButtonDownArgs;
            *  _mapButtonDownArgs = null;
            *
            *  if (downArgs != null && args != null)
            *  {
            *   if (Math.Abs(downArgs.X - args.X) < 5 && Math.Abs(downArgs.Y - args.Y) < 5)
            *   {
            *       resultArgs = args;
            *   }
            *  }
            *
            *  this.LastPressedMouseArgs = resultArgs;
            *
            *  base.OnMouseLeftButtonUp(map, args);*/


            _interactionLayer = args.InteractionLayer;


            // By default, add the coordinate if the mouse was not down
            bool addCoordinate = !IsMouseDown;

            if (IsMouseDown)
            {
                // Only add the coordinate, when there is enough spacing between coordinates
                addCoordinate = Math.Abs(_lastMouseMoveX - _mouseDownX) < 3 && Math.Abs(_lastMouseMoveY - _mouseDownY) < 3;
            }

            // Now, actually add the coordinate
            if (addCoordinate)
            {
                //_activeMeasurer.AddCoordinate(new SpatialEye.Framework.Geometry.Coordinate(args.X, args.Y));

                //_interactionLayer.Clear();
                //_geometry.Clear();

                SpatialEye.Framework.Geometry.Coordinate co = new SpatialEye.Framework.Geometry.Coordinate(args.X, args.Y);

                //Brush estilo = new SolidColorBrush(Colors.Red);

                //_geometry.Add(AnnotationFor(Map.CoordinateSystem, co, 0.0, estilo, 20, 0, TextAlignment.Center, 0));

                var geometryService = ServiceLocator.Current.GetInstance <IGeometryService>();

                SpatialEye.Framework.Geometry.CoordinateSystems.EpsgCoordinateSystemReference WGS84CoordinateSystem = new SpatialEye.Framework.Geometry.CoordinateSystems.EpsgCoordinateSystemReference {
                    SRId = 4326, Name = "WGS 84"
                };
                Map.PixelToWorldTransform.Convert(co);
                //var co2 = await GeometryManager.Instance.TransformAsync(co, Map.CoordinateSystem.EPSGCode, WGS84CoordinateSystem.SRId);
                var co2 = geometryService.TransformAsync(co, Map.CoordinateSystem.EPSGCode, WGS84CoordinateSystem.SRId).Result;

                _strLatitud  = (co2.Y).ToString("00.0000000");
                _strLongitud = (co2.X).ToString("00.0000000");


                //Si es el primer trazo
                if (_viewModel.Latitud == string.Empty && _viewModel.Longitud == string.Empty)
                {
                    _viewModel.Latitud  = _strLatitud.Replace(",", ".");
                    _viewModel.Longitud = _strLongitud.Replace(",", ".");
                }
                else
                {
                    _viewModel.Latitud  = _viewModel.Latitud + "," + _strLatitud.Replace(",", ".");
                    _viewModel.Longitud = _viewModel.Longitud + "," + _strLongitud.Replace(",", ".");
                }


                /*
                 * foreach (var element in _geometry)
                 * {
                 *  _interactionLayer.Add(element);
                 * }*/
            }

            // Mouse is no longer down
            IsMouseDown = false;

            // We have handled the event
            args.Handled = true;
            base.OnMouseLeftButtonUp(sender, args);
        }
Пример #5
0
        /// <summary>
        /// Handler for mouse move events; notifies the active measurer of this
        /// </summary>
        /// <param name="sender">The mapViewModel</param>
        /// <param name="args">The mouse event arguments</param>
        protected override void OnMouseMove(MapViewModel sender, MapMouseEventArgs args)
        {
            _interactionLayer = args.InteractionLayer;

            if (IsMouseDown)
            {
                // In case the mouse is down (and we are moving), we need
                // to move all coordinates of the active measurer
                if (_activeMeasurer != null)
                {
                    var diffX = args.X - _lastMouseMoveX;
                    var diffY = args.Y - _lastMouseMoveY;

                    _activeMeasurer.MoveAll(diffX, diffY);

                    _lastMouseMoveX = args.X;
                    _lastMouseMoveY = args.Y;
                }
            }

            var mouseX = args.X;
            var mouseY = args.Y;

            // Now notify the measurer of the move
            _activeMeasurer.MoveCoordinate(new SpatialEye.Framework.Geometry.Coordinate(args.X, args.Y));

            // In case we are near the boundary of the (physical) map, we can automatically
            // move the map to make space for some new measure points
            int    testPixels    = 10;
            double spacingFactor = 10.0;

            if (_activeMeasurer.CanMoveScreen & !IsMovingMap)
            {
                bool   doMove            = false;
                double measurerToRight   = 0.0;
                double measurerToBottom  = 0.0;
                double measurerXDistance = 0.0;
                double measurerYDistance = 0.0;

                if (mouseX < testPixels + LeftMargin)
                {
                    // Near the left of the Map, move Map to the Right
                    doMove            = true;
                    measurerToRight   = sender.DeviceWidth / spacingFactor;
                    measurerXDistance = -sender.Envelope.Width / spacingFactor;
                }
                else if (mouseY < testPixels + TopMargin)
                {
                    // Near the top of the Map, move Map to the Bottom
                    doMove            = true;
                    measurerToBottom  = sender.DeviceHeight / spacingFactor;
                    measurerYDistance = sender.Envelope.Height / spacingFactor;
                }
                else if (mouseX >= sender.DeviceWidth - testPixels - RightMargin)
                {
                    // Near the right of the Map, move Map to the Left
                    doMove            = true;
                    measurerToRight   = -sender.DeviceWidth / spacingFactor;
                    measurerXDistance = sender.Envelope.Width / spacingFactor;
                }
                else if (mouseY >= sender.DeviceHeight - testPixels - BottomMargin)
                {
                    // Near the bottom of the Map, map to the Top
                    doMove            = true;
                    measurerToBottom  = -sender.DeviceHeight / spacingFactor;
                    measurerYDistance = -sender.Envelope.Height / spacingFactor;
                }

                if (doMove)
                {
                    // Move the lot
                    IsMovingMap = true;
                    _activeMeasurer.MoveAll(measurerToRight, measurerToBottom);
                    sender.SetCentre(new Coordinate(sender.Centre.X + measurerXDistance, sender.Centre.Y + measurerYDistance), false);
                }
                else if (!sender.IsAnimating)
                {
                    IsMovingMap = false;
                }
            }
            else if (!sender.IsAnimating)
            {
                IsMovingMap = false;
            }

            args.Handled = !IsMouseDown;
            base.OnMouseMove(sender, args);
        }