예제 #1
0
        private async void CurrentCostButton_Click(object sender, EventArgs e)
        {
            var currencies = new[] { cryptoBtc, cryptoDot, cryptoEth, cryptoLtc, cryptoXmr };

            try
            {
                foreach (var currency in currencies)
                {
                    string price = await CoinPaprika.GetCoinInfo(currency.CryptoTitle, currency.CryptoName);

                    currency.CryptoValue = price;
                }
            }
            catch (Exception exception)
            {
                string messageBoxText = $"{exception.Message}\r\n1. Check the entered value.\r\n2. Check your internet connection.";
                MessageBox.Show(messageBoxText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #2
0
        private async void ConvertButton_Click(object sender, EventArgs e)
        {
            var baseCurrencyName  = coinsComboBoxFirst.SelectedItem.ToString();
            var quoteCurrencyName = coinsComboBoxSecond.SelectedItem.ToString();

            var baseCurrencyTitle  = FindTitleByName(baseCurrencyName);
            var quoteCurrencyTitle = FindTitleByName(quoteCurrencyName);

            try
            {
                var convertResult = await CoinPaprika.Convert(string.Concat(new[] { baseCurrencyTitle, "-", baseCurrencyName }),
                                                              string.Concat(new[] { quoteCurrencyTitle, "-", quoteCurrencyName }),
                                                              Convert.ToDouble(inputTextBox.Text, CultureInfo.InvariantCulture));

                resultTextBox.Text = convertResult;
            }
            catch (Exception exception)
            {
                string messageBoxText = $"{exception.Message}\r\n1. Check the entered value.\r\n2. Check your internet connection.";
                MessageBox.Show(messageBoxText, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }