public SymbolRotateData(IMuteMap map, int layerHandle, int objectIndex) { Map = map; LayerHandle = layerHandle; ObjectIndex = objectIndex; CalculateSnapAngles(); }
internal 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; }
private void OnMapCursorChanged(IMuteMap map, EventArgs e) { if (map.MapCursor == Api.Enums.MapCursor.AddShape || map.MapCursor == Api.Enums.MapCursor.EditShape) { return; } _anchorService.UserAnchorLocation = null; }
private void OnChooseLayer(IMuteMap map, ChooseLayerEventArgs e) { var layer = map.Layers.Current; if (layer != null) { e.LayerHandle = layer.Handle; } }
/// <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> /// The plugin on choose layer. /// </summary> /// <param name="map">The map.</param> /// <param name="e">The ChooseLayer EventArgs.</param> private void PluginOnChooseLayer(IMuteMap map, ChooseLayerEventArgs e) { if (e.LayerHandle == -1) { return; } _sampleDockWindow.Write( "MapListener.PluginOnChooseLayer", "Selected layer name: " + Path.GetFileName(_context.Layers.ItemByHandle(e.LayerHandle).Filename)); }
public SymbolRotater(IAppContext context, SymbologyPlugin plugin) { _context = context ?? throw new ArgumentNullException("context"); _plugin = plugin ?? throw new ArgumentNullException("plugin"); _map = context.Map; _currentObject = new SymbolRotateData(_map, -1, -1); plugin.MouseDown += MapMouseDown; plugin.MouseUp += MapMouseUp; plugin.MouseMove += MapMouseMove; }
private void plugin_MouseMove(IMuteMap map, System.Windows.Forms.MouseEventArgs e) { if (map.MapCursor != Api.Enums.MapCursor.Identify) { return; } if (_identifierPresenter.View.Mode == IdentifierMode.CurrentLayer /*&& _configService.Config.ShowValuesOnMouseMove*/) { DisplayCurrentPixelValue(map, e.X, e.Y); } }
private void SaveRotation(IMuteMap map) { var layer = map.GetLayer(CurrentObject.LayerHandle); var fs = layer.FeatureSet; var feature = fs.Features[CurrentObject.ObjectIndex]; if (feature == null) { return; } CurrentObject.SaveRotationField(layer); }
public CopyOperation(IMuteMap map, IGeoprocessingService geoService) { if (map == null) { throw new ArgumentNullException("map"); } if (geoService == null) { throw new ArgumentNullException("geoService"); } _map = map; _geoService = geoService; }
private void MapMouseMove(IMuteMap map, MouseEventArgs e) { var ctrlDown = Control.ModifierKeys.HasFlag(Keys.Control); var shiftDown = Control.ModifierKeys.HasFlag(Keys.Shift); SnapAngleDrawer.DrawSnapAngles(CurrentObject, shiftDown, ctrlDown); if (!Active || CurrentObject.LayerHandle == -1) { return; } RotateSymbol(map, e.X, e.Y, shiftDown, ctrlDown); }
public SetScaleView(IMuteMap map) { if (map == null) { throw new ArgumentNullException("map"); } _map = map; InitializeComponent(); InitControls(); FormClosed += (s, e) => _snapToZoomLevels = chkSnap.Checked; }
public SymbolRotater(IAppContext context, SymbologyPlugin plugin) { _context = context ?? throw new ArgumentNullException("context"); _map = context.Map; SnapAngleDrawer = new SnapAngleDrawer(_map, _context.Config); CurrentObject = new SymbolRotateData(_map, -1, -1, 0, 0); plugin.MouseDown += MapMouseDown; plugin.MouseUp += MapMouseUp; plugin.MouseMove += MapMouseMove; plugin.ExtentsChanged += MapExtentsChanged; }
private void MapMouseMove(IMuteMap map, MouseEventArgs e) { if (!Active || _currentObject.LayerHandle == -1) { return; } if (e.X != _currentObject.X || e.Y != _currentObject.Y) { _currentObject.GetEventDelta(e, out double dx, out double dy); var r = _currentObject.Rect.CloneWithOffset((int)dx, (int)dy); DrawLabelRectangle(r); } }
private void OnMapMouseUp(IMuteMap map, MouseEventArgs e) { bool rightClick = e.Button == MouseButtons.Right; if (rightClick) { _context.Map.PixelToProj(e.X, e.Y, out double mapX, out double mapY); _anchorService.UserAnchorLocation = new Coordinate(mapX, mapY); _contextMenuExtender.UpdateStates(); } else { _snapRestrictionService.HandleMapMouseUp(); } }
private void MapMouseMove(IMuteMap map, MouseEventArgs e) { if (!Active || _currentLabel.LayerHandle == -1) { return; } if (e.X != _currentLabel.X || e.Y != _currentLabel.Y) { int dx = -_currentLabel.X + e.X; int dy = -_currentLabel.Y + e.Y; var r = _currentLabel.Rect.CloneWithOffset(dx, dy); DrawLabelRectangle(r); } }
/// <summary> /// Start the dragging operation. /// </summary> private void MapMouseDown(IMuteMap map, MouseEventArgs e) { if (!Active) { return; } var data = FindRotatebleItem(e.X, e.Y); if (data == null) { return; } _currentObject = data; }
private LabelMoveData _currentLabel = new LabelMoveData(); // The label being moved currently public LabelMover(IAppContext context, SymbologyPlugin plugin) { if (context == null) { throw new ArgumentNullException("context"); } if (plugin == null) { throw new ArgumentNullException("plugin"); } _context = context; _plugin = plugin; _map = context.Map; plugin.MouseDown += MapMouseDown; plugin.MouseUp += MapMouseUp; plugin.MouseMove += MapMouseMove; }
private void MapMouseMove(IMuteMap map, MouseEventArgs e) { if (!Active || _currentObject.LayerHandle == -1) { return; } if (e.X == _currentObject.X && e.Y == _currentObject.Y) { return; } var ctrlDown = Control.ModifierKeys.HasFlag(Keys.Control); var shiftDown = Control.ModifierKeys.HasFlag(Keys.Shift); // Move the object RotateSymbol(map, e.X, e.Y, shiftDown, ctrlDown); }
private void MapMouseDown(IMuteMap map, MouseEventArgs e) { if (Active && CurrentObject.LayerHandle == -1) { var data = FindRotatebleItem(e.X, e.Y); if (data == null) { return; } CurrentObject = data; } var ctrlDown = Control.ModifierKeys.HasFlag(Keys.Control); var shiftDown = Control.ModifierKeys.HasFlag(Keys.Shift); SnapAngleDrawer.DrawSnapAngles(CurrentObject, shiftDown, ctrlDown); }
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(); }
private static void ApplyMouseWheelDirection(this IMuteMap map, MouseWheelDirection direction) { switch (direction) { case MouseWheelDirection.Forward: map.MouseWheelSpeed = 0.5; break; case MouseWheelDirection.Reverse: map.MouseWheelSpeed = 2.0; break; // case MouseWheelDirection.None: default: map.MouseWheelSpeed = 1.0; break; } }
private void OnMapCursorChanged(IMuteMap sender, EventArgs e) { var map = _context.Map; FindToolbarItem(MenuKeys.GeometryCreate).Checked = map.MapCursor == MapCursor.AddShape; FindToolbarItem(MenuKeys.VertexEditor).Checked = map.MapCursor == MapCursor.EditShape; FindToolbarItem(MenuKeys.MoveShapes).Checked = map.MapCursor == MapCursor.MoveShapes; FindToolbarItem(MenuKeys.RotateShapes).Checked = map.MapCursor == MapCursor.RotateShapes; FindToolbarItem(MenuKeys.SplitByPolyline).Checked = map.MapCursor == MapCursor.SplitByPolyline; FindToolbarItem(MenuKeys.SplitByPolygon).Checked = map.MapCursor == MapCursor.SplitByPolygon; FindToolbarItem(MenuKeys.EraseByPolygon).Checked = map.MapCursor == MapCursor.EraseByPolygon; FindToolbarItem(MenuKeys.ClipByPolygon).Checked = map.MapCursor == MapCursor.ClipByPolygon; bool polygonCursor = map.MapCursor == MapCursor.ClipByPolygon || map.MapCursor == MapCursor.SplitByPolygon || map.MapCursor == MapCursor.EraseByPolygon; FindToolbarItem(MenuKeys.PolygonOverlayDropDown).Checked = polygonCursor; }
/// <summary> /// Moves the current label /// </summary> private void MoveLabel(IMuteMap map, double dx, double dy) { var layer = map.GetLayer(_currentObject.LayerHandle); var fs = layer.FeatureSet; var label = fs.Labels.Items[_currentObject.ObjectIndex, _currentObject.PartIndex]; if (label == null) { return; } // Check if the featureset has setup offset x or y fields & store the new offset if so if (_currentObject is ObjectTranslateData translateData && translateData.HasBackingOffsetFields) { // We add the existing offset to the new offset & store it in the tabe of the shapefile dx += label.OffsetX; dy += label.OffsetY; translateData.UpdateOffsetFields(layer, dx, dy); }
/// <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(); }
/// <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(""); } }
private void RemoveSelectedShapesNoPrompt(IMuteMap map, IFeatureSet fs, int layerHandle) { var list = map.History; list.BeginBatch(); var features = fs.Features; for (int i = features.Count - 1; i >= 0; i--) { if (features[i].Selected) { list.Add(UndoOperation.RemoveShape, layerHandle, i); features.EditDelete(i); } } list.EndBatch(); _broadcaster.BroadcastEvent(p => p.LayerFeatureCountChanged_, fs, new LayerEventArgs(layerHandle)); }
private void MapMouseUp(IMuteMap map, MouseEventArgs e) { var ctrlDown = Control.ModifierKeys.HasFlag(Keys.Control); var shiftDown = Control.ModifierKeys.HasFlag(Keys.Shift); if (!Active || CurrentObject.LayerHandle == -1) { return; } if (!map.EventWithinMap(e)) { ResetRotation(); Clear(); return; } RotateSymbol(map, e.X, e.Y, shiftDown, ctrlDown); SaveRotation(map); Clear(); }
/// <summary> /// Start the dragging operation. /// </summary> private void MapMouseDown(IMuteMap map, MouseEventArgs e) { if (!Active) { return; } var data = FindMovableItem(e.X, e.Y); if (data == null) { return; } _currentLabel = data; var fs = _map.GetFeatureSet(_currentLabel.LayerHandle); if (fs == null) { return; } IEnvelope env = null; if (_currentLabel.IsChart) { var chart = fs.Diagrams[_currentLabel.LabelIndex]; env = chart.ScreenExtents; } else { var label = fs.Labels.Items[_currentLabel.LabelIndex, _currentLabel.PartIndex]; env = label.ScreenExtents; } _currentLabel.Rect = env.ToRectangle(); DrawLabelRectangle(_currentLabel.Rect); }
private ObjectRotateData CreateObjectRotateDataForPoint(int x, int y, IMuteMap map, ILayer layer, int featureIndex) { IFeature feature = layer.FeatureSet.Features[featureIndex]; if (feature == null) { Clear(); return(_currentObject); } var data = new SymbolRotateData(map, layer.Handle, featureIndex) { X = x, Y = y, OriginalRotation = feature.Rotation }; string rotationExpression = layer.FeatureSet?.Style?.Marker?.RotationExpression ?? ""; if (feature.CategoryIndex > 0) { rotationExpression = feature.Category?.Style?.Marker?.RotationExpression ?? ""; } var rotationFieldIndex = GetRotationFieldIndex(rotationExpression, layer); if (rotationFieldIndex > 0) { data.HasBackingRotationField = true; data.RotationField = rotationFieldIndex; data.OriginalRotation = feature.GetAsDouble(rotationFieldIndex); } else { MessageBox.Show("This feature does not have a single field rotation expression - can not rotate symbol."); Clear(); return(_currentObject); } return(data); }