protected override async void OnToolMouseMove(MapViewMouseEventArgs e) { if (_lastLocation == e.ClientPoint) { return; } _lastLocation = e.ClientPoint; _invoker.Invoke(async() => { var tuple = await AddFeatureToOverlay(e); lock (_lock) { long oid = tuple.Item2; if (oid >= 0) { _theInspector.LoadAsync(_trees, oid); } else { _theInspector.ClearAsync(); } if (_disposer != null) { _disposer.Dispose(); } _disposer = tuple.Item1; } }); }
private Task <Tuple <IDisposable, long> > AddFeatureToOverlay(MapViewMouseEventArgs e) { return(QueuedTask.Run(() => { double llx = e.ClientPoint.X - 3; double lly = e.ClientPoint.Y - 3; double urx = e.ClientPoint.X + 3; double ury = e.ClientPoint.Y + 3; EnvelopeBuilder envBuilder = new EnvelopeBuilder(ActiveMapView.ClientToMap(new Point(llx, lly)), ActiveMapView.ClientToMap(new Point(urx, ury))); MapPoint mp = ActiveMapView.ClientToMap(e.ClientPoint); var cursor = _trees.Search(new SpatialQueryFilter() { FilterGeometry = envBuilder.ToGeometry(), SpatialRelationship = SpatialRelationship.Intersects }); if (cursor.MoveNext()) { return new Tuple <IDisposable, long>( ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint), _overlaySymbol.MakeSymbolReference()), cursor.Current.GetObjectID()); } //var select = _trees.Select(new SpatialQueryFilter() { // FilterGeometry = envBuilder.ToGeometry(), // SpatialRelationship = SpatialRelationship.Intersects //}); //if (select.GetCount() > 0) { // return ActiveMapView.AddOverlay(ActiveMapView.ClientToMap(e.ClientPoint), _overlaySymbol.MakeSymbolReference()); //} return new Tuple <IDisposable, long>(null, -1); })); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { var vm = FrameworkApplication.DockPaneManager.Find("ProAppCoordConversionModule_CoordinateConversionDockpane") as CoordinateConversionDockpaneViewModel; if (vm != null) { vm.IsHistoryUpdate = false; } UpdateInputWithMapPoint(e.ClientPoint); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { //Only do this for 2D view if (MapView.Active.ViewingMode != ArcGIS.Core.CIM.MapViewingMode.Map) return; base.OnToolMouseMove(e); //Offset the map control window so right edge of the window is to the left and slightly offset from the mouse position in the main map view mapControlWindow.Left = MapView.Active.ClientToScreen(e.ClientPoint).X - mapControlWindow.Width - 30; mapControlWindow.Top = e.ClientPoint.Y; mapControlWindow.viewModel.UpdateMapControlCamera(e.ClientPoint); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { // try a subject here to limit the amount of times this is handled mouseSubject.OnNext(e); } catch (Exception ex) { } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { // try a subject here to limit the amount of times this is handled mouseSubject.OnNext(e); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { // try a subject here to limit the amount of times this is handled mouseSubject.OnNext(e); } catch(Exception ex) { } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { //Only do this for 2D view if (MapView.Active.ViewingMode != ArcGIS.Core.CIM.MapViewingMode.Map) { return; } base.OnToolMouseMove(e); //Offset the map control window so right edge of the window is to the left and slightly offset from the mouse position in the main map view mapControlWindow.Left = MapView.Active.ClientToScreen(e.ClientPoint).X - mapControlWindow.Width - 30; mapControlWindow.Top = e.ClientPoint.Y; mapControlWindow.viewModel.UpdateMapControlCamera(e.ClientPoint); }
/// <summary> /// Method to handle the Tool Mouse Move event /// Get MapPoint from ClientPoint and notify /// </summary> /// <param name="e">MapViewMouseEventArgs</param> protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { QueuedTask.Run(() => { var mp = MapView.Active.ClientToMap(e.ClientPoint); Mediator.NotifyColleagues(VisibilityLibrary.Constants.MOUSE_MOVE_POINT, mp); }); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { if (_active) { QueuedTask.Run(() => { _counter++; if (_counter % 10 == 0) { MapView.Active.LookAtAsync(ActiveMapView.ClientToMap(e.ClientPoint), new TimeSpan(0, 0, 0, 0, 15)); _counter = 0; } }); } e.Handled = true; }
/// <summary> /// Method to handle the Tool Mouse Move event /// Get MapPoint from ClientPoint and notify /// </summary> /// <param name="e">MapViewMouseEventArgs</param> protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { QueuedTask.Run(() => { var mp = MapView.Active.ClientToMap(e.ClientPoint); Mediator.NotifyColleagues(VisibilityLibrary.Constants.MOUSE_MOVE_POINT, mp); }); } catch (Exception ex) { // do nothing } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { try { //lets limit how many times we call this // take the latest event args every so often // this will keep us from drawing too many feedback geometries _throttleMouse.ThrottleAndFireAtInterval(150, async(args) => { var mp = await QueuedTask.Run(() => MapView.Active.ClientToMap(e.ClientPoint)); Mediator.NotifyColleagues(DistanceAndDirectionLibrary.Constants.MOUSE_MOVE_POINT, mp); }, priority: DispatcherPriority.Normal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } base.OnToolMouseMove(e); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { // bIsMouseMoveActive is preventing the creation of too many threads via QueuedTask.Run // especially if imagery is via a remote service if (bIsMouseMoveActive) { return; } bIsMouseMoveActive = true; MapPoint map_point = null; // IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); Task t = QueuedTask.Run(() => { map_point = MapView.Active.ClientToMap(e.ClientPoint); }); t.Wait(); pane.PositionLabel = string.Format("{0:0.###} {1:0.###}", map_point.X, map_point.Y); bIsMouseMoveActive = false; }
protected override async void OnToolMouseMove(MapViewMouseEventArgs e) { //All of this logic is to avoid unnecessarily updating the graphic position //for ~every~ mouse move. We skip any "intermediate" points in-between rapid //mouse moves. lock (_lock) { if (_trackingMouseMove == TrackingState.NotTracking) return; else { if (_workingLocation.HasValue) { _lastLocation = e.ClientPoint; return; } else { _lastLocation = e.ClientPoint; _workingLocation = e.ClientPoint; } } _trackingMouseMove = TrackingState.Tracking; } //The code "inside" the QTR will execute for all points that //get "buffered" or "queued". This avoids having to spin up a QTR //for ~every~ point of ~every mouse move. await QueuedTask.Run(() => { var symReference = _pointSymbol.MakeSymbolReference(); while (true) { System.Windows.Point? point; Polyline lineFeature = null; IDisposable graphic = null; lock (_lock) { point = _lastLocation; _lastLocation = null; _workingLocation = point; if (point == null || !point.HasValue) {//No new points came in while we updated the overlay _workingLocation = null; break; } else if (_lineFeature == null || _graphic == null) {//conflict with the mouse down, //If this happens then we are done. A new line and point will be //forthcoming from the SketchCompleted callback _trackingMouseMove = TrackingState.NotTracking; break; } lineFeature = _lineFeature; graphic = _graphic; } //update the graphic overlay var nearest = GeometryEngine.NearestPoint(lineFeature, MapView.Active.ClientToMap(point.Value)); this.UpdateOverlay(graphic, nearest.Point, symReference); } }); }
protected override async void OnToolMouseMove(MapViewMouseEventArgs e) { //All of this logic is to avoid unnecessarily updating the graphic position //for ~every~ mouse move. We skip any "intermediate" points in-between rapid //mouse moves. lock (_lock) { if (_trackingMouseMove == TrackingState.NotTracking) { return; } else { if (_workingLocation.HasValue) { _lastLocation = e.ClientPoint; return; } else { _lastLocation = e.ClientPoint; _workingLocation = e.ClientPoint; } } _trackingMouseMove = TrackingState.Tracking; } //The code "inside" the QTR will execute for all points that //get "buffered" or "queued". This avoids having to spin up a QTR //for ~every~ point of ~every mouse move. await QueuedTask.Run(() => { var symReference = _pointSymbol.MakeSymbolReference(); while (true) { System.Windows.Point?point; Polyline lineFeature = null; IDisposable graphic = null; lock (_lock) { point = _lastLocation; _lastLocation = null; _workingLocation = point; if (point == null || !point.HasValue) //No new points came in while we updated the overlay { _workingLocation = null; break; } else if (_lineFeature == null || _graphic == null) //conflict with the mouse down, //If this happens then we are done. A new line and point will be //forthcoming from the SketchCompleted callback { _trackingMouseMove = TrackingState.NotTracking; break; } lineFeature = _lineFeature; graphic = _graphic; } //update the graphic overlay var nearest = GeometryEngine.Instance.NearestPoint(lineFeature, MapView.Active.ClientToMap(point.Value)); this.UpdateOverlay(graphic, nearest.Point, symReference); } }); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { UpdateInputWithMapPoint(e.ClientPoint); }
protected override void OnToolMouseMove(MapViewMouseEventArgs e) { if (_selectedRaster == null) { return; } // bIsMouseMoveActive is preventing the creation of too many threads via QueuedTask.Run // especially if imagery is via a remote service if (bIsMouseMoveActive) { return; } bIsMouseMoveActive = true; System.Diagnostics.Debug.WriteLine($@"{DateTime.Now} OnToolMouseMove"); QueuedTask.Run(() => { try { // create a pixelblock representing a 3x3 window to hold the raster values var pixelBlock = _selectedRaster.CreatePixelBlock(3, 3); // determine the cursor position in mapping coordinates var clientCoords = new System.Windows.Point(e.ClientPoint.X, e.ClientPoint.Y); if (clientCoords == null || ActiveMapView == null) { return; } var mapPointAtCursor = ActiveMapView.ClientToMap(clientCoords); if (mapPointAtCursor == null) { return; } // create a container to hold the pixel values Array pixelArray = new object[pixelBlock.GetWidth(), pixelBlock.GetHeight()]; // reproject the raster envelope to match the map spatial reference var rasterEnvelope = GeometryEngine.Instance.Project(_selectedRaster.GetExtent(), mapPointAtCursor.SpatialReference); // if the cursor is within the extent of the raster if (GeometryEngine.Instance.Contains(rasterEnvelope, mapPointAtCursor)) { // find the map location expressed in row,column of the raster var pixelLocationAtRaster = _selectedRaster.MapToPixel(mapPointAtCursor.X, mapPointAtCursor.Y); // fill the pixelblock with the pointer location _selectedRaster.Read(pixelLocationAtRaster.Item1, pixelLocationAtRaster.Item2, pixelBlock); if (_bandindex != -1) { // retrieve the actual pixel values from the pixelblock representing the red raster band pixelArray = pixelBlock.GetPixelData(_bandindex, false); } } else { // fill the container with 0s Array.Clear(pixelArray, 0, pixelArray.Length); } // pass the pass the raster values to the view model RasterValuesPaneViewModel.Current.RasterValues = ConvertArray(pixelArray); } finally { bIsMouseMoveActive = false; } }); }