public override void Do() { _context.SelectedEntities.Clear(); foreach (IVisualElement entity in AffectedEntities) { // check for objects that are not allowed to be paseted inside of buildings if (_context is IVisualBuilding && (entity.SourceEntity is IBuildingEntity || entity.SourceEntity is IVegetationEntity)) { continue; } double offsetX = entity.X - _context.CopyLocation.X; double offsetY = entity.Y - _context.CopyLocation.Y; IVisualElement copy = entity.Copy(); copy.X = PasteLocation.X + offsetX; copy.Y = PasteLocation.Y + offsetY; _context.MapEntities.Add(copy); PastedEntities.Add(copy); _context.SelectedEntities.Add(copy); copy.IsSelected = true; } }
public override void Undo() { foreach (IVisualElement copy in PastedEntities) { _context.SelectedEntities.Remove(copy); _context.MapEntities.Remove(copy); } PastedEntities.Clear(); }