/// <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();
            }
        }
        /// <summary>
        /// What to do when mouse moves
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            #region Left

            if (e.Button == MouseButtons.Left)
            {
                // dragging vehicle
                if (this.selected != null && this.selected is CarDisplayObject && isDragging && this.temporaryCoordinate.HasValue)
                {
                    // Get the offset.
                    Point point = e.Location;

                    // new coord
                    Coordinates newCoord = this.transform.GetWorldPoint(new PointF(point.X, point.Y));

                    // calc offse
                    Coordinates offset = newCoord - this.temporaryCoordinate.Value;

                    // moving object
                    CarDisplayObject cdo = (CarDisplayObject)this.selected;

                    // check we are not tracking
                    if (this.tracked != null && cdo.Equals(this.tracked))
                    {
                        this.tracked = null;
                    }

                    // move
                    cdo.InMove(this.temporaryCoordinate.Value, offset, this.transform);

                    // check snap pos or heading
                    if (cdo.SnapHeading || cdo.SnapPosition)
                    {
                        // filter for vehicles
                        DisplayObjectFilter partitionDof = delegate(IDisplayObject target)
                        {
                            // check if target is network object
                            if (target is ArbiterLanePartition)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        };

                        // check to see if selected a partition
                        HitTestResult vhcHtr = this.HitTest(transform.GetWorldPoint(new PointF(e.X, e.Y)), partitionDof);

                        // check hit
                        if (vhcHtr.Hit)
                        {
                            // get partition
                            ArbiterLanePartition alp = (ArbiterLanePartition)vhcHtr.DisplayObject;

                            // heading
                            Coordinates heading = alp.Vector();

                            // position
                            Coordinates closest = alp.PartitionPath.GetPoint(alp.PartitionPath.GetClosestPoint(transform.GetWorldPoint(new PointF(e.X, e.Y))));

                            if (cdo.SnapPosition)
                            {
                                cdo.Position = closest;
                            }

                            if (cdo.SnapHeading)
                            {
                                cdo.Heading = heading;
                            }
                        }
                    }
                }
                else if (this.selected != null && this.selected is SimObstacle && isDragging && this.temporaryCoordinate.HasValue)
                {
                    // Get the offset.
                    Point point = e.Location;

                    // new coord
                    Coordinates newCoord = this.transform.GetWorldPoint(new PointF(point.X, point.Y));

                    // calc offse
                    Coordinates offset = newCoord - this.temporaryCoordinate.Value;

                    // moving object
                    SimObstacle so = (SimObstacle)this.selected;

                    // move
                    so.InMove(this.temporaryCoordinate.Value, offset, this.transform);
                }
                // check if user is dragging
                else if (isDragging)
                {
                    // Get the offset.
                    Point point = (Point)controlTag;

                    // Calculate change in position
                    double deltaX = e.X - point.X;
                    double deltaY = e.Y - point.Y;

                    // Update the world
                    Coordinates tempCenter = WorldTransform.CenterPoint;
                    tempCenter.X -= deltaX / WorldTransform.Scale;
                    tempCenter.Y += deltaY / WorldTransform.Scale;
                    WorldTransform.CenterPoint = tempCenter;

                    // update control
                    controlTag = new Point(e.X, e.Y);
                }

                // redraw
                this.Invalidate();
            }

            #endregion

            #region Right

            else if (e.Button == MouseButtons.Right)
            {
                if (this.selected != null && this.selected is SimObstacle && isDragging && this.temporaryCoordinate.HasValue)
                {
                    // Get the offset.
                    Point point = e.Location;

                    // new coord
                    Coordinates newCoord = this.transform.GetWorldPoint(new PointF(point.X, point.Y));

                    // moving object
                    SimObstacle so = (SimObstacle)this.selected;

                    // calc new rel heading
                    Coordinates offset = newCoord - so.Position;

                    // calc degree diff
                    //double rotDiff = offset.ToDegrees() - this.temporaryCoordinate.Value.ToDegrees();

                    // new head
                    //Coordinates newHead = so.Heading.Rotate(rotDiff);

                    // set
                    so.Heading = offset;

                    this.Invalidate();
                }
            }

            #endregion

            base.OnMouseMove(e);
        }
        /// <summary>
        /// Obstacle
        /// </summary>
        /// <param name="screenCenter"></param>
        /// <returns></returns>
        public SimObstacle AddObstacle(Coordinates screenCenter)
        {
            // deafualt id is # of elts
            int idNumber = this.WorldService.Obstacles.Count + this.Vehicles.Count;

            // create array to hold used vehicle and obstacle id's
            bool[] usedIds = new bool[this.WorldService.Obstacles.Count + this.Vehicles.Count];

            // loop over obstacles and get ids
            foreach (SimObstacle ism in this.WorldService.Obstacles.Values)
            {
                // make sure num within # of obstacles and vehicles
                if (ism.ObstacleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count)
                {
                    // check off
                    usedIds[ism.ObstacleId.Number] = true;
                }
            }

            // loop over vehicles and get ids
            foreach (SimVehicle ism in this.Vehicles.Values)
            {
                // make sure num within # of obstacles and vehicles
                if (ism.VehicleId.Number < this.WorldService.Obstacles.Count + this.Vehicles.Count)
                {
                    // check off
                    usedIds[ism.VehicleId.Number] = true;
                }
            }

            // loop over checked off id's
            for (int i = usedIds.Length - 1; i >= 0; i--)
            {
                // if find a false one set that id
                if (usedIds[i] == false)
                {
                    // set id num
                    idNumber = i;
                }
            }

            // create obstacle id
            SimObstacleId soi = new SimObstacleId(idNumber);

            // get position (center of screen)
            Coordinates position = screenCenter;

            // create obstacle
            SimObstacle so = new SimObstacle(soi, position, new Coordinates(1, 0));

            // add to obstacles
            this.WorldService.Obstacles.Add(so.ObstacleId, so);

            // return
            return so;
        }