/// <summary> /// Handler for changes in the active measurer's geometry /// </summary> /// <param name="sender">The sender of the changed geometry</param> /// <param name="geometry">The new geometry</param> void MeasurerFeatureGeometryChanged(LiteMapMeasurerBase sender, System.Collections.Generic.List <FrameworkElement> geometry) { if (_interactionLayer != null) { _interactionLayer.Clear(); foreach (var element in geometry) { _interactionLayer.Add(element); } } }
/// <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> /// The mouse leftButton is up /// </summary> /// <param name="sender">The mapViewModel</param> /// <param name="args">The mouse event args</param> 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) { _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; // _viewModel.Longitud = _viewModel.Longitud + "," + _strLongitud; // } 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); }