예제 #1
0
 private void Resume()
 {
     if (SelectedDate == null)
     {
         return;
     }
     CurrenciesGrid.DataContext = NbpApi.GetAllCurrencyExchangeRatesForDay((DateTime)SelectedDate);
 }
예제 #2
0
 private void DatesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (SelectedDate == null)
     {
         return;
     }
     CurrenciesGrid.DataContext   = NbpApi.GetAllCurrencyExchangeRatesForDay((DateTime)SelectedDate);
     localSettings.Values["Date"] = (DateTimeOffset)SelectedDate;
 }
예제 #3
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null && (string)e.Parameter == "resuming")
     {
         CurrenciesGrid.DataContext =
             NbpApi.GetAllCurrencyExchangeRatesForDay(((DateTimeOffset)localSettings.Values["date"]).DateTime);
     }
     localSettings.Values["page"] = "main";
 }
예제 #4
0
        public MainPage()
        {
            InitializeComponent();

            DatesListView.DataContext = GetDaysBetweenTwoDates(DateTime.Today.AddDays(-90), DateTime.Today);

            CurrenciesGrid.DataContext = NbpApi.GetAllCurrencyExchangeRatesForDay(DateTime.Today);

            localSettings = ApplicationData.Current.LocalSettings;
            localSettings.Values["page"] = "main";
        }
예제 #5
0
        private async void UpdateGraph()
        {
            if (Currency == null || Currency.code == "")
            {
                return;
            }
            if (DateFrom.Date.Date < DateTime.Parse("23-09-02"))
            {
                errorTextBox.Text = "Error: invalid date!";
                return;
            }

            Windows.Storage.ApplicationDataCompositeValue composite =
                new Windows.Storage.ApplicationDataCompositeValue
            {
                ["currency"] = Currency.currency,
                ["code"]     = Currency.code,
                ["from"]     = DateFrom.Date,
                ["to"]       = DateTo.Date
            };
            localSettings.Values["currencyObj"] = composite;


            errorTextBox.Text = "";
            var from      = DateFrom.Date.Date;
            var to        = DateTo.Date.Date;
            var tempPairs = new List <KeyValuePair <DateTime, double> >();
            var ab        = new List <Task <List <Exchange> > >();

            while (to - from > TimeSpan.FromDays(356))
            {
                var mid = to.AddDays(-356);
                ab.Add(NbpApi.GetExchangesForSingleCurrencyInRange(mid, to, Currency.code));
                to = mid;
            }
            ab.Add(NbpApi.GetExchangesForSingleCurrencyInRange(from, to, Currency.code));

            await Task.Run(async() =>
            {
                tempPairs.AddRange(from l in await Task.WhenAll(ab) from ex in l select new KeyValuePair <DateTime, double>(ex.EffectiveDate, ex.mid));
            });

            LineChart.DataContext = tempPairs;
        }