private void OnSimulationDone(object sender, EventArgs args)
 {
     ProgressBar.Value = Simulation.MsInDay;
     ProcessLabel.Text = "Success";
     InformationWriteLine("Simulation saved as: " + Simulation.Filename);
     Simulation = null;
     Cancel.Enabled = false;
 }
 private void OnFormClosing(object sender, EventArgs args)
 {
     if (Cancel.Enabled)
     {
         Simulation.Cancel();
         Simulation = null;
         Cancel.Enabled = false;
     }
 }
 public GUIMenuSimulationRun(Project project)
 {
     Project = project;
     Setup();
     Simulation = new Simulation(project);
     Simulation.PrimaryWorker.ProgressChanged += PrimaryProgressChanged;
     Simulation.SecondaryWorker.ProgressChanged += SecondaryProgressChanged;
     Simulation.SimulationDone += OnSimulationDone;
     FormClosing += OnFormClosing;
 }
 private void StartClick(object sender, EventArgs args)
 {
     Start.Enabled = false;
     Cancel.Enabled = true;
     try
     {
         InformationWriteLine("Simulating...");
         Simulation.Run();
     }
     catch (Exception e)
     {
         InformationWriteLine("ERROR: " + e.Message);
         ProcessLabel.Text = "Failure";
         Simulation = null;
         Cancel.Enabled = false;
     }
 }