Example #1
0
        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 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;
         }
     }
 }