protected void GOEPPImport_Click(object sender, EventArgs e) { activeTournament = io.GOEPPImport(); if (activeTournament != null) { SetGUIState(true); RefreshDataGridPlayer(activeTournament.Participants); SetIO(); } }
protected void ButtonSetPairing_Click(object sender, EventArgs e) { Tournament2 t = activeTournament; SetPairingDialog spd = new SetPairingDialog(t.Participants, t.PrePaired); spd.Run(); if (spd.OK) { t.PrePaired = spd.PremadePairing; } spd.Destroy(); }
protected void NewTournament_Click(object sender, EventArgs e) { if (activeTournament != null) { if (!io.ShowMessageWithOKCancel("Das aktuelle Turnier wird überschrieben.")) { return; } } NewTournament2Dialog ntd = new NewTournament2Dialog(); ntd.Run(); if (ntd.NewTournament) { activeTournament = new Tournament2(ntd.GetName(), ntd.GetMaxSquadSize(), ntd.GetCut()); SetGUIState(true); selectedPlayer = -1; SetIO(); } ntd.Destroy(); }
public NewTournament2Dialog(Tournament2 tournament = null) { this.Build(); foreach (string s in tournamentTypesXwing) { ComboBoxTournamentType.AppendText(s); } ComboBoxTournamentType.Active = 0; Changes = false; if (tournament != null) { TextboxName.Text = tournament.Name; if (tournament.Cut == TournamentCut.Top4) { RadioButtonTop4.Active = true; } else if (tournament.Cut == TournamentCut.Top8) { RadioButtonTop8.Active = true; } else if (tournament.Cut == TournamentCut.Top16) { RadioButtonTop16.Active = true; } else { RadioButtonNoCut.Active = true; } IntegerUpDownMaxSquad.Value = tournament.MaxSquadPoints; ButtonOK.Label = "Speichern"; } else { IntegerUpDownMaxSquad.Value = 100; } }
public static void LoadCSV(Statistic stats, bool overview = false, Tournament2 tournament = null) { string path, file, overviewList, line; string[] url, lines; int countOfLists; bool win = true; List <Statistic> statistics; List <string> lists, players, output; lists = new List <string>(); players = new List <string>(); statistics = new List <Statistic>(); Gtk.FileChooserDialog dlg = new Gtk.FileChooserDialog("Statistik laden", null, Gtk.FileChooserAction.Open, "Abbrechen", Gtk.ResponseType.Cancel, "Öffnen", Gtk.ResponseType.Ok); Gtk.FileFilter filter = new Gtk.FileFilter(); filter.Name = "TXT-Datei"; filter.AddPattern("*.txt"); int response = dlg.Run(); if (response == -5) { path = dlg.Filename; } else { return; } using (StreamReader sr = new StreamReader(path)) { file = sr.ReadToEnd(); } if (file.Contains('\n')) { lines = file.Split('\n'); for (int i = 0; i < lines.Length; i++) { if (lines[i] != "") { lines[i] = lines[i].Remove(lines[i].LastIndexOf('\r')); } } } else { lines = file.Split('\r'); } countOfLists = lines[1].Split('\t').Length - 1; statistics.Add(stats); for (int i = 1; i < countOfLists; i++) { statistics.Add(Update.LoadContents()); } for (int j = 1; j < lines.Length; j++) { if (lines[j] != "") { url = lines[j].Split('\t'); players.Add(url[0]); for (int i = 1; i <= countOfLists; i++) { if (url[i] != "") { if (url[i].StartsWith("\"") && url[i].EndsWith("\"")) { url[i] = url[i].Substring(url[i].IndexOf("\"") + 1, url[i].LastIndexOf("\"") - 1); } else if (url[i].StartsWith("\"")) { url[i] = url[i].Substring(url[i].IndexOf("\"") + 1); } else if (url[i].EndsWith("\"")) { url[i] = url[i].Substring(0, url[i].LastIndexOf("\"") - 2); } } if (url[i] == "") { overviewList = ""; } else { overviewList = statistics[i - 1].Parse(url[i], true, overview); } lists.Add(overviewList); //Aktuell nur für die erste Liste, da die Turnierverwaltung noch nicht //mit Escalation klar kommt. if (tournament != null && overviewList != "" && i == 1) { int trenner = overviewList.IndexOf(';'); int trenner2 = overviewList.IndexOf(';', trenner + 1); tournament.AddInfos(url[0], Int32.Parse(overviewList.Substring(trenner + 1, trenner2 - trenner - 1)), url[i]); } } } } if (countOfLists > 1) { MessageBox.Show("Es wurden mehrere Listen pro Spieler ermittelt.\nWähle einen Speicherort aus.\nAnschließend wird die erste Liste angezeigt."); Gtk.FileChooserDialog slg = new Gtk.FileChooserDialog("Listen speichern", null, Gtk.FileChooserAction.Save, "Abbrechen", Gtk.ResponseType.Cancel, "Speichern", Gtk.ResponseType.Ok); filter = new Gtk.FileFilter(); filter.Name = "TXM Statistik Datei"; filter.AddPattern("*.txmstats"); slg.AddFilter(filter); response = slg.Run(); if (response == -5) { path = slg.Filename; } else { return; } for (int i = 0; i < countOfLists; i++) { statistics[i].Path = path.Substring(0, path.LastIndexOf('.')) + " " + (i + 1) + path.Substring(path.LastIndexOf('.'), path.Length - path.LastIndexOf('.')); Serialize(statistics[i], true); } } if (overview) { MessageBox.Show("Gib bitte den Speicherort für die\nÜbersichtsliste(n) an."); Gtk.FileChooserDialog slg = new Gtk.FileChooserDialog("Listen speichern", null, Gtk.FileChooserAction.Save, "Abbrechen", Gtk.ResponseType.Cancel, "Speichern", Gtk.ResponseType.Ok); filter = new Gtk.FileFilter(); filter.Name = "CSV-Datei"; filter.AddPattern("*.csv"); slg.AddFilter(filter); response = slg.Run(); if (response == -5) { path = slg.Filename; } else { return; } output = new List <string>(); line = "Spieler;Fraktion;Punkte;Liste"; output.Add(line); for (int i = 0; i < players.Count; i++) { url = lines[i + 1].Split('\t'); line = players[i] + ";"; for (int j = 0; j < countOfLists; j++) { line += lists[i * countOfLists + j] + ";"; } output.Add(line); } using (System.IO.StreamWriter f = new System.IO.StreamWriter(path)) { foreach (string s in output) { f.WriteLine(s); } } if (countOfLists == 1) { path = path.Substring(0, path.LastIndexOf('.')) + "_statistik.csv"; Export(statistics[0], true, false, path); } else { for (int i = 0; i < countOfLists; i++) { string p = statistics[i].Path.Substring(0, path.LastIndexOf('.') + 2) + ".csv"; Export(statistics[i], true, false, p); } } } }
public static void LoadCSV(Tournament2 tournament) { LoadCSV(tournament.Statistics, true, tournament); }
private void Load(bool autosave = false) { int response; bool overwrite = true; string filename = ""; for (int i = 3; i < vbuttonboxRounds.Children.Length; i++) { vbuttonboxRounds.Remove(vbuttonboxRounds.Children [i]); } if (autosave) { AutosaveDialog ad = new AutosaveDialog(io); ad.Run(); overwrite = ad.Result; filename = ad.FileName; ad.Destroy(); } else { if (activeTournament != null) { if (!io.ShowMessageWithOKCancel("Das aktuelle Turnier wird überschrieben.")) { overwrite = false; } } } if (overwrite == true) { activeTournament = io.Load(filename); //Load Actions if (activeTournament != null) { for (int i = 1; i <= activeTournament.Rounds.Count; i++) { AddRoundButton(i); } } if (activeTournament.FirstRound && (activeTournament.Rounds == null || activeTournament.Rounds.Count == 0)) { SetGUIState(true); } else { SetGUIState(false, true); } ButtonGetResults.Label = "Erg. übernehmen"; ButtonGetResults.Sensitive = activeTournament.ButtonGetResultState == true; ButtonNextRound.Sensitive = activeTournament.ButtonNextRoundState == true; ButtonCut.Sensitive = activeTournament.ButtonCutState == true; activeTournament.Sort(); RefreshDataGridPlayer(activeTournament.Participants); if (activeTournament.Pairings != null) { RefreshDataGridPairings(activeTournament.Pairings); } selectedPlayer = -1; SetIO(); } }