/// <summary> /// Custom event. Handles which state the simulator should be in. /// </summary> private void HandleSimStart(object sender, StartingSimEventArgs e) { switch (e.value) { //A value of zero means the simulator should be put in a stopped state, //The previous state was that of started randomly. case 0: StartStopButton.Background = Brushes.Green; ContentBlock1.Text = "Start randomly\non route"; StartStopFirstPointButton.IsEnabled = true; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate -= HandleLogUpdate; } WaitDataUpdate = false; break; //A value of 1 means the simulator should be put in a started state, with random placement of busses. case 1: StartStopButton.Background = Brushes.Red; ContentBlock1.Text = "Stop\nSimulation"; StartStopFirstPointButton.IsEnabled = false; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } break; //A value of 2 means the simulator should be put in a stopped state, //The previous state was that of started at the beginning of the route. case 2: StartStopFirstPointButton.Background = Brushes.Green; ContentBlock2.Text = "Start at\nbeginning\nof route"; StartStopButton.IsEnabled = true; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } WaitDataUpdate = false; break; //A value of 3 means the simulator should be put in a started state, //where the busses are placed at the beginning of the route. case 3: StartStopFirstPointButton.Background = Brushes.Red; ContentBlock2.Text = "Stop simulation"; StartStopButton.IsEnabled = false; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } break; default: break; } }
private void HandleSimStart(object sender, StartingSimEventArgs e) { switch (e.value) { case 0: StartStopButton.Background = Brushes.Green; ContentBlock1.Text = "Start randomly\non route"; StartStopFirstPointButton.IsEnabled = true; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate -= HandleLogUpdate; } break; case 1: StartStopButton.Background = Brushes.Red; ContentBlock1.Text = "Stop\nSimulation"; StartStopFirstPointButton.IsEnabled = false; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } break; case 2: StartStopFirstPointButton.Background = Brushes.Green; ContentBlock2.Text = "Start at\nbeginning\nof route"; StartStopButton.IsEnabled = true; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } break; case 3: StartStopFirstPointButton.Background = Brushes.Red; ContentBlock2.Text = "Stop simulation"; StartStopButton.IsEnabled = false; foreach (Bus bs in SimulationConfig.RunningBusses) { bs.log.LogUpdate += HandleLogUpdate; } break; default: break; } }