private void CompletAll() { if (Helpers.CheckConnectInternet()) { currentExchangeRates = new CurrentExchangeRates(true); labeCourseUsd.Content = "USD = " + Math.Round(currentExchangeRates.GetCourse("USD"), 2) + "zł"; labeCourseEur.Content = "EUR = " + Math.Round(currentExchangeRates.GetCourse("EUR"), 2) + "zł"; labeCourseGbp.Content = "GBP = " + Math.Round(currentExchangeRates.GetCourse("GBP"), 2) + "zł"; labeCourseChf.Content = "CHF = " + Math.Round(currentExchangeRates.GetCourse("CHF"), 2) + "zł"; Helpers.FillComboBox(currentExchangeRates, ref comboBox1, true); Helpers.FillComboBox(currentExchangeRates, ref comboBox2, true); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 1; OfflineDataCurrency.Content = ""; control.Fill = Brushes.Green; ReadAndWriteJson.WriteJson(); OfflineMode = false; } else { currentExchangeRates = new CurrentExchangeRates(false); labeCourseUsd.Content = "USD = " + Math.Round(currentExchangeRates.GetCourse("USD"), 2) + "zł"; labeCourseEur.Content = "EUR = " + Math.Round(currentExchangeRates.GetCourse("EUR"), 2) + "zł"; labeCourseGbp.Content = "GBP = " + Math.Round(currentExchangeRates.GetCourse("GBP"), 2) + "zł"; labeCourseChf.Content = "CHF = " + Math.Round(currentExchangeRates.GetCourse("CHF"), 2) + "zł"; Helpers.FillComboBox(currentExchangeRates, ref comboBox1, true); Helpers.FillComboBox(currentExchangeRates, ref comboBox2, true); comboBox1.SelectedIndex = 0; comboBox2.SelectedIndex = 1; OfflineDataCurrency.Content = "Kursy walut z dnia: " + currentExchangeRates.Data; control.Fill = Brushes.Red; OfflineMode = true; } }
public static string GetShortName(string comboBoxItem, CurrentExchangeRates currentExchangeRates) { foreach (var item in currentExchangeRates.CurrencieNames) { if (comboBoxItem == item.ShortName + " " + item.Name) { return(item.ShortName); } } return("EUR"); }
public static void FillComboBox(CurrentExchangeRates currentExchangeRates, ref ComboBox comboBox, bool tmp) { if (tmp) { comboBox.Items.Add("PLN"); foreach (var item in currentExchangeRates.CurrencieNames) { comboBox.Items.Add(item.ShortName + " " + item.Name); } } else { foreach (var item in currentExchangeRates.CurrencieNames) { comboBox.Items.Add(item.ShortName + " " + item.Name); } } }