Exemplo n.º 1
0
 /// <summary>
 /// Clearing user inputs
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ResetButton_Click(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
     WeightTextBox.Clear();
     BMIResultTextBox.Clear();
     BMIScaleTextBox.Clear();
 }
 /// <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();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Method for clearing the textboxes in the form
 /// </summary>
 private void ClearForm()
 {
     WeightTextBox.Clear();
     HeightTextBox.Clear();
     //BMITextbox.Clear();
     CalculateButton.Enabled = false;
 }
Exemplo n.º 4
0
        private void BMI_CalculatorButton_Click(object sender, EventArgs e)
        {
            if (this.ActiveError == false)
            {
                // create a reference to the sender object
                // and tell c-sharp that it is a button
                Button buttonClicked = (Button)sender;

                if (String.Equals(HeightTextBox.Text, "0"))
                {
                    HeightTextBox.Clear();
                }
                if (String.Equals(WeightTextBox.Text, "0"))
                {
                    WeightTextBox.Clear();
                }

                if (TextBoxFocus == true)
                {
                    string HeightResult = HeightTextBox.Text; // read the string in the TextBox
                    HeightResult      += buttonClicked.Text;  // add the text of the button clicked to the currentResult
                    HeightTextBox.Text = HeightResult;        // update the ResultTextBox
                    this.ActiveControl = HeightTextBox;
                }
                else if (TextBoxFocus == false)
                {
                    string WeightResult = WeightTextBox.Text; // read the string in the TextBox
                    WeightResult      += buttonClicked.Text;  // add the text of the button clicked to the currentResult
                    WeightTextBox.Text = WeightResult;        // update the ResultTextBox
                    this.ActiveControl = WeightTextBox;
                }
            }
        }
 /// <summary>
 /// This method clears all the fields in the form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ClearButton_Click_1(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
     WeightTextBox.Clear();
     BMIResultTextBox.Clear();
     BMIScaleTextBox.Clear();
     HeightTextBox.Focus();
 }
Exemplo n.º 6
0
 /// <summary>
 /// This method sets the background color to white and clears all textboxes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void clearButton_Click(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
     WeightTextBox.Clear();
     BMITextbox.Clear();
     BMIScaleMultiLineTextBox.Clear();
     BMIScaleMultiLineTextBox.BackColor = Color.White;
 }
Exemplo n.º 7
0
 private void CancelButton_Click(object sender, RoutedEventArgs e)
 {
     BMIStatusIcon.Source           = new BitmapImage(new Uri("/Images/BMIIcons/bmi-underweight-icon.png", UriKind.Relative));
     BMIStatusText.Text             = "Недостаточный";
     BMIStatusArrow.RenderTransform = new TranslateTransform(48, 0);
     BMIStatusNumber.Text           = "0.0";
     HeightTextBox.Clear();
     WeightTextBox.Clear();
 }
Exemplo n.º 8
0
 /// <summary>
 /// This is the where the reset button clears all the current information in each text box.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ResetButton_Click(object sender, EventArgs e)
 {
     WeightTextBox.Clear();
     HeightTextBox.Clear();
     BMIResultTextBox.Clear();
     MetricRadioButton.Checked   = false;
     ImperialRadioButton.Checked = true;
     ProgressBar.Value           = 10;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Set controls value as defult
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ResetButton_Click(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
     WeightTextBox.Clear();
     BmiTextBox.Clear();
     ResultTextBox.Clear();
     BmiProgressBar.Value        = 0;
     ImperialRadioButton.Checked = true;
     ImperialRadioButton.Focus();
 }
Exemplo n.º 10
0
        // CLEAR BUTTON
        private void ClearButton_Click_1(object sender, EventArgs e)
        {
            //clear fields
            HeightTextBox.Clear();
            WeightTextBox.Clear();
            ResultTextBox.Clear();
            ResultInfoTextBox.Clear();


            //enable textboxes
            HeightTextBox.Enabled = true;
            WeightTextBox.Enabled = true;
        }
Exemplo n.º 11
0
        /// <summary>
        /// This is an event handler to trigger a Click Event that will reset all of radio buttons and text boxes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResetButton_Click(object sender, EventArgs e)
        {
            //Clear the textboxes
            WeightTextBox.Clear();
            HeightTextBox.Clear();
            BMIResultTextBox.Clear();

            //Change the radio buttons to their original state
            ImpericalRadioButton.Checked = true;
            MetricRadioButton.Checked    = false;

            //Hide error label
            BMIResultLabel.Visible = false;
        }
Exemplo n.º 12
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            BMRTextBlock.Text = "0";

            SittingActivityTextBlock.Text = $"Сидячий образ: 0";
            LowActivityTextBlock.Text     = $"Маленькая активность: 0";
            MediumActivityTextBlock.Text  = $"Средняя активность: 0";
            HighActivityTextBlock.Text    = $"Высокая активность: 0";
            MaxActivityTextBlock.Text     = $"Максимальная активность 0";

            HeightTextBox.Clear();
            WeightTextBox.Clear();
            AgeTextBox.Clear();
        }
 /// <summary>
 /// This method checks of the value entered is valid.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonCalculate_Click(object sender, EventArgs e)
 {
     try
     {
         height = Convert.ToDouble(HeightTextBox.Text);
         weight = Convert.ToDouble(WeightTextBox.Text);
         CalculateBMI(height, weight);
     }
     catch (Exception)
     {
         MessageBox.Show("Invalid number");
         HeightTextBox.Clear();
         WeightTextBox.Clear();
         HeightTextBox.Focus();
     }
 }
