You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
namespace Phoneword
|
|
|
|
|
{
|
|
|
|
|
public partial class MainPage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
string _translatedNumber;
|
|
|
|
|
|
|
|
|
|
public MainPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TranslateButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string enteredNumber = PhoneNumberText.Text;
|
|
|
|
|
_translatedNumber = PhonewordTranslator.ToNumber(enteredNumber);
|
|
|
|
|
if (!string.IsNullOrEmpty(_translatedNumber))
|
|
|
|
|
{
|
|
|
|
|
CallButton.IsEnabled = true;
|
|
|
|
|
CallButton.Text = $"Call {_translatedNumber}";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CallButton.IsEnabled = false;
|
|
|
|
|
CallButton.Text = "Call";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void CallButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (await this.DisplayAlert(
|
|
|
|
|
"Dial a Number",
|
|
|
|
|
$"Would you like to call {_translatedNumber}?",
|
|
|
|
|
"Yes",
|
|
|
|
|
"No"))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (PhoneDialer.Default.IsSupported)
|
|
|
|
|
PhoneDialer.Default.Open(_translatedNumber);
|
|
|
|
|
}
|
|
|
|
|
catch (ArgumentNullException)
|
|
|
|
|
{
|
|
|
|
|
await DisplayAlert("Unalble to dial", "Phone was not valid.", "OK");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
await DisplayAlert("Unalble to dial", "Phone dialing failed.", "OK");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|