private void clear1_Click(object sender, RoutedEventArgs e)
 {
     clearIsClicked = true;
     regexOverride  = true;
     Application.Current.Dispatcher.Invoke(() => { Waist1Measurement.Clear(); });
     Waist1Measurement.Focus();
     regexOverride = false;
 }
 //Decalres a BT measurement
 private void checkBox_Unchecked(object sender, RoutedEventArgs e)
 {
     regexOverride     = true;
     manualMeasurement = false;
     Application.Current.Dispatcher.Invoke(() => { Waist1Measurement.Clear(); Waist2Measurement.Clear(); Waist3Measurement.Clear(); });
     MessageBox.Show("You are now entering measurements with Bluetooth.");
     //////
     RunCleanUp();
     Waist1Measurement.Focus();
     ////////
     regexOverride = false;
 }
 bool regexOverride     = false;//allows usage of text box clear operations to delte old results by not having regex applied to user input
 private void checkBox_Checked(object sender, RoutedEventArgs e)
 {
     regexOverride     = true;
     manualMeasurement = true;
     Application.Current.Dispatcher.Invoke(() => { Waist1Measurement.Clear(); Waist2Measurement.Clear(); Waist3Measurement.Clear(); });
     MessageBox.Show("You are now entering measurements manually.\n\n" +
                     "Please ensure measurements are of 1 decimal place format\n\n" +
                     "For example, 80 cm should be inout as 80.0\n" +
                     "140 cm should be input as 140.0");
     //////
     RunCleanUp();
     Waist1Measurement.Focus();
     ///////
     regexOverride = false;
 }
        //Clears everything in the case of switching between manual input and bluetooth measurements.
        public void RunCleanUp()
        {
            //reset all measruements
            arrayMeasurements[1, 1] = null;
            arrayMeasurements[2, 1] = null;
            arrayMeasurements[3, 1] = null;
            arrayMeasurements[1, 6] = null;
            arrayMeasurements[2, 6] = null;
            arrayMeasurements[3, 0] = null;
            arrayMeasurements[3, 6] = null;
            arrayMeasurements[3, 2] = null;
            arrayMeasurements[3, 3] = null;
            arrayMeasurements[3, 4] = null;
            arrayMeasurements[3, 5] = null;

            //enable first 2 measurement fields
            Waist1Measurement.IsEnabled = true;
            Waist2Measurement.IsEnabled = true;
            clear1.IsEnabled            = true;
            clear2.IsEnabled            = true;

            if (manualMeasurement == true) //Enable the manualMeasurement == true button to perform submission calcs using the manually entered measurements and not timer entered measurements.
            {
                button.IsEnabled   = false;
                button.Visibility  = Visibility.Hidden;
                button1.IsEnabled  = false;
                button1.Visibility = Visibility.Hidden;
                button3.IsEnabled  = true;
                button3.Visibility = Visibility.Visible;
                button4.IsEnabled  = false;
                button4.Visibility = Visibility.Hidden;
            }
            else //Bluetooth measuring so setting initial button again.
            {
                button.IsEnabled   = true;
                button.Visibility  = Visibility.Visible;
                button1.IsEnabled  = false;
                button1.Visibility = Visibility.Hidden;
                button3.IsEnabled  = false;
                button3.Visibility = Visibility.Hidden;
                button4.IsEnabled  = false;
                button4.Visibility = Visibility.Hidden;
            }

            //clear visibility of all things related to taking the third measurement
            textBlock6.Visibility        = Visibility.Hidden;
            Waist3Measurement.Visibility = Visibility.Hidden;
            button1.Visibility           = Visibility.Hidden;
            textBlock7.Visibility        = Visibility.Hidden;
            textBlock8.Visibility        = Visibility.Hidden;
            clear3.Visibility            = Visibility.Hidden;
            Waist3Measurement.IsEnabled  = false;

            //Set focus to first measurement again
            Waist1Measurement.Focus();

            //Previous input used in Regex expressions for only allowing certain char input. Clearing these avoids duplication of previous inout values.
            previousInput      = "";
            previousInput1     = "";
            previousInput2     = "";
            clearIsClicked     = false;
            isThirdMeasurement = false;
        }