private void ApplyAction(IEnumerable <Control> entities) { foreach (Control e in entities) { if (e.id == sel && e is Dynamic) { Dynamic d = (Dynamic)e; WayPoint w = new WayPoint(p.X, p.Y, d.maxSpeed); if (waypoint) { d.AppendWayPoint(w); } else { d.SetWayPoint(w); } break; } } }