Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Request button clicked
            RequestButton.TouchUpInside += (object sender, EventArgs e) => {
                //Resign first responders
                NameTextBox.ResignFirstResponder();
                CurrentLocationTextBox.ResignFirstResponder();
                DestinationTextBox.ResignFirstResponder();

                //Get user information
                string name           = NameTextBox.Text;
                string fromLocation   = CurrentLocationTextBox.Text;
                string toLocation     = DestinationTextBox.Text;
                string additionalInfo = AdditionalInfoTextBox.Text;

                SVC.RequestButtonClicked(name, fromLocation, toLocation, additionalInfo);
            };

            //Feedback button clicked
            FeedbackButton.TouchUpInside += (object sender, EventArgs e) => {
                UIApplication.SharedApplication.OpenUrl(new NSUrl("https://docs.google.com/forms/d/e/1FAIpQLSdeB7-BxZh4oWTGqrMGMUL4wu0ufQRKmEyNvwKGfzXt8OdZYQ/viewform?usp=sf_link"));
            };
        }
Beispiel #2
0
        /*
         * CalculateButton_click method handles all of the math and text manipulation
         * */
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            // local variables
            float gasConsumed    = -1;
            float milesTravelled = -1;

            // only calculate if the text boxes actually have text in them
            if ((MilesTravelledTextBox.Text.Length > 0) && (GallonsConsumedTextBox.Text.Length > 0) && (DestinationTextBox.Text.Length > 0))
            {
                // reset the error message if there is one viewable
                ErrorLabel.Text = "";
                while (float.TryParse(MilesTravelledTextBox.Text, out milesTravelled) == false)
                {
                    ErrorLabel.Text            = "Miles Travelled value entered must be numeric.";
                    MilesTravelledTextBox.Text = "0.0";
                    MilesTravelledTextBox.Focus();
                }
                while (float.TryParse(GallonsConsumedTextBox.Text, out gasConsumed) == false)
                {
                    ErrorLabel.Text             = "Gallons consumed value entered must be numeric.";
                    GallonsConsumedTextBox.Text = "0.0";
                    GallonsConsumedTextBox.Focus();
                }

                // make sure the variables are greater than 0 so we don't divide by 0
                if ((milesTravelled > 0) && (gasConsumed > 0))
                {
                    MPGLabel.Text   = milesTravelled / gasConsumed + " mpg";
                    ErrorLabel.Text = "";
                }
                else
                {
                    ErrorLabel.Text = "Please insert only numbers with values greater than 0";
                }
            }
            else // focus on the problem
            {
                ErrorLabel.Text = "Please fill out all of the boxes.";
                if (DestinationTextBox.Text.Length <= 0)
                {
                    DestinationTextBox.Focus();
                }
                else if (MilesTravelledTextBox.Text.Length <= 0)
                {
                    MilesTravelledTextBox.Focus();
                }
                else if (GallonsConsumedLabel.Text.Length <= 0)
                {
                    GallonsConsumedLabel.Focus();
                }
            }
        }
        private void OnBrowseButtonClick(object?sender, RoutedEventArgs e)
        {
            using var dialog = new System.Windows.Forms.FolderBrowserDialog
                  {
                      Description            = "Select destination",
                      UseDescriptionForTitle = true,
                      SelectedPath           = DestinationTextBox.Text,
                  };

            if (dialog.ShowDialog(owner: this) == System.Windows.Forms.DialogResult.OK)
            {
                DestinationTextBox.UpdateBinding(TextBox.TextProperty, dialog.SelectedPath);
            }
        }
Beispiel #4
0
        private void SelectDestinationButton_Click(object sender, EventArgs e)
        {
            using (var sf = new SaveFileDialog {
                Filter = Consts.FirmwareFilter, FileName = GetDestinationFileName()
            })
            {
                if (sf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                DestinationTextBox.Text = sf.FileName;
                DestinationTextBox.ScrollToEnd();
            }
        }
Beispiel #5
0
        void ReleaseDesignerOutlets()
        {
            if (AdditionalInfoTextBox != null)
            {
                AdditionalInfoTextBox.Dispose();
                AdditionalInfoTextBox = null;
            }

            if (CurrentLocationTextBox != null)
            {
                CurrentLocationTextBox.Dispose();
                CurrentLocationTextBox = null;
            }

            if (DestinationTextBox != null)
            {
                DestinationTextBox.Dispose();
                DestinationTextBox = null;
            }

            if (FeedbackButton != null)
            {
                FeedbackButton.Dispose();
                FeedbackButton = null;
            }

            if (NameTextBox != null)
            {
                NameTextBox.Dispose();
                NameTextBox = null;
            }

            if (RequestButton != null)
            {
                RequestButton.Dispose();
                RequestButton = null;
            }
        }
Beispiel #6
0
 /// <summary>
 /// Enters the preferred destination in the text box
 /// </summary>
 /// <param name="destination">Preferred city of stay</param>
 public void EnterDestination(string destination)
 {
     DestinationTextBox.SendKeys(destination);
 }