public Dibujo (Entorno entorno)
		{
			calles = entorno.Calles;
			señaleticas = entorno.Señaleticas;
			vehiculos = entorno.Vehiculos;
			sectores = entorno.Sectores;

			SetStyle (ControlStyles.OptimizedDoubleBuffer, true);
			SetStyle (ControlStyles.AllPaintingInWmPaint, true);
			SetStyle (ControlStyles.UserPaint, true);
		}
		public static Entorno cargarMapa(Entorno entorno)
		{
			entorno.agregarCalle (new Generador (0, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20, -60));
			//entorno.agregarCalle (new Generador (200, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20, 2600));
			entorno.agregarCalle (new Interseccion (20, 20));
			entorno.agregarCalle (new Calle ("Matta", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20,56));
			entorno.agregarCalle (new Interseccion (20, 656));
			entorno.agregarCalle (new Calle ("Matta", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20,692));
			entorno.agregarCalle (new Interseccion (20, 1292));
			entorno.agregarCalle (new Calle ("Matta", 282, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20,1328));
			entorno.agregarCalle (new Interseccion (20, 1610));
			entorno.agregarCalle (new Calle ("Matta", 282, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20,1646));
			entorno.agregarCalle (new Interseccion (20, 1928));
			entorno.agregarCalle (new Calle ("Matta", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 20,1964));
			entorno.agregarCalle (new Interseccion (20, 2564));

			entorno.agregarCalle (new Generador (0, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, -60, 20));
			entorno.agregarCalle (new Generador (0, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, -60, 656));
			//entorno.agregarCalle (new Generador (200, Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, -60, 1292));
			//entorno.agregarCalle (new Generador (2, Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, -60, 1610));
			entorno.agregarCalle (new Generador (0, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, -60, 1928));
			//entorno.agregarCalle (new Generador (200, Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, -60, 2564));

			entorno.agregarCalle (new Calle ("Almagro", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 56,20));
			entorno.agregarCalle (new Calle ("Colón", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 56,656));
			entorno.agregarCalle (new Calle ("Brasil", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 56,1292));
			entorno.agregarCalle (new Calle ("Regidor Muñoz", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 56,1610));
			entorno.agregarCalle (new Calle ("Arturo Prat", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 56,1928));
			entorno.agregarCalle (new Calle ("Gregorio Cordovez", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 56,2564));

			//entorno.agregarCalle (new Generador (200, Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656, -60));
			entorno.agregarCalle (new Generador (0, Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656, 2600));
			entorno.agregarCalle (new Interseccion (656, 20));
			entorno.agregarCalle (new Calle ("Los Carrera", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656,56));
			entorno.agregarCalle (new Interseccion (656, 656));
			entorno.agregarCalle (new Calle ("Los Carrera", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656,692));
			entorno.agregarCalle (new Interseccion (656, 1292));
			entorno.agregarCalle (new Calle ("Los Carrera", 282, Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656,1328));
			entorno.agregarCalle (new Interseccion (656, 1610));
			entorno.agregarCalle (new Calle ("Los Carrera", 282, Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656,1646));
			entorno.agregarCalle (new Interseccion (656, 1928));
			entorno.agregarCalle (new Calle ("Los Carrera", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 656,1964));
			entorno.agregarCalle (new Interseccion (656, 2564));

			entorno.agregarCalle (new Calle ("Almagro", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 692,20));
			entorno.agregarCalle (new Calle ("Colón", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 692,656));
			entorno.agregarCalle (new Calle ("Brasil", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 692,1292));
			entorno.agregarCalle (new Calle ("Arturo Prat", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 692,1928));
			entorno.agregarCalle (new Calle ("Gregorio Cordovez", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 692,2564));

			entorno.agregarCalle (new Generador (0, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292, -60));
			//entorno.agregarCalle (new Generador (200, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292, 2600));
			entorno.agregarCalle (new Interseccion (1292, 20));
			entorno.agregarCalle (new Calle ("Av. Jose Manuel Balmaceda", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292,56));
			entorno.agregarCalle (new Interseccion (1292, 656));
			entorno.agregarCalle (new Calle ("Av. Jose Manuel Balmaceda", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292,692));
			entorno.agregarCalle (new Interseccion (1292, 1292));
			entorno.agregarCalle (new Calle ("Av. Jose Manuel Balmaceda", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292,1328));
			entorno.agregarCalle (new Interseccion (1292, 1928));
			entorno.agregarCalle (new Calle ("Av. Jose Manuel Balmaceda", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 1292,1964));
			entorno.agregarCalle (new Interseccion (1292, 2564));

			entorno.agregarCalle (new Calle ("Almagro", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1328,20));
			entorno.agregarCalle (new Calle ("Colón", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1328,656));
			entorno.agregarCalle (new Calle ("Brasil", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 1328,1292));
			entorno.agregarCalle (new Calle ("Arturo Prat", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1328,1928));
			entorno.agregarCalle (new Calle ("Gregorio Cordovez", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 1328,2564));

			entorno.agregarCalle (new Generador (0, Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 1928, 2600));
			entorno.agregarCalle (new Interseccion (1928, 20));
			entorno.agregarCalle (new Calle ("Libertador Bernardo O'Higgins", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 1928,56));
			entorno.agregarCalle (new Interseccion (1928, 656));
			entorno.agregarCalle (new Calle ("Libertador Bernardo O'Higgins", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 1928,692));
			entorno.agregarCalle (new Interseccion (1928, 1292));
			entorno.agregarCalle (new Calle ("Libertador Bernardo O'Higgins", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 1928,1328));
			entorno.agregarCalle (new Interseccion (1928, 1928));
			entorno.agregarCalle (new Calle ("Libertador Bernardo O'Higgins", Elemento.DE1A2, Elemento.DE1A2, Elemento.VERTICAL, 1928,1964));
			entorno.agregarCalle (new Interseccion (1928, 2564));

			//entorno.agregarCalle (new Generador (10, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 2600, 20));
			//entorno.agregarCalle (new Generador (200, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 2600, 656));
			entorno.agregarCalle (new Generador (0, Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 2600, 1292));
			//entorno.agregarCalle (new Generador (200, Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 2600, 1928));
			entorno.agregarCalle (new Generador (0, Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 2600, 2564));

			entorno.agregarCalle (new Calle ("Almagro", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1964,20));
			entorno.agregarCalle (new Calle ("Colón", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1964,656));
			entorno.agregarCalle (new Calle ("Brasil", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 1964,1292));
			entorno.agregarCalle (new Calle ("Arturo Prat", Elemento.DE2A1, Elemento.DE2A1, Elemento.HORIZONTAL, 1964,1928));
			entorno.agregarCalle (new Calle ("Gregorio Cordovez", Elemento.DE1A2, Elemento.DE1A2, Elemento.HORIZONTAL, 1964,2564));

			entorno.agregarCalle (new Generador (54, 50, 100, Elemento.DE2A1, Elemento.DE1A2, Elemento.VERTICAL, 2564, -60));
			//entorno.agregarCalle (new Generador (200, Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 2564, 2600));
			entorno.agregarCalle (new Interseccion (2564, 20));
			entorno.agregarCalle (new Calle ("Cienfuegos", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 2564,56));
			entorno.agregarCalle (new Interseccion (2564, 656));
			entorno.agregarCalle (new Calle ("Cienfuegos", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 2564,692));
			entorno.agregarCalle (new Interseccion (2564, 1292));
			entorno.agregarCalle (new Calle ("Cienfuegos", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 2564,1328));
			entorno.agregarCalle (new Interseccion (2564, 1928));
			entorno.agregarCalle (new Calle ("Cienfuegos", Elemento.DE2A1, Elemento.DE2A1, Elemento.VERTICAL, 2564,1964));
			entorno.agregarCalle (new Interseccion (2564, 2564));
			entorno.unirCallesCercanas ();

			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.ESTE, 56, 20));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.NORTE, 656, 1982));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.OESTE, 656, 2600));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.ESTE, 692, 20));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.NORTE, 656, 2564));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.ESTE, 1274, 20));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.SUR, 1328, 56));
			entorno.agregarSeñaletica (new PasoDeCebra(Elemento.NORTE, 1928, 74));

			entorno.agregarSeñaletica (new LomoDeToro(20,Elemento.HORIZONTAL, 2376, 1292));

			entorno.agregarSeñaletica (new Pare(Elemento.CARRIL1Y2, Elemento.SUR,56,56));
			entorno.agregarSeñaletica (new Pare(Elemento.CARRIL1Y2, Elemento.ESTE,692,20));

			//No son parte del mapa elegido, solo de ejemplo
			//entorno.agregarSeñaletica (new Bache(300,20));
			//entorno.agregarSeñaletica (new Bache(20,600));
			//entorno.agregarSeñaletica (new CedaElPaso(Elemento.CARRIL1Y2, Elemento.SUR, 56, 56));
			//entorno.agregarSeñaletica (new CedaElPaso(Elemento.CARRIL1Y2, Elemento.ESTE, 692, 20));;

			entorno.agregarSeñaletica (new VelocidadMaxima(50, Elemento.HORIZONTAL, 344, 20));
			entorno.agregarSeñaletica (new VelocidadMaxima (100, Elemento.VERTICAL, 20, 344));

			entorno.agregarSeñaletica (new Semaforo (4, 1, 0, Elemento.CARRIL1Y2, Elemento.SUR, 56, 692));
			entorno.agregarSeñaletica (new Semaforo (1, 1, 0, Elemento.CARRIL1Y2, Elemento.ESTE, 56, 656));

			entorno.agregarSeñaletica (new Semaforo (8, 2, 0, Elemento.CARRIL1Y2, Elemento.NORTE, 656, 656));
			entorno.agregarSeñaletica (new Semaforo (8, 2, 0, Elemento.CARRIL1Y2, Elemento.ESTE, 692, 656));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 1328, 656));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 1328, 692));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.NORTE, 1928, 656));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 1964, 656));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 2600, 56));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 2600, 20));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 2600, 692));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 2600, 656));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 56, 1328));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 20, 1328));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 656, 1328));//
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.NORTE, 656, 1292));//

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 1292, 1328));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 1328, 1328));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 1928, 1328));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.NORTE, 1928, 1292));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 2564, 1328));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 2600, 1328));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 56, 1928));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 56, 1964));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 56, 2600));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 20, 2600));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 1328, 1928));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 1328, 1964));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 1964, 1928));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.NORTE, 1928, 1928));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 2600,1964));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.ESTE, 2600,1928));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 1292, 2600));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 1328, 2600));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 1928, 2600));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.NORTE, 1928, 2564));

			entorno.agregarSeñaletica (new Semaforo (Semaforo.VERDE, Elemento.CARRIL1Y2, Elemento.OESTE, 2564, 2600));
			entorno.agregarSeñaletica (new Semaforo (Semaforo.ROJO, Elemento.CARRIL1Y2, Elemento.SUR, 2600, 2600));

			return entorno;
		}
		public void nuevoEntorno(Entorno nuevo) {
			calles = nuevo.Calles;
			señaleticas = nuevo.Señaleticas;
			vehiculos = nuevo.Vehiculos;
		}
		public static void Serializar (Entorno datos, string archivo) {
			FileStream archivoGuardar = new FileStream (archivo, FileMode.Create);
			BinaryFormatter binario = new BinaryFormatter ();
			binario.Serialize (archivoGuardar, datos);
			archivoGuardar.Close ();
		}
        public Ventana ()
		{
			//Icono semaforo de Saki (Alexandre Moore)
			//Iconos interfaz de Aha-Soft https://www.iconfinder.com/aha-soft
			//http://www.iconarchive.com/artist/saki.html
			this.ClientSize = new Size (1000 , 600);
			this.Name = "Simulador de Trafico Vehicular";
			this.Text = "Simulador de Trafico Vehicular";
			//this.Icon = new Icon("semaforo.ico");
			ComponentResourceManager recurso = new ComponentResourceManager(typeof(Ventana));
			this.Icon = (Icon)(recurso.GetObject("$this.Icon"));

			entorno = new Entorno (true);
			entorno = MapaPredeterminado.cargarMapa (entorno);
			entorno.ordenarCalles ();
			entorno.ordenarSeñaleticas ();
			/*
			 * Corresponde al agente que aprende NO deberia estar aqui
			ElementoAprendizaje.leerTabla("APRENDIZAJE.arff");

			for (int i = 0; i < ElementoAprendizaje.tabla.getNumeroFila(); i++)
			{
				Fila fila = ElementoAprendizaje.tabla.getFila(i);
				for (int j = 0; j < fila.tamaño(); j++)
				{
					Dato dato = fila.getDato(j);
					System.Console.Write(dato + " ");
				}
				System.Console.WriteLine();
			}
			*/
			menu = new MenuStrip ();
			archivo = new ToolStripMenuItem ();
			abrir = new ToolStripMenuItem ();
			guardar = new ToolStripMenuItem ();
			salir = new ToolStripMenuItem ();

			ver = new ToolStripMenuItem ();
			modoDesarrollo = new ToolStripMenuItem ();
			mostrarID = new ToolStripMenuItem ();
			mostrarBezier = new ToolStripMenuItem ();
			mostrarRadioPercepcion = new ToolStripMenuItem ();
			mostrarSectores = new ToolStripMenuItem ();
			colores = new ToolStripMenuItem ();
			modoCiudad = new ToolStripMenuItem ();
			modoMapa = new ToolStripMenuItem ();

			barraHerramienta = new ToolStrip ();

			detener = new ToolStripButton ();
			masRapido = new ToolStripButton ();
			masLento = new ToolStripButton ();

			agregarLomoDeToro = new ToolStripButton ();
			agregarSemaforo = new ToolStripButton ();
			agregarVelocidadMaxima = new ToolStripButton ();
			agregarVehiculo = new ToolStripButton ();
			agregarBache = new ToolStripButton ();
			agregarCedaElPaso = new ToolStripButton ();
			agregarPare = new ToolStripButton ();
			agregarPasoDeCebra = new ToolStripButton ();
			
			eliminarCalles = new ToolStripButton ();
			eliminarSeñaleticas = new ToolStripButton ();
			eliminarVehiculos = new ToolStripButton ();

			separador1 = new ToolStripSeparator ();
			separador2 = new ToolStripSeparator ();

			barraEstado = new StatusStrip ();
			textoEstado = new ToolStripStatusLabel ();
			blancoEstado = new ToolStripStatusLabel ();
			totalVehiculos = new ToolStripStatusLabel ();
			vehiculosActual = new ToolStripStatusLabel ();
			fpsEstado = new ToolStripStatusLabel ();

			iconoDetener = new Icon ("pausa.ico");
			iconoReproducir = new Icon ("reproducir.ico");

			menu.Items.AddRange (new ToolStripItem[] {archivo, ver});
			menu.Location = new Point (0,0);
			menu.TabIndex = 0;

			archivo.DropDownItems.AddRange (new ToolStripItem[] {abrir,guardar,salir});
			archivo.Text = "Archivo";

			abrir.Text = "Abrir";
			abrir.Image = new Icon("abrir.ico").ToBitmap();
			abrir.Click += new EventHandler (eventoAbrir);

			guardar.Text = "Guardar";
			guardar.Image = new Icon("guardar.ico").ToBitmap();
			guardar.Click += new EventHandler (eventoGuardar);

			salir.Text = "Salir";
			salir.Image = new Icon("salir.ico").ToBitmap();
			salir.Click += new EventHandler(cerrar);

			ver.DropDownItems.AddRange (new ToolStripItem[] {modoDesarrollo, colores});
			ver.Text = "Ver";

			modoDesarrollo.DropDownItems.AddRange (new ToolStripItem[] {mostrarID, mostrarBezier, mostrarRadioPercepcion, mostrarSectores});
			modoDesarrollo.Text = "Modo Desarrollo";
			modoDesarrollo.Image = new Icon("configurar.ico").ToBitmap();

			mostrarID.Text = "Mostrar ID";
			mostrarID.Image = new Icon ("configurar.ico").ToBitmap ();
			mostrarID.Click += new EventHandler (activarID);

			mostrarBezier.Text = "Mostrar Bezier";
			mostrarBezier.Image = new Icon ("configurar.ico").ToBitmap ();
			mostrarBezier.Click += new EventHandler (activarBezier);

			mostrarRadioPercepcion.Text = "Mostrar Radio de Percepcion";
			mostrarRadioPercepcion.Image = new Icon ("configurar.ico").ToBitmap ();
			mostrarRadioPercepcion.Click += new EventHandler (activarRadio);

			mostrarSectores.Text = "Mostrar Sectores";
			mostrarSectores.Image = new Icon ("configurar.ico").ToBitmap ();
			mostrarSectores.Click += new EventHandler (activarSectores);

			colores.DropDownItems.AddRange (new ToolStripItem[] {modoMapa, modoCiudad});
			colores.Image = new Icon("colores.ico").ToBitmap();
			colores.Text = "Colores";

			modoMapa.Text = "Modo Mapa";
			modoMapa.Image = new Icon("mapa.ico").ToBitmap();
			modoMapa.Click += new EventHandler (cambiarModoMapa);

			modoCiudad.Text = "Modo Ciudad";
			modoCiudad.Image = new Icon("ciudad.ico").ToBitmap();
			modoCiudad.Click += new EventHandler (cambiarModoCiudad);

			barraHerramienta.Items.AddRange (new ToolStripItem[] {masLento, detener, masRapido, separador1, agregarLomoDeToro, agregarSemaforo, agregarVelocidadMaxima, /*agregarVehiculo, */agregarBache, agregarCedaElPaso, agregarPare, agregarPasoDeCebra, separador2, eliminarCalles, eliminarSeñaleticas, eliminarVehiculos});
			barraHerramienta.Location = new Point (0, 24);

			detener.Text = "Detener";
			detener.DisplayStyle = ToolStripItemDisplayStyle.Image;
			detener.Image = iconoDetener.ToBitmap();
			detener.Click += new EventHandler (detenerTiempo);

			masRapido.DisplayStyle = ToolStripItemDisplayStyle.Image;
			masRapido.Image = new Icon("mas.ico").ToBitmap();
			masRapido.Text = "Más Rapido";
			masRapido.Click += new EventHandler (acelerarTiempo);

			masLento.DisplayStyle = ToolStripItemDisplayStyle.Image;
			masLento.Image = new Icon("menos.ico").ToBitmap();
			masLento.Text = "Más Lento";
			masLento.Click += new EventHandler (reducirTiempo);

			//agregarCalles.Text = "Calle";
			//agregarCalles.Click += new EventHandler (eventoCalle);

			agregarLomoDeToro.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarLomoDeToro.Image = new Icon("lomoDeToro.ico").ToBitmap();
			agregarLomoDeToro.Text = "Agregar Lomo de Toro";
			agregarLomoDeToro.Click += new EventHandler (eventoLomoDeToro);

			agregarSemaforo.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarSemaforo.Image = ((Icon)(recurso.GetObject("$this.Icon"))).ToBitmap();
			agregarSemaforo.Text = "Agregar Semaforo";
			agregarSemaforo.Click += new EventHandler (eventoSemaforo);

			agregarVelocidadMaxima.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarVelocidadMaxima.Image = new Icon("velocidadMaxima.ico").ToBitmap();
			agregarVelocidadMaxima.Text = "Agregar Velocidad Maxima";
			agregarVelocidadMaxima.Click += new EventHandler (eventoVelocidadMaxima);

			agregarVehiculo.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarVehiculo.Text = "Agregar Vehiculo";
			agregarVehiculo.Image = new Icon("vehiculo.ico").ToBitmap();
			//agregarVehiculo.Click += new EventHandler (eventoVehiculo);

			agregarBache.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarBache.Image = new Icon("bache.ico").ToBitmap();
			agregarBache.Text = "Agregar Bache";
			agregarBache.Click += new EventHandler (eventoBache);

			agregarCedaElPaso.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarCedaElPaso.Image = new Icon("cedaElPaso.ico").ToBitmap();
			agregarCedaElPaso.Text = "Agregar Ceda el Paso";
			agregarCedaElPaso.Click += new EventHandler (eventoCedaPaso);

			agregarPare.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarPare.Image = new Icon("pare.ico").ToBitmap();
			agregarPare.Text = "Agregar Pare";
			agregarPare.Click += new EventHandler (eventoPare);

			agregarPasoDeCebra.DisplayStyle = ToolStripItemDisplayStyle.Image;
			agregarPasoDeCebra.Image = new Icon("pasoDeCebra.ico").ToBitmap();
			agregarPasoDeCebra.Text = "Agregar Paso de Cebra";
			agregarPasoDeCebra.Click += new EventHandler (eventoPasoDeCebra);

			eliminarCalles.Text = "Eliminar Calles";
			eliminarCalles.Click += new EventHandler (eventoEliminarCalles);

			eliminarSeñaleticas.Text = "Eliminar Señaleticas";
			eliminarSeñaleticas.Click += new EventHandler (eventoEliminarSeñaleticas);

			eliminarVehiculos.Text = "Eliminar Vehiculos";
			eliminarVehiculos.Click += new EventHandler (eventoEliminarVehiculos);

			Controls.Add (barraHerramienta);
			Controls.Add (menu);

			this.MainMenuStrip = menu;

			panelDibujo = new Dibujo (entorno);
			panelDibujo.Size = new Size (1000, 529);
			panelDibujo.Anchor = ((AnchorStyles)(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom));
			panelDibujo.Location = new Point (0,49);
			panelDibujo.MouseUp += new MouseEventHandler (soltar);
			panelDibujo.MouseDown += new MouseEventHandler (pulsar);
			panelDibujo.MouseMove += new MouseEventHandler (moverRaton);
			panelDibujo.Resize += new EventHandler (redimencionar);

			Controls.Add (panelDibujo);

			barraEstado.Items.AddRange (new ToolStripItem[] {textoEstado, blancoEstado, vehiculosActual, totalVehiculos, fpsEstado});
			barraEstado.Location = new Point (0,527);

			textoEstado.BorderSides = ToolStripStatusLabelBorderSides.Right;
			textoEstado.BorderStyle = Border3DStyle.Etched;
			textoEstado.Text = "Ejecutando Simulación";

			blancoEstado.Spring = true;

			vehiculosActual.BorderSides = ToolStripStatusLabelBorderSides.Left;
			vehiculosActual.BorderStyle = Border3DStyle.Etched;
			vehiculosActual.Text = "Vehiculos actuales: ";

			totalVehiculos.BorderSides = ToolStripStatusLabelBorderSides.Left;
			totalVehiculos.BorderStyle = Border3DStyle.Etched;
			totalVehiculos.Text = "Total Vehiculos: ";

			fpsEstado.BorderSides = ToolStripStatusLabelBorderSides.Left;
			fpsEstado.BorderStyle = Border3DStyle.Etched;
			fpsEstado.Text = "0 FPS";

			Controls.Add (barraEstado);

			hilo = new Thread (new ThreadStart(actualizar));
			hilo.Start ();
		}
		private void eventoAbrir(object sender, EventArgs e)
		{
			//Console.WriteLine ("Cargar Archivo");
			OpenFileDialog abrirDialogoArchivo = new OpenFileDialog();
			abrirDialogoArchivo.Title = "Abrir Mapa";
			abrirDialogoArchivo.Filter = "Archivos STV(*.stv)|*.stv";
			if (abrirDialogoArchivo.ShowDialog() == DialogResult.OK)
			{
				entorno = Guardar.Deserializar (abrirDialogoArchivo.FileName);
				panelDibujo.nuevoEntorno (entorno);
			}
			abrirDialogoArchivo.Dispose ();
		}