Ejemplo n.º 1
0
        private void StartBackgroundUpdater(int waitMinutes)
        {
            var startTimeSpan  = TimeSpan.Zero;
            var periodTimeSpan = TimeSpan.FromMinutes(waitMinutes);

            var timer = new System.Threading.Timer((e) =>
            {
                currencies = XmlWebApiReader.ReadXml();
            }, null, startTimeSpan, periodTimeSpan);
        }
Ejemplo n.º 2
0
        public CurrencyConverterWindow()
        {
            InitializeComponent();
            currencies = XmlWebApiReader.ReadXml();
            StartBackgroundUpdater(5);      //update currencies from the API every n minutes

            #region controls setup
            updateTimerComboBox.Items.Add("5 percenként");
            updateTimerComboBox.Items.Add("Félóránként");
            updateTimerComboBox.Items.Add("Óránként");
            updateTimerComboBox.SelectedIndex = 0;

            List <string> currList = new List <string>
            {
                "EUR", "GBP", "AUD", "DKK", "JPY", "CAD", "NOK", "CHF", "SEK", "USD", "CZK", "PLN", "HRK", "RON", "TRY"
            };
            currList.Sort();
            ComboBoxFrom.ItemsSource   = ComboBoxTo.ItemsSource = ComboBoxTopFrom.ItemsSource = ComboBoxAlert.ItemsSource = currList;
            ComboBoxFrom.SelectedValue = ComboBoxTopFrom.SelectedValue = "EUR";
            ComboBoxTo.SelectedValue   = "GBP";

            ComboBoxAlert.SelectedValue = "EUR";
            dudAlert.Value = 330;

            DataGridCurrency.ItemsSource = currencies;

            ComboBoxFrom.SelectionChanged += currChanged;
            ComboBoxFrom.DropDownClosed   += currChanged;
            ComboBoxTo.SelectionChanged   += currChanged;
            ComboBoxTo.DropDownClosed     += currChanged;

            formFullyLoaded  = true;
            dudFrom.Value    = (decimal)100.10;
            dudTopFrom.Value = (decimal)1.0;
            calcHufRate(ComboBoxTopFrom.Text, "sell");
            calcExchangeRate(ComboBoxTo.Text, ComboBoxFrom.Text);

            createChart();

            #endregion
        }