private void ButtonConfig_Click(object sender, RoutedEventArgs e) { if (cbType.SelectedIndex == -1) { MessageBox.Show("Сначала укажите тип агента"); return; } AgentTypesNames typeName = (AgentTypesNames)cbType.SelectedItem; if (typeName.Type == typeof(HumanAgent)) { wndWayPointsConfig wnd; if (template.WayPointsList != null && template.WayPointsList.Count != 0) { wnd = new wndWayPointsConfig(template.WayPointsList); } else { wnd = new wndWayPointsConfig(); } if (wnd.ShowDialog().GetValueOrDefault()) { template.WayPointsList = wnd.WayPointsList; lvWayPointsList.ItemsSource = null; lvWayPointsList.ItemsSource = template.WayPointsList; } } else if (typeName.Type == typeof(BusAgent) || typeName.Type == typeof(TrainAgent)) { var roadGraph = (Application.Current.MainWindow as MainWindow).Scena.RoadGraph; if (roadGraph.Nodes == null) { MessageBox.Show("Сначала задайте дорожную сеть"); return; } VehicleWayPointsConfigWindow wnd = new VehicleWayPointsConfigWindow(roadGraph); if (wnd.ShowDialog().GetValueOrDefault()) { template.WayPointsList = wnd.GetWayPointsList(); lvWayPointsList.ItemsSource = null; lvWayPointsList.ItemsSource = template.WayPointsList; } } }
private void ConfigOutputPoint_Click(object sender, RoutedEventArgs e) { wndWayPointsConfig wpc; if ((service as StopService).OutputPoints == null) { wpc = new wndWayPointsConfig(); } else { wpc = new wndWayPointsConfig((service as StopService).OutputPoints); } if (wpc.ShowDialog() == true) { (service as StopService).OutputPoints = wpc.WayPointsList; } lvOutputPoints.ItemsSource = null; lvOutputPoints.ItemsSource = (service as StopService).OutputPoints; }
private void ConfigInputPoint_Click(object sender, RoutedEventArgs e) { wndWayPointsConfig wpc; if (service is StopService) { StopService serv = service as StopService; if (serv.InputPoints == null) { wpc = new wndWayPointsConfig(); } else { wpc = new wndWayPointsConfig(serv.InputPoints); } if (wpc.ShowDialog() == true) { (service as StopService).InputPoints = wpc.WayPointsList; lvInputPoints.ItemsSource = null; lvInputPoints.ItemsSource = (service as StopService).InputPoints; } } else if (service is QueueService) { QueueService serv = service as QueueService; if (serv.InputPoints == null) { wpc = new wndWayPointsConfig(); } else { wpc = new wndWayPointsConfig(serv.InputPoints); } if (wpc.ShowDialog() == true) { (service as QueueService).InputPoints = wpc.WayPointsList; lvInputQueuePoints.ItemsSource = null; lvInputQueuePoints.ItemsSource = (service as QueueService).InputPoints; } } }