public OverviewUserControl(string urlParams) { var lst = new CryptoLoader().GetOverview(urlParams); InitializeComponent(); InitializeOverview(lst); }
private void ConvertButton_Click(object sender, RoutedEventArgs e) { if (ComboBox1.SelectedItem == null || ComboBox2.SelectedItem == null) { MessageBox.Show("Vyberte měnu v ComboBoxu!"); } else if (TextBoxInput.Text == "") { MessageBox.Show("Zadejte množství!"); } else { Cryptocurrency a; Cryptocurrency b; string url = @"/summary?apikey=JPC30MFZDAVCBNZ291M3"; var selectedTag1 = ((ComboBoxItem)ComboBox1.SelectedItem).Tag.ToString(); var selectedTag2 = ((ComboBoxItem)ComboBox2.SelectedItem).Tag.ToString(); if (selectedTag1.Equals(selectedTag2)) { TextBoxOutput.Text = TextBoxInput.Text; } else if ((selectedTag1.Equals("eur") && selectedTag2.Equals("usd")) || (selectedTag1.Equals("usd") && selectedTag2.Equals("eur"))) { a = new CryptoLoader().GetAnyToAny("btc" + selectedTag1 + url); b = new CryptoLoader().GetAnyToAny("btc" + selectedTag2 + url); TextBoxOutput.Text = (Double.Parse(TextBoxInput.Text) * (b.Price.Last / a.Price.Last)).ToString(); } else if (selectedTag1.Equals("usd") || selectedTag1.Equals("eur")) { a = new CryptoLoader().GetAnyToAny(selectedTag2 + selectedTag1 + url); TextBoxOutput.Text = (Double.Parse(TextBoxInput.Text) * (1 / a.Price.Last)).ToString(); } else if (selectedTag2.Equals("usd") || selectedTag2.Equals("eur")) { a = new CryptoLoader().GetAnyToAny(selectedTag1 + selectedTag2 + url); TextBoxOutput.Text = (Double.Parse(TextBoxInput.Text) * a.Price.Last).ToString(); } else { a = new CryptoLoader().GetAnyToAny(selectedTag1 + "usd" + url); b = new CryptoLoader().GetAnyToAny(selectedTag2 + "usd" + url); TextBoxOutput.Text = (Double.Parse(TextBoxInput.Text) * (a.Price.Last / b.Price.Last)).ToString(); } } }