Exemple #1
0
        private async void getAllCurrencies()
        {
            CurrencyDataProvider cdp = new CurrencyDataProvider();
            ComboBoxItem         currenciesAll;

            try
            {
                currencies = await cdp.GetCurrencies();
            }
            catch
            {
                return;
            }

            foreach (var cur in currencies.OrderBy(f => f.Value.CurrencyName))
            {
                currenciesAll = new ComboBoxItem {
                    Content = cur.Value.CurrencyName
                };
                Currencies.Items.Add(currenciesAll);
            }
            Currencies.SelectedIndex = 0;
            try
            {
                var firstCurrency = currencies.OrderBy(kvp => kvp.Value.CurrencyName).First();
                CurrencyId.Text     = firstCurrency.Value.Id;
                CurrencySymbol.Text = firstCurrency.Value.CurrencySymbol;
            }
            catch
            {
                return;
            }
        }
        RateModel[] Load(DextopReadFilter filter)
        {
            var currency = filter.Params.SafeGet("Currency", "EUR");
            var amount   = filter.Params.SafeGet("Amount", 100.0m);

            var data = CurrencyDataProvider.GetCurrencyList(currency);

            return(data.Rates.Select(a => new RateModel
            {
                Currency = a.Currency,
                ISOCode = a.ISOCode,
                Rate = a.Rate,
                Amount = amount * a.Rate
            }).ToArray());
        }
        public override void InitRemotable(DextopRemote remote, DextopConfig config)
        {
            base.InitRemotable(remote, config);
            Remote.AddStore("model", Load);
            Remote.AddStore("history", LoadHistory);
            Remote.AddLookupData("Currency", CurrencyDataProvider.GetCurrencyList().Rates.Select(a => new Object[] {
                a.ISOCode,
                String.Format("{0} ({1})", a.Currency, a.ISOCode)
            }).ToArray());

            config["convertData"] = new ConvertForm
            {
                Amount   = 100,
                Currency = "EUR"
            };
        }
Exemple #4
0
        private async void getCurrencies()
        {
            CurrencyDataProvider cdp = new CurrencyDataProvider();
            Dictionary <string, Models.Currency> currencies;

            try
            {
                currencies = await cdp.GetCurrencies();
            }
            catch
            {
                return;
            }
            ComboBoxItem currenciesFrom;
            ComboBoxItem currenciesTo;

            foreach (var cur in currencies.OrderBy(e => e.Value.CurrencyName))
            {
                if (cur.Value.CurrencySymbol == null)
                {
                    currenciesFrom = new ComboBoxItem {
                        Content = cur.Key + "   " + cur.Value.CurrencyName
                    };
                    currenciesTo = new ComboBoxItem {
                        Content = cur.Key + "   " + cur.Value.CurrencyName
                    };
                }
                else
                {
                    currenciesFrom = new ComboBoxItem {
                        Content = cur.Key + "   " + cur.Value.CurrencyName + " (" + cur.Value.CurrencySymbol + ")"
                    };
                    currenciesTo = new ComboBoxItem {
                        Content = cur.Key + "   " + cur.Value.CurrencyName + " (" + cur.Value.CurrencySymbol + ")"
                    };
                }
                CurrenciesFrom.Items.Add(currenciesFrom);
                CurrenciesTo.Items.Add(currenciesTo);
            }
            CurrenciesFrom.SelectedIndex = 156;
            CurrenciesTo.SelectedIndex   = 143;
            AmountFrom.Focus(FocusState.Programmatic);
        }