public void GetProjectedEventDelta(IMuteMap map, MouseEventArgs e, out double dx, out double dy) { map.PixelToProj(X, Y, out double x1, out double y1); map.PixelToProj(e.X, e.Y, out double x2, out double y2); dx = -x1 + x2; dy = -y1 + y2; }
/// <summary> /// Finishes the label moving operation. /// </summary> private void MapMouseUp(IMuteMap map, MouseEventArgs e) { if (!Active || _currentLabel.LayerHandle == -1) { return; } if (e.X == _currentLabel.X || e.Y == _currentLabel.Y) { Clear(); return; } // check that new position is within map if (e.X < 0 || e.Y < 0 || e.X > map.Width || e.Y > map.Height) { Clear(); return; } var fs = map.GetFeatureSet(_currentLabel.LayerHandle); if (_currentLabel.IsChart) { var chart = fs.Diagrams[_currentLabel.LabelIndex]; if (chart != null) { double x1, x2, y1, y2; map.PixelToProj(_currentLabel.X, _currentLabel.Y, out x1, out y1); map.PixelToProj(e.X, e.Y, out x2, out y2); chart.PositionX = chart.PositionX - x1 + x2; chart.PositionY = chart.PositionY - y1 + y2; fs.Diagrams.SavingMode = PersistenceType.XmlOverwrite; // .chart file should be overwritten _context.Project.SetModified(); map.Redraw(); } } else { var lb = fs.Labels.Items[_currentLabel.LabelIndex, _currentLabel.PartIndex]; if (lb != null) { double x1, x2, y1, y2; map.PixelToProj(_currentLabel.X, _currentLabel.Y, out x1, out y1); map.PixelToProj(e.X, e.Y, out x2, out y2); lb.X = lb.X - x1 + x2; lb.Y = lb.Y - y1 + y2; fs.Labels.SavingMode = PersistenceType.XmlOverwrite; // .lbl file should be overwritten _context.Project.SetModified(); map.Redraw(); } } Clear(); }
public void OffsetShapes(IFeatureSet fs, double screenOffsetX, double screenOffsetY) { double x1, x2, y1, y2; _map.PixelToProj(0.0, 0.0, out x1, out y1); _map.PixelToProj(screenOffsetX, screenOffsetY, out x2, out y2); foreach (var ft in fs.Features) { ft.Geometry.Move(x2 - x1, y2 - y1); } }
private ObjectRotateData FindRotatebleItem(int x, int y) { foreach (var layer in _map.Layers.ToList()) { if (layer == null || !layer.IsVector || layer.FeatureSet == null) { continue; } if (layer.FeatureSet.GeometryType != GeometryType.Point) { continue; } var fs = layer.FeatureSet; var env = new Envelope(); _map.PixelToProj(x, y, out double projX, out double projY); env.SetBounds(new Coordinate(projX, projY), (_map as IMuteMap).GetProjectedMouseTolerance(), (_map as IMuteMap).GetProjectedMouseTolerance()); // Try to find a point feature if (FindPointFeature(fs, env) is int featureIndex) { return(CreateObjectRotateDataForPoint(x, y, _map, layer, featureIndex)); } } return(null); }
/// <remarks> /// TODO: think of a better place for it to allow reuse /// </remarks> private void DisplayCurrentPixelValue(IMuteMap map, int pixelX, int pixelY) { var layer = map.Layers.Current; if (layer == null) { return; } var raster = layer.Raster; if (raster == null) { return; } if (raster.RenderingType == RasterRendering.Rgb) { return; } double projX, projY; map.PixelToProj(pixelX, pixelY, out projX, out projY); int column, row; if (raster.ProjectionToImage(projX, projY, out column, out row)) { var band = raster.ActiveBand; double value; if (band.GetValue(column, row, out value)) { string msg = string.Format("Raster info. Row: {0}; Column: {1}; Value: {2}", row, column, value); _context.StatusBar.ShowInfo(msg); } } else { _context.StatusBar.ShowInfo(""); } }
public static double GetProjectedMouseTolerance(this IMuteMap map) { map.PixelToProj(0, 0, out double x1, out double _); map.PixelToProj(MapConfig.MouseTolerance, 0, out double x2, out _); return(Math.Abs(x1 - x2)); }