public void setCompetitor(Competitor member, int index) { try { list[index] = member; } catch (IndexOutOfRangeException ex) { ArgumentException argEx = new ArgumentException("Index is out of range", "index", ex); throw argEx; } }
public static void Add_Competitors(CompetitorsList List) { SQLiteConnection connect = new SQLiteConnection("Data Source=" + databaseName); connect.Open(); for (int i = 0; i < List.getSize(); i++) { Competitor c = List.getCompetitor(i); SQLiteCommand command = new SQLiteCommand("INSERT INTO 'Competitors' ('RatingNum'," + "'Name','Exist','Tournir') VALUES (" + (i + 1) + ",'" + c.name + "','" + c.exist + "','" + c.tournir + "');", connect); command.ExecuteNonQuery(); } connect.Close(); }
private void MyNTextbox_KeyDown(object sender, KeyEventArgs e) //РАБОТАЕТ))) { if (e.Key == Key.Return) { TextBox tbox = sender as TextBox; for (int i = 0; i < relist.getSize(); i++) { if (i + "" == Convert.ToString(tbox.Name.Last())) { Competitor comp = new Competitor(i + 1, tbox.Text + "\n", true, TName); relist.setCompetitor(comp, i); tbox.Background = Brushes.Lavender; } } } }
private void button_Click(object sender, RoutedEventArgs e) { if (tNameTextBox.Text.Length != 0) { switch (tTypeComboBox.SelectedIndex) { case 0: RoundEliminationPage page1 = new RoundEliminationPage(); switch (sizeComboBox.SelectedIndex) { case 0: page1.GridSize = listTextBox.LineCount; CompetitorsList newList1 = new CompetitorsList(listTextBox.LineCount); for (int i = 0; i < listTextBox.LineCount; i++) { Competitor comp = new Competitor(i, listTextBox.GetLineText(i), true, tNameTextBox.Text); newList1.setCompetitor(comp, i); } page1.Relist = newList1; page1.TName = tNameTextBox.Text; NavigationService.Navigate(page1); break; case 1: page1.GridSize = Convert.ToInt16(sizeTextBox.Text); CompetitorsList newList2 = new CompetitorsList(Convert.ToInt16(sizeTextBox.Text)); for (int i = 0; i < Convert.ToInt16(sizeTextBox.Text); i++) { newList2.setCompetitor(new Competitor(i, "", true, tNameTextBox.Text), i); } page1.Relist = newList2; page1.TName = tNameTextBox.Text; NavigationService.Navigate(page1); break; default: errorView(); break; } break; case 1: SingleEliminaionPage page2 = new SingleEliminaionPage(); switch (sizeComboBox.SelectedIndex) { case 0: page2.Steps = TrueSingleElimSize(listTextBox.LineCount); page2.GridSize = (int)Math.Pow(2, page2.Steps); CompetitorsList newList1 = new CompetitorsList(page2.GridSize); for (int i = 0; i < page2.GridSize; i++) { if (i < listTextBox.LineCount) { newList1.setCompetitor(new Competitor(i + 1, listTextBox.GetLineText(i), true, tNameTextBox.Text), i); } else { newList1.setCompetitor(new Competitor(i + 1, "", false, tNameTextBox.Text), i); } } page2.Selist = newList1; page2.TName = tNameTextBox.Text; NavigationService.Navigate(page2); break; case 1: page2.Steps = TrueSingleElimSize(Convert.ToInt16(sizeTextBox.Text)); page2.GridSize = (int)Math.Pow(2, TrueSingleElimSize(Convert.ToInt16(sizeTextBox.Text))); CompetitorsList newList2 = new CompetitorsList(page2.GridSize); for (int i = 0; i < page2.GridSize; i++) { if (i < Convert.ToInt16(sizeTextBox.Text)) { newList2.setCompetitor(new Competitor(i + 1, "", true, tNameTextBox.Text), i); } else { newList2.setCompetitor(new Competitor(i + 1, "", false, tNameTextBox.Text), i); } } page2.Selist = newList2; page2.TName = tNameTextBox.Text; NavigationService.Navigate(page2); break; default: errorView(); break; } break; default: errorView(); break; } } else { errorView(); } }
public Duel(Competitor comp1, Competitor comp2, int duelNum) { this.comp1 = comp1; this.comp2 = comp2; this.duelNum = duelNum; }