예제 #1
0
        // Helper to setBalance, also able to change currency when using the selection method
        private async void setBalance(string currencyOverride)
        {
            HomeLoadingBar.Visibility = Visibility.Visible;
            string currency = global_methods.GetDefaultCurrency();

            // Check to see if currency override is different then default currency
            if (!currencyOverride.Equals(currency))
            {
                currency = currencyOverride;
            }

            var blockioClient = new BlockIoClient(global_methods.ReadAPIKey(currency));

            var getBalance = await blockioClient.GetBalance();

            var balance = getBalance.AvailableBalance;

            // Get default currency from global methods
            switch (currency)
            {
            case "Bitcoin":
                BalanceBlock.Text = balance + " ฿";
                break;

            case "Litecoin":
                BalanceBlock.Text = balance + " Ł";
                break;

            case "Dogecoin":
                BalanceBlock.Text = balance + " Ð";
                break;
            }

            // Get QR code for default address
            // TODO:
            // Possibly save qr for offline access???
            //

            var blockioGet = await blockioClient.GetAddressByLabel("default");

            var    defaultAdd = blockioGet.Value;
            string getQR      = "https://chart.googleapis.com/chart?cht=qr&chs=200x200&chl=" + defaultAdd;

            QRImage.Source = new BitmapImage(new Uri(getQR));

            HomeLoadingBar.Visibility = Visibility.Collapsed;
        }
예제 #2
0
        // Dogecoin API box lost focus, only used in first run settings page

        private async void DogecoinAPIBox_LostFocus(object sender, RoutedEventArgs e)
        {
            var    blockClient = new BlockIoClient(DogecoinAPIBox.Text);
            string balString   = "";

            try
            {
                var bal = await blockClient.GetBalance();

                balString = bal.AvailableBalance.ToString();
            }
            catch
            {
                balString = "error";
                global_methods.DisplayMessage("Please try again!", "Invalid Dogecoin API Key");
            }
        }
예제 #3
0
        private async void SaveButton_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var bitClient  = new BlockIoClient(BitcoinAPIBox.Text);
            var liteClient = new BlockIoClient(LitecoinAPIBox.Text);
            var dogeClient = new BlockIoClient(DogecoinAPIBox.Text);

            bool bitPass  = false;
            bool litePass = false;
            bool dogePass = false;


            // Try Bitcoin

            try
            {
                var bal = await bitClient.GetBalance();

                //string balString = bal.AvailableBalance.ToString();


                bitPass = true;
            }
            catch
            {
                global_methods.DisplayMessage("Incorrect Bitcoin API Key!", "Error!");

                BitcoinAPIBox.Text = "";
            }

            // Try Litecoin

            try
            {
                var bal = await liteClient.GetBalance();


                litePass = true;
            }
            catch
            {
                global_methods.DisplayMessage("Incorrect Litecoin API Key!", "Error!");
                LitecoinAPIBox.Text = "";
            }

            // Try Dogecoin

            try
            {
                var bal = await dogeClient.GetBalance();



                dogePass = true;
            }
            catch
            {
                global_methods.DisplayMessage("Incorrect Dogecoin API Key!", "Error!");
                DogecoinAPIBox.Text = "";
            }

            if (bitPass && litePass && dogePass)
            {
                global_methods.DisplayMessage("API Keys saved successfully!", "Saved!");

                global_methods.SaveAPIKey("Bitcoin", BitcoinAPIBox.Text);
                global_methods.SaveAPIKey("Litecoin", LitecoinAPIBox.Text);
                global_methods.SaveAPIKey("Dogecoin", DogecoinAPIBox.Text);

                // change view for home view
                SettingsLoaded.Visibility = Visibility.Collapsed;
                HomeLoaded.Visibility     = Visibility.Visible;
                Launched();

                setBalance();
            }
        }