private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (this.selected is SimVehicle) { // vehicle SimVehicle isv = (SimVehicle)this.selected; // notfy SimulatorOutput.WriteLine("Removed Vehicle: " + isv.SimVehicleState.VehicleID.ToString()); // remove this.displayObjects.Remove(this.selected); this.Simulation.simEngine.Vehicles.Remove(isv.VehicleId); this.Simulation.clientHandler.Remove(isv.VehicleId); this.Simulation.OnClientsChanged(); if (this.tracked != null && this.tracked.VehicleId.Equals(isv.VehicleId)) { this.tracked = null; } // remove selecation this.selected = null; // properties this.Simulation.simEngine.SetPropertyGridDefault(); // redraw this.Invalidate(); } }
/// <summary> /// Delete obstacle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void deleteObstacleContextToolStripMenuItem1_Click(object sender, EventArgs e) { if (this.selected is SimObstacle) { SimObstacle so = (SimObstacle)this.selected; this.displayObjects.Remove(so); this.Simulation.simEngine.WorldService.Obstacles.Remove(so.ObstacleId); this.Simulation.simEngine.SetPropertyGridDefault(); this.selected = null; SimulatorOutput.WriteLine("Removed Obstacle: " + so.ObstacleId.ToString()); this.Invalidate(); } }