Exemplo n.º 1
0
 private void Start()
 {
     weight    = GameObject.Find("Weight").GetComponent <WeightInput>();
     player    = GameObject.Find("Player");
     renderer  = GetComponent <Renderer>();
     activated = false;
 }
Exemplo n.º 2
0
 private void Start()
 {
     weight     = GetComponentInParent <WeightInput>();
     player     = GameObject.Find("Player");
     clicking   = false;
     unclicking = false;
     active     = false;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Checks that the Weight input field only has numeric characters and .'s
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void WeightInput_TextChanged(object sender, EventArgs e)
 {
     if (!(System.Text.RegularExpressions.Regex.IsMatch(WeightInput.Text, @"^((\+|\-)?(\d)([0-9])*)?\.?([0-9])*$")) && WeightInput.Text.Length > 0)
     {
         MessageBox.Show("Only numeric data is allowed");
         WeightInput.Clear();
     }
 }
Exemplo n.º 4
0
        public void WriteWeightMat(string basePath)
        {
            var wiPath = basePath + "_WI.csv";
            var woPath = basePath + "_WO.csv";

            WeightInput.WriteTo(wiPath);
            WeightOutput.WriteTo(woPath);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //add observer to include "kg" in textfield after weight when numbers are inserted
            NSNotificationCenter.DefaultCenter.AddObserver(
                UITextField.TextDidBeginEditingNotification, (notification) => {
                WeightInput.Text              = " kg";
                var indexToSet                = WeightInput.Text.Length - 3;
                var positionToSet             = WeightInput.GetPosition(WeightInput.BeginningOfDocument, indexToSet);
                WeightInput.SelectedTextRange = WeightInput.GetTextRange(positionToSet, positionToSet);
            });

            CalcButton.TouchUpInside += CalcButton_TouchUpInside;
        }
 //Calculate optimal daily drinking amount when button is pressed
 private void CalcButton_TouchUpInside(object sender, EventArgs e)
 {
     if ((!string.IsNullOrEmpty(WeightInput.Text)) && (WeightInput.Text != (" kg")))
     {
         WeightInput.ResignFirstResponder();
         calcWeightInKg       = WeightInput.Text.Remove(WeightInput.Text.Length - 3, 3);
         calculatedAmount     = Convert.ToString(int.Parse(calcWeightInKg) * mlToDrinkPerKg);
         WaterOuputLabel.Text = calculatedAmount + " ml";
     }
     else if (string.IsNullOrEmpty(WeightInput.Text))
     {
         UIAlertController alertController = UIAlertController.Create("Nothing to calculate", "Please insert your weight.", UIAlertControllerStyle.Alert);
         alertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null));
         PresentViewController(alertController, true, null);
     }
 }