Ejemplo n.º 1
0
        private async void BuyBULClicked(object sender, System.EventArgs e)
        {
            if (!App.Locator.FriendlyService.IsFundWorking)
            {
                ShowErrorMessage(AppResources.WalletFundNotWorking);
                return;
            }

            if (IsValid(SpendCurrency.BUL))
            {
                try
                {
                    App.ShowLoading(true);

                    var currency = (PaymentCurrency)PickerBULCurrency.SelectedItem;

                    double amount = double.Parse(EntryAmountForBUL.Text);

                    if (amount > 50)
                    {
                        EventHandler handleCurrencyHandler = (s, ev) =>
                        {
                            EntryAmountForBUL.Focus();
                        };

                        ShowErrorMessage(AppResources.PurchaseManyBULs, false, handleCurrencyHandler);
                    }
                    else
                    {
                        var result = await App.Locator.IdentityServiceClient.PurchaseBULs(amount, currency);

                        if (result != null)
                        {
                            PurchaseBullAddress = result.PaymentAddress;

                            var successString = String.Format("Please send your {0} to the address {1} to purchase your BULs", currency, result.PaymentAddress);
                            PurchaseBULSuccessLabel.Text = successString;

                            PurchaseBULMainView.IsVisible     = false;
                            PurchaseBULSSuccessView.IsVisible = true;
                        }
                    }
                }
                catch (Exception)
                {
                }

                App.ShowLoading(false);

                EnableDisableButton();
            }
        }
Ejemplo n.º 2
0
        private void PickerUnfocused(object sender, EventArgs e)
        {
            if (sender == PickerBULCurrency)
            {
                if (PickerBULCurrency.SelectedItem != null)
                {
                    IconBULCurrencyView.IsVisible = true;

                    var currency = (PaymentCurrency)PickerBULCurrency.SelectedItem;

                    if (currency == PaymentCurrency.BTC)
                    {
                        IconBULCurrencyView.Source = "btc_icon.png";
                    }
                    else
                    {
                        IconBULCurrencyView.Source = "eth_icon.png";
                    }

                    if (ShowPurchaseBuls)
                    {
                        EntryAmountForBUL.Focus();
                    }
                }
            }
            else if (sender == PickerXLMCurrency)
            {
                if (PickerXLMCurrency.SelectedItem != null)
                {
                    IconXLMCurrencyView.IsVisible = true;

                    var currency = (PaymentCurrency)PickerXLMCurrency.SelectedItem;

                    if (currency == PaymentCurrency.BTC)
                    {
                        IconXLMCurrencyView.Source = "btc_icon.png";
                    }
                    else
                    {
                        IconXLMCurrencyView.Source = "eth_icon.png";
                    }
                }
            }

            EnableDisableButton();
        }
Ejemplo n.º 3
0
        private bool IsValid(SpendCurrency spendCurrency)
        {
            if (spendCurrency == SpendCurrency.BUL)
            {
                if (PickerBULCurrency.SelectedItem == null)
                {
                    EventHandler handleCurrencyHandler = (s, e) =>
                    { 
 PickerBULCurrency.Focus(); }; 

                    ShowErrorMessage(AppResources.PleaseSelectPaymentCurrency, false, handleCurrencyHandler);

                    return(false);
                }
                if (!ValidationHelper.ValidateNumber(EntryAmountForBUL.Text))
                {
                    EntryAmountForBUL.Focus();
                    return(false);
                }
            }
            else
            {
                if (PickerXLMCurrency.SelectedItem == null)
                {
                    EventHandler handleCurrencyHandler = (s, e) =>
                    {
                        PickerXLMCurrency.Focus();
                    };

                    ShowErrorMessage(AppResources.PleaseSelectPaymentCurrency, false, handleCurrencyHandler);

                    return(false);
                }
                if (!ValidationHelper.ValidateNumber(EntryAmountForXLM.Text))
                {
                    EntryAmountForXLM.Focus();
                    return(false);
                }
            }

            return(true);
        }