Exemplo n.º 1
0
        public void createMarker(List <PointLatLng> points, int index)
        {
            MapObject mapObject = null;

            switch (index)
            {
            case 0:
            {
                mapObject = new Area_class(createObjectName.Text, points);
                break;
            }

            case 1:
            {
                mapObject = new Location_class(createObjectName.Text, points.Last());
                break;
            }

            case 2:
            {
                mapObject = new Car_class(createObjectName.Text, points.Last());
                break;
            }

            case 3:
            {
                mapObject = new Human_class(createObjectName.Text, points.Last());
                break;
            }

            case 4:
            {
                mapObject = new Route_class(createObjectName.Text, points);
                break;
            }
            }
            if (mapObject != null)
            {
                mapObjects.Add(mapObject);
                Map.Markers.Add(mapObject.getMarker());
            }
        }
Exemplo n.º 2
0
        private void Focus_Follow(object sender, EventArgs args)
        {
            Car_class c = (Car_class)sender;

            waybar.Maximum = c.route.Points.Count;
            Map.Position   = c.getFocus();

            if (waybar.Value == waybar.Maximum)
            {
                (sender as Car_class).Follow -= Focus_Follow;
            }

            if (waybar.Value != waybar.Maximum)
            {
                waybar.Value += 1;
            }

            else
            {
                waybar.Value = 0;
            }
        }
Exemplo n.º 3
0
        private void stuvk_Click(object sender, RoutedEventArgs e)
        {
            {
                waybar.Value = 0;
                foreach (MapObject obj in mapObjects)
                {
                    if (obj is Human_class)
                    {
                        startOfRoute = (obj.getFocus());
                    }
                }
                endOfRoute = areaspots.Last();
                var besidedObj = mapObjects.OrderBy(mapObject => mapObject.getDist(startOfRoute));

                Car_class   nearestCar = null;
                Human_class h          = null;

                foreach (MapObject obj in mapObjects)
                {
                    if (obj is Human_class)
                    {
                        h = (Human_class)obj;
                        h.destinationPoint = endOfRoute;
                        break;
                    }
                }

                foreach (MapObject obj in besidedObj)
                {
                    if (obj is Car_class)
                    {
                        nearestCar = (Car_class)obj;
                        break;
                    }
                }


                var localRoute = nearestCar.MoveTo(startOfRoute);
                if (localRoute != null)
                {
                    createMarker(localRoute.Points, 4);
                }
                else
                {
                    System.Windows.MessageBox.Show("маршрут не назначен");
                }

                RoutingProvider routingProvider = GMapProviders.OpenStreetMap;
                MapRoute        route           = routingProvider.GetRoute(
                    startOfRoute,
                    endOfRoute,
                    false,
                    false,
                    15);
                createMarker(route.Points, 4);
                nearestCar.Arrived += h.CarArrived;
                h.seated           += nearestCar.getintocar;
                nearestCar.Follow  += Focus_Follow;

                nearestCar.Arrived += nearestCar.test;


                //  nearestCar.Arrived -= h.CarArrived;
                //  h.seated -= nearestCar.getintocar;
            }
        }