public App()
        {
            if (db.GetCurrency(Utils.currencyCodes[0]) == null) // db not initialized
            {
                // initialize db with default rate (-1) // changed to 1. -1 was giving problems.
                foreach (string cod in Utils.currencyCodes)
                {
                    db.UpdateCurrency(new Currency()
                    {
                        code = cod, rate = 1.0
                    });
                }

                db.SetGlobal("favouriteCurrency", "EUR");
            }

            foreach (WalletAmount wa in db.GetWalletAmounts())
            {
                wallet.AddAmount(wa.code, wa.amount);
            }


            // The root page of your application
            var content = new InputValuePage(db, wallet);

            MainPage = new NavigationPage(content);

            content.UpdateCurrencies();
        }
        public BalancePage(Wallet w, DatabaseOps d)
        {
            this.Title = "Balance";

            wallet = w;
            db     = d;

            screenWidth  = DeviceInfo.Hardware.ScreenWidth;
            screenHeight = ConvertPixelsToDp(DeviceInfo.Hardware.ScreenHeight);

            Debug.WriteLine("Height: " + screenHeight + " # Width: " + screenWidth);
            graphMaxHeight = screenHeight * 0.6;

            selectedCurrency = db.GetCurrency(db.GetGlobal("favouriteCurrency"));

            InitializeMainGrid();
            InitializeGraph();
            InitializeTotals();

            var scrollview = new ScrollView
            {
                Content = new StackLayout
                {
                    Children = { mainGrid }
                }
            };

            Content = new StackLayout
            {
                Children = { scrollview }
            };
        }
Example #3
0
        public static double ConvertAmount(DatabaseOps db, double amount, string codeFrom, string codeTo)
        {
            double rate = db.GetCurrency(codeTo).rate / db.GetCurrency(codeFrom).rate;

            return(amount * rate);
        }
Example #4
0
 public static Currency getFavouriteCurrency(DatabaseOps db)
 {
     return(db.GetCurrency(db.GetGlobal("favouriteCurrency")));
 }
 private void updateCurrencyRateLabelText()
 {
     currencyRateLabel.Text = string.Format("1 {0} = {1} {2}", favouriteCurrency.code,
                                            Math.Round(db.GetCurrency(selectedCurrency.code).getRate(favouriteCurrency), 5),
                                            selectedCurrency.code);
 }