/// <summary> /// calculate the 1 rep max bench /// </summary> private void btn_CalculateMaxBench_Click(object sender, EventArgs e) { double weight = 0; double value; double maxWeight; int maxBench; int reps = 0; string validationFeedback; string userMessage = null; string unit = "lbs"; // // assign max weight values based on selected button // if (radBtn_Lbs.Checked == true) { maxWeight = MAX_WEIGHT_LBS; } else { maxWeight = MAX_WEIGHT_KG; unit = "Kg"; } // // validate user input weight and build out the feedback message // if (!ValidateUserInput(txtBox_weight.Text, maxWeight, out value, out validationFeedback)) { userMessage += "The Weight" + validationFeedback + Environment.NewLine; txtBox_weight.Text = null; } else { weight = value; reps = (int)btn_numReps.Value; } if (userMessage != null) { //lbl_ErrorMessage.Text = userMessage; MessageBox.Show(userMessage); } // // open the SolutionForm // else { maxBench = MaxBench(weight, reps); Form solutionForm = new form_Solution(new SolutionFormInfo(maxBench, unit)); solutionForm.FormBorderStyle = FormBorderStyle.FixedDialog; solutionForm.MaximizeBox = false; solutionForm.MinimizeBox = false; solutionForm.ShowDialog(); solutionForm.Dispose(); } }
/// <summary> /// calculate the number of people who fit /// </summary> private void btn_CalculatePeople_Click(object sender, EventArgs e) { double length = 0, width = 0, height = 0; double value; double maxDimension; int numberOfPeople; string validationFeedback; string userMessage = null; // // validate dimensions and return values // if (radBtn_English.Checked == true) { maxDimension = MAX_DIMENSION_FT; } else { maxDimension = MAX_DIMENSION_M; } // // validate each user input and build out the feedback message // if (!ValidateUserInput(txtBox_Length.Text, maxDimension, out value, out validationFeedback)) { userMessage += "The Length" + validationFeedback + Environment.NewLine; txtBox_Length.Text = null; } else { length = value; } if (!ValidateUserInput(txtBox_Width.Text, maxDimension, out value, out validationFeedback)) { userMessage += "The Width" + validationFeedback + Environment.NewLine; txtBox_Width.Text = null; } else { width = value; } if (!ValidateUserInput(txtBox_Height.Text, maxDimension, out value, out validationFeedback)) { userMessage += "The Height" + validationFeedback + Environment.NewLine; txtBox_Height.Text = null; } else { height = value; } if (userMessage != null) { //lbl_ErrorMessage.Text = userMessage; MessageBox.Show(userMessage); } // // open the SolutionForm // else { numberOfPeople = NumberOfPeople(length, width, height); Form solutionForm = new form_Solution(new SolutionFormInfo(numberOfPeople, cmbBox_BodyType.Text)); solutionForm.FormBorderStyle = FormBorderStyle.FixedDialog; solutionForm.MaximizeBox = false; solutionForm.MinimizeBox = false; solutionForm.ShowDialog(); solutionForm.Dispose(); } }