async void OnCall(object sender, System.EventArgs e)
 {
     if (await this.DisplayAlert(
             "Dial a Number",
             "Would you like to call " + translatedNumber + "?",
             "Yes",
             "No"))
     {
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
         }
         catch (FeatureNotSupportedException)
         {
             await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
         }
         catch (Exception)
         {
             // Other error has occurred.
             await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
         }
     }
 }
示例#2
0
 /// <summary>
 /// Handles the user pressing the call button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 async private void OnCall(object sender, EventArgs e)
 {
     Debug.WriteLine("In OnCall method..");
     // Have OK and Cancel buttons
     if (await this.DisplayAlert("Dial a number?", "Do you want to call " + translatedNumber + "?", "Yes", "No"))
     {
         //  Dial the phone number
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
         }
         catch (FeatureNotSupportedException)
         {
             await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
         }
         catch (Exception)
         {
             // Other error has occurred.
             await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
         }
     }
 }
示例#3
0
 private async void OnCall(object sender, EventArgs e)
 {
     if (await this.DisplayAlert(
             "Dial a number",
             $"Would you like to call {translatedNumber}",
             "Yes",
             "No"
             ))
     {
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await(DisplayAlert("Unable to dial", "Phone number was not valid.", "OK"));
         }
         catch (FeatureNotSupportedException)
         {
             await(DisplayAlert("Unable  to dial", "Phone dialing not supported.", "OK"));
         }
         catch (Exception)
         {
             await(DisplayAlert("Unable to call", "Phone dialing failed.", "OK"));
         }
     }
 }
示例#4
0
 async void OnCall(object sender, EventArgs e)
 {
     if (await this.DisplayAlert(
             "Marcar un número",
             "¿Quieres llamar a " + translatedNumber + "?",
             "Si",
             "No"
             ))
     {
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await DisplayAlert("No puedo llamar", "El numero de teléfono no es válido", "Ok");
         }
         catch (FeatureNotSupportedException)
         {
             await DisplayAlert("No puedo llamar", "Este teléfono no puede hacer llamadas", "Ok");
         }
         catch (Exception)
         {
             await DisplayAlert("No puedo llamar", "El discado de teléfono falló", "Ok");
         }
     }
 }
示例#5
0
 async private void OnCall(object sender, EventArgs e)
 {
     if (await DisplayAlert(
             "Dial a Number",
             "Would you like to call " + translatedNumber + "?",
             "Call",
             "Cancel"))
     {
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
         }
         catch (FeatureNotSupportedException)
         {
             await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
         }
         catch (Exception)
         {
             // uh-oh
             await DisplayAlert("Unable to dial", "Phone dialing failed", "OK");
         }
     }
 }
示例#6
0
 async void OnCall(object sender, System.EventArgs e)
 {
     if (await this.DisplayAlert(
             "Dial a Number",
             "You are calling " + translatedNumber + ", correct?",
             "Yes",
             "No"))
     {
         try
         {
             PhoneDialer.Open(translatedNumber);
         }
         catch (ArgumentNullException)
         {
             await DisplayAlert("Unable to dial", "An invalid number was entered.", "OK");
         }
         catch (FeatureNotSupportedException)
         {
             await DisplayAlert("Unable to dial", "Phone dialing used is no longer supported.", "OK");
         }
         catch (Exception)
         {
             // Other error has occurred.
             await DisplayAlert("Unable to dial", "Phone dialing has failed.", "OK");
         }
     }
 }
示例#7
0
 private async void OnCall(object sender, EventArgs e)
 {
     if (await DisplayAlert("Dial a Number",
                            $"Would you like to call {phoneNumber}?",
                            "Yes",
                            "No"))
     {
         PhoneDialer.Open(phoneNumber);
     }
 }
 private async void OnCall(object sender, EventArgs e)
 {
     if (await DisplayAlert("Dial a Number",
                            $"Would you like to call {phoneNumber}?",
                            "Yes",
                            "No"))
     {
         PhoneDialer.Open(phoneNumber);
         //await Sms.ComposeAsync(new SmsMessage("Teste sms", phoneNumber));
     }
 }
