/// <summary> /// The event triggered when Convert button is clicked /// </summary> /// <param name="sender">The sender object</param> /// <param name="e">The event arggs</param> private void Button_Click(object sender, RoutedEventArgs e) { if (txtNumber.Text != string.Empty && Format.IsMatch(txtNumber.Text)) { double.TryParse(txtNumber.Text.Replace(",", "."), out var result); if (result > Maxim) { FormatTxtResultAsError(ErrorMessage); } else { try { var converterServiceClient = new ConverterServiceClient(); var response = converterServiceClient.ConvertNumberToWords(result); txtResult.Text = response; FormatTxtResultAsCorrect(); } catch (Exception exception) { FormatTxtResultAsError(exception.Message); } } } else { FormatTxtResultAsError(ErrorMessage); } }
public MainViewModel() { convertionResult = Properties.Resources.DefaultConvertionResultText; convertCommand = new ButtonCommand(ConvertText, null); service = new ConverterServiceClient(); }