private void ChangeSimulationSpeed() { bool fastMode = checkBoxFastMode.Checked; if (fastMode) { simulation.SetMaxSimSpeed(); return; } double duration = trackBarDuration.Value; double interval = trackBarInterval.Value; simulation.SetSimSpeed(interval, duration / 1000); }
private void buttonRun_Click(object sender, System.EventArgs e) { try { NumberOfReplications = Int32.Parse(TextBoxReplications.Text); } catch (Exception ex) { MessageBox.Show("Enter a valid number of replications", "Invalid format", MessageBoxButtons.OK); return; } try { GeneratorSeed = Int32.Parse(textBoxSeed.Text); // simulation start int userSeed = 0; if (userSeed > 0 || textBoxSeed.Text != "") { Constants.Seed = userSeed; } else { Constants.Seed = 0; } } catch (Exception ex) { MessageBox.Show("Enter a valid generator seed", "Invalid format", MessageBoxButtons.OK); return; } _first = true; DisableChanges(); Sim = new MySimulation(); Sim.SetSimSpeed(_interval, _duration); Sim.AgentModelu.SelectedCars = SelectedCars; System.Action <MySimulation> updateGuiAction = new System.Action <MySimulation>((s) => UpdateGui(s)); System.Action <MySimulation> ReplicationFinished = new Action <MySimulation>((s) => UpdateUIAfterReplication()); System.Action <MySimulation> SimulationFinished = new Action <MySimulation>((s) => UpdateUIAfterSimulation()); Sim.OnReplicationDidFinish(simulation => simulation.InvokeAsync(UpdateUIAfterReplication)); Sim.OnSimulationDidFinish(simulation => simulation.InvokeAsync(UpdateUIAfterSimulation)); try { Sim.OnRefreshUI(s => this.Invoke(updateGuiAction, s)); } catch (Exception ex) { throw ex; } // 777 600 Sim.SimulateAsync(NumberOfReplications, 788400); DrawChart(); System.Action <MySimulation> enableChangesAction = new Action <MySimulation>((s) => EnableChanges()); // nefunguje //Sim.OnSimulationDidFinish(s => this.Invoke(enableChangesAction)); }