/// <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>
        /// 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);
         * }
         */
        protected override async 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));

                //_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);
        }