Esempio n. 1
0
        async void OnAddressChanged(object sender, EventArgs eventArgs)
        {
            if (!String.IsNullOrEmpty(AddressEntry.Text))
            {
                if (addressToValidate != null)
                {
                    if (addressToValidate.Street != AddressEntry.Text)
                    {
                        addressList.ItemsSource = await addr.GetPlacesPredictionsAsync(AddressEntry.Text);

                        addressEntryFocused(sender, eventArgs);
                    }
                }
                else
                {
                    addressList.ItemsSource = await addr.GetPlacesPredictionsAsync(AddressEntry.Text);

                    addressEntryFocused(sender, eventArgs);
                }
            }
            else
            {
                addressEntryUnfocused(sender, eventArgs);
                addressToValidate = null;
            }
        }
        async void addressSelected(System.Object sender, SelectedItemChangedEventArgs e)
        {
            StreetEntry.TextChanged      -= OnAddressChanged;
            addressToValidate             = addr.addressSelected(AddressListView, StreetEntry, addressFrame);
            addressToValidate.isValidated = false;
            StreetEntry.Text = addressToValidate.Street;
            string zipcode = await addr.getZipcode(addressToValidate.PredictionID);

            if (zipcode != null)
            {
                addressToValidate.ZipCode = zipcode;
            }
            StreetEntry.TextChanged += OnAddressChanged;
            ValidateAddress(sender, e);
        }
        async void OnAddressChanged(object sender, EventArgs eventArgs)
        {
            var entry = (Entry)sender;
            var frame = (Frame)entry.Parent;

            if (displayAddress)
            {
                if (!String.IsNullOrEmpty(StreetEntry.Text))
                {
                    if (frame.BorderColor == Color.LightGray)
                    {
                        frame.BorderColor = Color.Red;
                    }

                    if (addressToValidate != null)
                    {
                        if (addressToValidate.Street != StreetEntry.Text)
                        {
                            AddressListView.ItemsSource = await addr.GetPlacesPredictionsAsync(StreetEntry.Text);

                            addressEntryFocused(sender, eventArgs);
                        }
                    }
                    else
                    {
                        AddressListView.ItemsSource = await addr.GetPlacesPredictionsAsync(StreetEntry.Text);

                        addressEntryFocused(sender, eventArgs);
                    }
                }
                else
                {
                    if (frame.BorderColor == Color.Red)
                    {
                        frame.BorderColor = Color.LightGray;
                        SetAccountValues(entry.ClassId, null);
                    }

                    addressEntryUnfocused(sender, eventArgs);
                    addressToValidate = null;
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(entry.Text))
                {
                    if (frame.BorderColor == Color.LightGray)
                    {
                        frame.BorderColor = Color.Red;
                    }
                }
                else
                {
                    if (frame.BorderColor == Color.Red)
                    {
                        frame.BorderColor = Color.LightGray;
                        SetAccountValues(entry.ClassId, null);
                    }
                }
            }
        }