/// <summary>
 /// This is the reset method which clears the form whenever the click button is pressed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ResetButton_Click(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
     WeightTextBox.Clear();
     resultTextBox.Clear();
     BMIProgressBar.Hide();
 }
        /// <summary>
        /// This is the CalculateBMIButton_Click method which performs the calculation
        /// whenever the calculate bmi button is pressed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            double height = double.Parse(HeightTextBox.Text);
            double weight = double.Parse(WeightTextBox.Text);

            Calculate_BMI(height, weight);

            if (this.RESULT > 30)
            {
                BMIProgressBar.Value     = BMIProgressBar.Maximum;
                ResultListBox.Text       = "Obese: 30 or greater";
                BMIProgressBar.ForeColor = Color.Red;
            }
            else if (this.RESULT > 24.9 && this.RESULT < 30)
            {
                BMIProgressBar.Value     = (int)this.RESULT;
                ResultListBox.Text       = "Overweight: Between 25 and 29.5";
                BMIProgressBar.ForeColor = Color.Orange;
            }
            else if (this.RESULT > 18.5 && this.RESULT < 24.9)
            {
                BMIProgressBar.Value     = (int)this.RESULT;
                ResultListBox.Text       = "Normal: Between 18.5 and 24.9";
                BMIProgressBar.ForeColor = Color.Green;
            }
            else
            {
                BMIProgressBar.Value     = (int)this.RESULT;
                ResultListBox.Text       = "Underweight: Less then 18.5";
                BMIProgressBar.ForeColor = Color.LightGreen;
            }
            BMIProgressBar.Show();
        }
 private void ClearButton_Click(object sender, EventArgs e)
 {
     HeightTextBox.Text = "";
     WeightTextBox.Text = "";
     resultTextBox.Text = "";
     BMIProgressBar.Hide();
 }
Ejemplo n.º 4
0
 private void calculateBMIButton_Click(object sender, EventArgs e)
 {
     if (MetricRadioButton.Checked)
     {
         BMI = Weight / (Height * Height);
     }
     else if (ImperialRadioButton.Checked)
     {
         BMI = (Weight * 703) / (Height * Height);
     }
     BMI = Math.Round(BMI, 1);
     BMIScaleTextBox.Visible = true;
     BMITextBox.Visible      = true;
     BMITextBox.Text         = "" + BMI;
     BMIProgressBar.Visible  = true;
     BMIProgressBar.Increment(-100);
     BMIProgressBar.Value = Convert.ToInt32(BMI);
 }
Ejemplo n.º 5
0
        private void ProgressBar(double bmi)
        {
            // References https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.progressbar?view=netframework-4.8
            // Display the ProgressBar control.
            BMIProgressBar.Visible = true;
            // Set Minimum to 1 to represent the first file being copied.
            BMIProgressBar.Minimum = 1;
            // Set Maximum to the total number of files to copy.
            BMIProgressBar.Maximum = 50;
            // Set the initial value of the ProgressBar.
            BMIProgressBar.Value = 1;
            // Set the Step property to a value of 1
            BMIProgressBar.Step = 1;

            // Loop through all files to copy.
            for (int x = 1; x <= bmi; x++)
            {
                {
                    // Perform the increment on the ProgressBar.
                    BMIProgressBar.PerformStep();
                }
            }
        }
 /// <summary>
 /// This is the private _bmiProgressBar method
 /// </summary>
 private void _bmiProgressBar()
 {
     if (this.RESULT > 30)
     {
         BMIProgressBar.Value     = BMIProgressBar.Maximum;
         BMIProgressBar.ForeColor = Color.Red;
     }
     else if (this.RESULT > 24.9)
     {
         BMIProgressBar.Value     = (int)this.RESULT;
         BMIProgressBar.ForeColor = Color.Orange;
     }
     else if (this.RESULT > 18.5)
     {
         BMIProgressBar.Value     = (int)this.RESULT;
         BMIProgressBar.ForeColor = Color.Green;
     }
     else
     {
         BMIProgressBar.Value     = (int)this.RESULT;
         BMIProgressBar.ForeColor = Color.LightGreen;
     }
     BMIProgressBar.Show();
 }