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 cbType_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { AgentTypesNames atn = (AgentTypesNames)cbType.SelectedItem; template.Type = atn.Type.Name; if (atn.Type == typeof(HumanAgent)) { tbCapasity.IsEnabled = false; tbNumberOfCarriges.IsEnabled = false; } if (atn.Type == typeof(BusAgent)) { tbCapasity.IsEnabled = true; tbNumberOfCarriges.IsEnabled = false; } if (atn.Type == typeof(TrainAgent)) { tbCapasity.IsEnabled = true; tbNumberOfCarriges.IsEnabled = true; } }