public void getintocar(object sender, EventArgs args) { human = (Human_class)sender; MoveTo(human.destinationPoint); human.point = point; (sender as Human_class).seated -= getintocar; }
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()); } }
private void MoveByRoute() { try { foreach (var point in route.Points) { Application.Current.Dispatcher.Invoke(delegate { this.point = point; marker.Position = point; if (human != null) // human = null { human.marker.Position = point; Follow?.Invoke(this, null); } }); Thread.Sleep(700); } if (human == null) { Arrived?.Invoke(this, null); } else { human.point = point; MessageBox.Show("Прибыли"); human = null; Arrived?.Invoke(this, null); } } catch { } }
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; } }