/// <summary> /// Metoda do pobrania z API danych oraz wczytywanie ich do widoku. /// </summary> /// <param name="download">Obiekt implementujący IDownloadTeam, musi posiadać właściwość TeamsDTO</param> /// <param name="listView">Widok listy</param> public async void DownloadData(IDownloadTeam download, ListView listView) { await download.HttpCall(); Results = download.results; List <CustomTeam> list = new List <CustomTeam>(); if (Results != null) { int lp = 1; foreach (var result in Results.Teams) { CustomTeam custom = new CustomTeam() { Lp = lp.ToString() + ".", Name = result.Name }; list.Add(custom); lp++; } listView.ItemsSource = list; listView.ItemTemplate = new DataTemplate(typeof(TeamsItemView)); } }
private void AddPlayer_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PlayerName.Text) || string.IsNullOrEmpty(CustomTeam.Text)) { MessageBox.Show("Gibt einen gültigen Spielernamen oder Teamnamen ein"); return; } this.addCustomTeam(); CustomTeam.Clear(); int i = Int32.Parse(SpielerCount.Text); i++; SpielerCount.Text = i.ToString(); Array.Resize(ref Spieler, Spieler.Length + 1); Spieler[Spieler.Length - 1] = PlayerName.Text; string[] row = { PlayerName.Text }; dataGridView1.Rows.Add(row); PlayerName.Focus(); PlayerName.Clear(); dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.RowCount - 1; int SpielerZahl = 5; if (turn.tennis) { SpielerZahl = 2; } if (Spieler.Length % SpielerZahl == 1) { this.addteam(); } }