示例#9
0
        public MainPage()
        {
            Padding = new Thickness(20);

            Entry  phoneNumberText;
            Button translateButton;
            Button callButton;

            StackLayout panel = new StackLayout
            {
                Spacing = 15
            };

            panel.Children.Add(new Label
            {
                Text     = "Escreva o phoneword",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            });

            panel.Children.Add(phoneNumberText = new Entry
            {
                Text = "11WWWLURTA"
            });

            panel.Children.Add(translateButton = new Button
            {
                Text = "Traduzir"
            });

            panel.Children.Add(callButton = new Button
            {
                Text      = "Ligar",
                IsEnabled = false
            });


            translateButton.Clicked += (object sender, EventArgs e) =>
            {
                string enteredNumber = phoneNumberText.Text;
                translatedNumber = PhonewordTranslator.ToNumber(enteredNumber);

                if (!string.IsNullOrEmpty(translatedNumber))
                {
                    callButton.IsEnabled = true;
                    callButton.Text      = "Ligar para " + translatedNumber;
                }
                else
                {
                    callButton.IsEnabled = false;
                    callButton.Text      = "Ligar";
                }
            };

            callButton.Clicked += async(object sender, EventArgs e) =>
            {
                if (await this.DisplayAlert("Discar número", "Gostaria de ligar para " + translatedNumber + "?", "Sim", "Não"))
                {
                    try
                    {
                        PhoneDialer.Open(translatedNumber);
                    }
                    catch (ArgumentNullException)
                    {
                        await DisplayAlert("Não é possivel discar", "Telefone não é válido.", "OK");
                    }
                    catch (FeatureNotSupportedException)
                    {
                        await DisplayAlert("Não é possivel discar", "Discagem não é suportada.", "OK");
                    }
                    catch (Exception)
                    {
                        // Other error has occurred.
                        await DisplayAlert("Não é possivel discar", "Discagem falhou.", "OK");
                    }
                }
            };

            Content = panel;
        }
示例#10
0
        public MainPage()
        {
            this.Padding = new Thickness(20, 20, 20, 20);

            StackLayout panel = new StackLayout
            {
                Spacing = 15
            };

            panel.Children.Add(new Label
            {
                Text     = "Enter a Phoneword:",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            });

            panel.Children.Add(phoneNumberText = new Entry
            {
                Text = "1-855-XAMARIN",
            });

            panel.Children.Add(translateButton = new Button
            {
                Text = "Translate"
            });

            panel.Children.Add(callButton = new Button
            {
                Text      = "Call",
                IsEnabled = false,
            });

            translateButton.Clicked += OnTranslate;
            callButton.Clicked      += OnCall;
            this.Content             = panel;

            void OnTranslate(object sender, EventArgs e)
            {
                string enteredNumber = phoneNumberText.Text;

                translatedNumber = Core.PhonewordTranslator.ToNumber(enteredNumber);

                if (!string.IsNullOrEmpty(translatedNumber))
                {
                    callButton.IsEnabled = true;
                    callButton.Text      = "Call " + translatedNumber;
                }
                else
                {
                    callButton.IsEnabled = false;
                    callButton.Text      = "Call";
                }
            }

            async void OnCall(object sender, System.EventArgs e)
            {
                if (await this.DisplayAlert(
                        "Dial a Number",
                        "Would you like to call " + translatedNumber + "?",
                        "Yes",
                        "No"))
                {
                    try
                    {
                        PhoneDialer.Open(translatedNumber);
                    }
                    catch (ArgumentNullException)
                    {
                        await DisplayAlert("Unable to dial", "Phone number was not valid.", "OK");
                    }
                    catch (FeatureNotSupportedException)
                    {
                        await DisplayAlert("Unable to dial", "Phone dialing not supported.", "OK");
                    }
                    catch (Exception)
                    {
                        await DisplayAlert("Unable to dial", "Phone dialing failed.", "OK");
                    }
                }
            }
        }