public void AddRandomTracks(TrackDatabase database, HashSet<Track> ignoreTracks, string[] genres, int tracks, bool themesonly)
        {
            //Create a random generator
            Random random = new Random();

            //Create list of tracks for selection (ignoring tracks in previous playlists)
            TrackCollection picklist = new TrackCollection();
            foreach (Track track in database.Tracks) {
             	foreach (string s in genres) {
                    //Genre in Round and track not already used
                    if (String.Compare(track.Genre, s, true) == 0 && !ignoreTracks.Contains(track)) {
                        // Check whether only themes to be chosen
                        if (track.IsTheme || !themesonly) {
                            //Add to pick list
                            picklist.Add(track);
                        }
                    }
                }
            }

            // Shuffle the order first
            picklist.Shuffle();

            // Now sort by times played
            picklist.Sort(new Track.TrackTimesPlayedComparer());

            // Pick random tracks
            for (int i = 0; i < tracks; i++) {
                //Check if the list has any tunes
                if (picklist.Count == 0)
                    break;

                //Pick a random track from the selection list
                int ri = random.Next(0, picklist.Count);

                //Save in playlist
                Add(picklist[ri]);

                //Remove track from selection list
                picklist.RemoveAt(ri);
            }
        }
        public FastAnswerForm(TrackDatabase db, string[] genres = null)
        {
            mDatabase = db;

            // Initialise the form
            InitializeComponent();
            pnlQuestions.Visible = true;
            pnlConclusion.Visible = false;

            // Create playlist
            mPlaylist = mDatabase.Tracks.GetFromGenre(genres);
            mPlaylist.Shuffle();

            // Now sort by times played
            mPlaylist.Sort(new Track.TrackTimesPlayedComparer());

            // Start the session
            mSessionTime.Start();
            NextTrack();
        }
 public void AddRange(TrackCollection tracks)
 {
     this.InnerList.AddRange(tracks);
 }
 public TrackCollection GetFromGenre(string[] genres)
 {
     TrackCollection newtc = new TrackCollection();
     foreach (Track t in this)
         foreach (string g in genres)
             if (String.Compare(t.Genre, g, true) == 0)
                 newtc.Add(t);
     return newtc;
 }
 public TrackCollection GetFromCategory(string[] categories)
 {
     TrackCollection newtc = new TrackCollection();
     foreach (Track t in this)
         foreach (string g in categories)
             if (String.Compare(t.Category, g, true) == 0)
                 newtc.Add(t);
     return newtc;
 }