Exemple #1
0
        private void BuyButton_Click(object sender, EventArgs e)
        {
            //Inflate the dialog layout that should appear when a button is pressed
            LayoutInflater layoutInfalter = LayoutInflater.From(Activity);
            View           mView          = layoutInfalter.Inflate(Resource.Layout.OrderConfirmationLayout, null);

            //Gets a string of the currency to use as a label
            string currencyOnly = Currency.Substring(4, Currency.Length - 4);

            //Set the information of the order
            var amountTextView = (TextView)mView.FindViewById(Resource.Id.confirmAmount);

            amountTextView.Text = orderAmount.Text + " " + currencyOnly;

            var priceTextView = (TextView)mView.FindViewById(Resource.Id.confirmPrice);

            priceTextView.Text = orderPrice.Text + " BTC";

            var totalTextView = (TextView)mView.FindViewById(Resource.Id.confirmTotal);

            totalTextView.Text = totalPriceBtc.Text + " BTC";

            AlertDialog.Builder ad = new AlertDialog.Builder(Activity);
            ad.SetTitle("Confirm your buy order");
            ad.SetCancelable(false).SetPositiveButton("Confirm", delegate
            {
                double amount = Convert.ToDouble(orderAmount.Text);
                double price  = Convert.ToDouble(orderPrice.Text);

                try
                {
                    string orderUUID = APIMethods.PlaceBuyLimitOrder(Currency, amount, price);
                }
                catch (Exception i)
                {
                    Toast.MakeText(Activity, i.Message.ToString(), ToastLength.Short).Show();
                }
            }).SetNegativeButton("Cancel", delegate
            {
                ad.Dispose();
            });

            ad.SetView(mView);
            ad.Show();
        }