private void RefreshForRound(Round round) { // Set Round Name & Play Mode lblRoundName.Text = round.Name; cmbPlayMode.SelectedIndex = round.PlayMode; //Set Number of Tracks and start with Track 1 spnTrack.Maximum = round.Tracks.Count; spnTrack.Minimum = 1; spnTrack.Value = 1; RefreshForTrack(); }
private Quiz GenerateTTQ() { Quiz quiz = new Quiz(); quiz.Name = txtQuizName.Text; HashSet<Track> alltracks = new HashSet<Track>(); for (int i = 0; i < 5; i++) { NumericUpDown nud = (NumericUpDown)(Controls["spnTracks" + i]); if (nud.Value > 0) { //Create a new round instance Round r = new Round(); TextBox namebox = (TextBox)Controls["txtRoundName" + i]; r.Name = namebox.Text; r.PlayMode = ((ComboBox)Controls["cmbMode" + i]).SelectedIndex; //Call make songs or something using rounds.ToArray List<string> genres = new List<string>(); CheckedListBox clbox = (CheckedListBox)Controls["chkRound" + i]; foreach (int j in clbox.CheckedIndices) genres.Add(mGenres[j]); r.Tracks.AddRandomTracks(mDatabase, alltracks, genres.ToArray(), Convert.ToInt32(nud.Value), ((CheckBox)Controls["chkTheme" + i]).Checked); foreach (Track t in r.Tracks) alltracks.Add(t); //Add this new round to list quiz.Rounds.Add(r); } } // Increment times played for each song and save database foreach (Track t in alltracks) t.TimesPlayed++; mDatabase.Save(); return quiz; }
private void LoadXMLQuiz(TrackDatabase db, string path) { Round r = null; bool inQuiz = false; bool inRound = false; bool inTrack = false; int missingtunes = 0; string name; string playMode; string text; XmlReader xmlReader; xmlReader = XmlReader.Create(path); mCreationTime = File.GetCreationTime(path); missingtunes = 0; while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: switch (xmlReader.Name) { case "Quiz": inQuiz = true; name = xmlReader.GetAttribute("Name"); if (name != null) Name = name; break; case "Round": if (inQuiz) { inRound = true; name = xmlReader.GetAttribute("Name"); playMode = xmlReader.GetAttribute("PlayMode"); r = new Round(); if (name != null) r.Name = name; if (playMode != null) { if (IsPositiveInt(playMode)) r.PlayMode = Convert.ToInt32(playMode); } } break; case "Track": if (inRound) { inTrack = true; } break; } break; case XmlNodeType.Text: if (inTrack) { text = xmlReader.Value; if (text != null) { // Check whether track is found in the database if (db.Tracks.Contains(text)) r.Tracks.Add(db.GetTune(text)); else missingtunes++; } } break; case XmlNodeType.EndElement: switch (xmlReader.Name) { case "Quiz": inQuiz = false; break; case "Round": if (r != null) { mRounds.Add(r); r = null; } inRound = false; break; case "Track": inTrack = false; break; } break; } } if (missingtunes > 0) { MessageBox.Show(missingtunes.ToString() + " tunes were not in database and have been removed from the quiz.", "Missing Tunes", MessageBoxButtons.OK); } }
public void Add(Round round) { this.List.Add(round); }