/// <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(); }
/// <summary> /// Creates temporary shapefile, adds it to map and returns layer handle /// </summary> public static int DisplaySelection(this IMuteMap map, IEnvelope ext) { var sf = new FeatureSet(Enums.GeometryType.Polygon); var g = ext.ToGeometry(); sf.Features.EditAdd(g); // will be displayed above labels of other layers sf.Volatile = true; bool oldZoomToFirstLayer = MapConfig.ZoomToFirstLayer; MapConfig.ZoomToFirstLayer = false; int handle = map.Layers.Add(sf, true, false); MapConfig.ZoomToFirstLayer = oldZoomToFirstLayer; var fill = sf.Style.Fill; fill.Color = Color.LightBlue; fill.Transparency = 100; var line = sf.Style.Line; line.Width = 2; line.Color = Color.Blue; line.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; map.Redraw(); return(handle); }
private void RotateSymbol(IMuteMap map, double dx, double dy, bool snapToFeatures = false, bool snapToAxes = false) { var layer = map.GetLayer(CurrentObject.LayerHandle); var fs = layer.FeatureSet; var feature = fs.Features[CurrentObject.ObjectIndex]; if (feature == null) { return; } var projCoordinate = _context.Map.PixelToProj(new Coordinate(dx, dy)); CurrentObject.UpdateRotationField(layer, projCoordinate.X, projCoordinate.Y, snapToFeatures, snapToAxes); map.Redraw(); }
/// <summary> /// Rotates the current symbol /// </summary> private void RotateSymbol(IMuteMap map, double dx, double dy, bool snapToFeatures = false, bool snapToAxes = false) { var layer = map.GetLayer(_currentObject.LayerHandle); var fs = layer.FeatureSet; var feature = fs.Features[_currentObject.ObjectIndex]; if (feature == null) { return; } // Check if the featureset has setup offset x or y fields & store the new offset if so if (_currentObject.HasBackingRotationField) { _currentObject.UpdateRotationField(layer, dx, dy, snapToFeatures, snapToAxes); } map.Redraw(); }
public override bool ViewOkClicked() { if (_map.Layers.Count > 0) { MessageService.Current.Info("Can't change projection when there are layers on the map."); return(false); } var sr = new SpatialReference(); if (_view.Projection == SetProjectionView.ProjectionType.Custom) { if (string.IsNullOrWhiteSpace(_view.CustomProjection)) { MessageService.Current.Info("ProjectionType string is empty."); return(false); } if (!sr.ImportFromAutoDetect(_view.CustomProjection)) { MessageService.Current.Info("Failed to identify projection."); return(false); } } if (_view.Projection == SetProjectionView.ProjectionType.Default) { if (_view.DefaultProjectionIndex == 0) { sr.SetWgs84(); } if (_view.DefaultProjectionIndex == 1) { sr.SetGoogleMercator(); } } _map.Projection = sr; _map.Redraw(); return(true); }
private void Clear() { _currentLabel.Clear(); _map.FocusRectangle.Visible = false; _map.Redraw(RedrawType.Minimal); }
private void Clear() { CurrentObject.Clear(); SnapAngleDrawer.DrawSnapAngles(null, false, false, true); _map.Redraw(RedrawType.Minimal); }