private void Simulate_Click(object sender, EventArgs e) { SimulationSystem ss = new SimulationSystem { DowntimeCost = (int)DC_numeric.Value, RepairPersonCost = (int)RPC_numeric.Value, BearingCost = (int)BC_numeric.Value, NumberOfHours = (int)NH_numeric.Value, NumberOfBearings = (int)NB_numeric.Value, RepairTimeForOneBearing = (int)RT1B_numeric.Value, RepairTimeForAllBearings = (int)RTAB_numeric.Value }; int convertedTime; decimal convertedProbability; var DTD = DTD_textbox.Text.Split('\n'); var BTD = BLD_textbox.Text.Split('\n'); foreach (var dtd in DTD) { string[] spliced = dtd.Split(','); if (spliced.Length == 2 && int.TryParse(spliced[0], out convertedTime) && decimal.TryParse(spliced[1], out convertedProbability)) { ss.DelayTimeDistribution.Add(new TimeDistribution { Time = convertedTime, Probability = convertedProbability }); } } foreach (var btd in BTD) { var spliced = btd.Split(','); if (spliced.Length == 2 && int.TryParse(spliced[0], out convertedTime) && decimal.TryParse(spliced[1], out convertedProbability)) { ss.BearingLifeDistribution.Add(new TimeDistribution { Time = convertedTime, Probability = convertedProbability }); } } ss.CalculateBearingLifeDistribution(); ss.CalculateDelayTimeDistribution(); ss.InitBearings(); ss.CurrentSimulationTable = ss.GenerateCurrentSimulationCase(); ss.ProposedSimulationTable = ss.GenerateProposedSimulationCase(); ss.CurrentPerformanceMeasures = ss.SolveCurrentSimulationCase(); ss.ProposedPerformanceMeasures = ss.SolveProposedSimulationCase(); if (File.Exists("TestCases\\" + TC_list.Text)) { var testingResult = TestingManager.Test(ss, TC_list.Text); MessageBox.Show(testingResult); ResultsForm resultsForm = new ResultsForm(ss); resultsForm.ShowDialog(this); } }