using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; namespace SoundBoard { class GenerateRandomPlayList { private Random randomNumber = new Random(); //Random number generator private string __workingDirectory = Path.GetDirectoryName(Application.ExecutablePath); public string[] SingleViewPlayList(List> listViewContents, int iterations, int index) { string[] playList = new String[iterations]; string tempFileName; int i = 0; int itemCount = listViewContents[index].Count - 1; //Count is not zero index based do { tempFileName = listViewContents[index][randomNumber.Next(0, itemCount)]; if (playList.Contains(tempFileName)) { playList[i] = listViewContents[index][randomNumber.Next(0, itemCount)]; } else { playList[i] = tempFileName; } i++; } while (i < iterations); return playList; } public string[] MulitViewPlayList(List> listViewContents, int iterations) { string[] playList = new String[iterations]; int zeroIndexCount = listViewContents[0].Count; int tabCount = listViewContents.Count; int itemCount; int i = 0; int temp; string tempFilePath; do { if (zeroIndexCount > 5) { temp = randomNumber.Next(0, tabCount - 1); itemCount = listViewContents[temp].Count - 1; //Count is zero index based tempFilePath = listViewContents[temp][randomNumber.Next(0, itemCount)]; if (playList.Contains(tempFilePath)) { playList[i] = listViewContents[temp][randomNumber.Next(0, itemCount)]; } else { playList[i] = tempFilePath; } } else { temp = randomNumber.Next(1, tabCount - 1); itemCount = listViewContents[temp].Count - 1; //Count is zero index based tempFilePath = listViewContents[temp][randomNumber.Next(0, itemCount)]; if (playList.Contains(tempFilePath)) { playList[i] = listViewContents[temp][randomNumber.Next(0, itemCount)]; } else { playList[i] = tempFilePath; } } i++; } while(i < iterations); return playList; } } }