private ObjectMoveData _currentObject; // The object being moved currently public MapObjectMover(IAppContext context, SymbologyPlugin plugin) { _context = context ?? throw new ArgumentNullException("context"); _plugin = plugin ?? throw new ArgumentNullException("plugin"); _map = context.Map; _currentObject = new EmptyMoveData(); plugin.MouseDown += MapMouseDown; plugin.MouseUp += MapMouseUp; plugin.MouseMove += MapMouseMove; }
/// <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; } _currentObject = data; var fs = _map.GetFeatureSet(_currentObject.LayerHandle); if (fs == null) { return; } IEnvelope env = null; if (_currentObject.IsChart) { var chart = fs.Diagrams[_currentObject.ObjectIndex]; env = chart.ScreenExtents; } else { var label = fs.Labels.Items[_currentObject.ObjectIndex, _currentObject.PartIndex]; env = label.ScreenExtents; } _currentObject.Rect = env.ToRectangle(); DrawLabelRectangle(_currentObject.Rect); }