Exemplo n.º 14
0
 private void HeightTextBox_Enter(object sender, EventArgs e)
 {
     HeightTextBox.Clear();
 }
Exemplo n.º 15
0
        //Submit button
        private void button1_Click(object sender, EventArgs e)
        {
            //First Name validiation and parsing
            string firstName = firstNameTextBox.Text;

            if (firstName.Length < 1 || firstName.Length > 32)
            {
                MessageBox.Show("First Name must be between 1-32 characters long");
                return;
            }
            if (!Regex.IsMatch(firstName, @"^[a-zA-Z]+$"))
            {
                MessageBox.Show("First Name can only contain alphabetic characters");
                return;
            }

            //Last Name validiation and parsing
            string lastName = lastNameTextBox.Text;

            if (lastName.Length < 1 || lastName.Length > 32)
            {
                MessageBox.Show("Last Name must be between 1-32 characters long");
                return;
            }
            if (!Regex.IsMatch(lastName, @"^[a-zA-Z]+$"))
            {
                MessageBox.Show("Last Name can only contain alphabetic characters");
                return;
            }

            //BattleRosterNumber validation and parsing
            string battleRosterNumber = battleRosterNumberTextBox.Text;

            if (!Regex.IsMatch(battleRosterNumber, @"^[A-Z][A-Z][0-9][0-9][0-9][0-9]$"))
            {
                MessageBox.Show("Battle Roster Number must first 2 intials of last name in upercase and last 4 SSN numbers. (ie. AB1234)");
                return;
            }

            //Height validation and parsing
            float height;

            if (float.TryParse(HeightTextBox.Text, out height))
            {
                if (height < 1.0 || height > 12.0)
                {
                    MessageBox.Show("Enter a valid height");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter a valid height");
                return;
            }

            //Weight validation and parsing
            float weight;

            if (float.TryParse(WeightTextBox.Text, out weight))
            {
                if (weight < 1.0 || weight > 600.0)
                {
                    MessageBox.Show("Enter a valid weight");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter a valid weight");
                return;
            }

            //Age validation and parsing
            int age;

            if (int.TryParse(AgeTextBox.Text, out age))
            {
                if (age < 17 || age > 110)
                {
                    MessageBox.Show("Enter a valid age");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter a valid age");
                return;
            }

            //Heat Casualty selection
            bool heatCat = true;

            if (HeatCatNoRadioButton.Checked)
            {
                heatCat = false;
            }
            if (HeatCatYesRadioButton.Checked)
            {
                heatCat = true;
            }

            //Male Female selection
            char sex = 'M';

            if (SexMaleRadioButton.Checked)
            {
                sex = 'M';
            }
            if (SexFemaleRadioButton.Checked)
            {
                sex = 'F';
            }

            //Add data to the xmloader class
            Solider solider = new Solider(firstName, lastName, battleRosterNumber, heatCat, height, weight, sex);

            Program.xLoader.AddSoliderToRoster(solider);

            //Clear all data from textboxs and reset radio buttons
            firstNameTextBox.Clear();
            lastNameTextBox.Clear();
            battleRosterNumberTextBox.Clear();
            HeightTextBox.Clear();
            WeightTextBox.Clear();
            AgeTextBox.Clear();
            HeatCatYesRadioButton.Checked = true;
            SexMaleRadioButton.Checked    = true;

            //Hide Form and return to previous form
            menuButtonPressed = true;
            FormProvider.AddSolider.Close();
            FormProvider.RosterDisplay.Show();
        }
Exemplo n.º 16
0
        private void CalculateBMI_Click(object sender, EventArgs e)
        {
            //initialize variables
            double result;
            double height;
            double weight;

            try
            {
                if (HeightTextBox.Text == "" || WeightTextBox.Text == "")
                {
                    MessageBox.Show("Fields can not be empty, please fill them out");

                    if ((HeightTextBox.Text == "") || (HeightTextBox.Text == "" && WeightTextBox.Text == ""))
                    {
                        HeightTextBox.Focus();
                    }
                    else
                    {
                        WeightTextBox.Focus();
                    }
                }

                try
                {
                    height = Convert.ToDouble(HeightTextBox.Text);
                    weight = Convert.ToDouble(WeightTextBox.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Please type numbers");
                    HeightTextBox.Clear();
                    WeightTextBox.Clear();
                    HeightTextBox.Focus();
                }

                height = Convert.ToDouble(HeightTextBox.Text);
                weight = Convert.ToDouble(WeightTextBox.Text);

                if (imperialRadBtn.Checked == true)
                {
                    result             = ((weight * 703)) / ((height * height));
                    ResultTextBox.Text = Convert.ToString(result);

                    if (result < 18.5)
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Underweight");
                    }

                    if ((result > 18.5) && (result < 24.9))
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Normal");
                    }

                    if ((result > 25) && (result < 29.9))
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Overweight");
                    }

                    if (result > 30)
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Obese");
                    }
                }
                else if (metricRadBnt.Checked == true)
                {
                    result             = (weight / (height * height));
                    ResultTextBox.Text = Convert.ToString(result);

                    if (result < 18.5)
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Underweight");
                    }

                    if ((result > 18.5) && (result < 24.9))
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Normal");
                    }

                    if ((result > 25) && (result < 29.9))
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Overweight");
                    }

                    if (result > 30)
                    {
                        ResultInfoTextBox.Text = Convert.ToString("Obese");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Press OK");
            }
        }