Пример #1
0
        /// <summary>
        /// Initialises a new <c>ListRandomiserApp</c> instance with default values
        /// </summary>
        public ListRandomiserApp()
        {
            string listLocation     = Path.Combine(SaveLocation[ListRandomiserFolder.Main], SaveLocation[ListRandomiserFolder.ListsFromMain]);
            string settingsLocation = Path.Combine(SaveLocation[ListRandomiserFolder.Main], SaveLocation[ListRandomiserFolder.SettingsFromMain]);

            // Create the folders if they are missing
            Directory.CreateDirectory(SaveLocation[ListRandomiserFolder.Main]);
            Directory.CreateDirectory(listLocation);

            // Create basic list of all available lists
            foreach (string folder in Directory.EnumerateFiles(listLocation))
            {
                ListsAvailable.Add(Path.GetFileNameWithoutExtension(folder));
            }

            // Load settings
            if (File.Exists(settingsLocation))
            {
                string[] file = File.ReadAllLines(settingsLocation);
                NumberOfMainRolls     = Convert.ToInt32(file[0]);
                NumberOfSlowDownRolls = Convert.ToInt32(file[1]);
                TimeBetweenRolls      = Convert.ToInt32(file[2]);
                MaxRollTime           = Convert.ToInt32(file[3]);
            }
            else
            {
                SetDefaultSettings();
            }

            // Set current list to default
            CurrentList = new SpecificList(GetDefaultName());
        }
Пример #2
0
        /// <summary>
        /// Chooses a list choice from the available lists
        /// </summary>
        /// <param name="listChoice">Name of the list</param>
        /// <exception cref="ListDoesNotExistException">Thrown if the list does not exist</exception>
        public void ChooseList(string listChoice)
        {
            if (!ListsAvailable.Contains(listChoice))
            {
                throw new ListDoesNotExistException("The list chosen is not available");
            }

            CurrentList = new SpecificList(listChoice, File.ReadAllLines(Path.Combine(SaveLocation[ListRandomiserFolder.Main], SaveLocation[ListRandomiserFolder.ListsFromMain], listChoice + ".txt")).ToList());
            TempList    = null;
        }
Пример #3
0
 /// <summary>
 /// Sets up a temporary list ready for rolling
 /// </summary>
 public void PrepareList()
 {
     TempList = new SpecificList(CurrentList.Name, CurrentList.Items);
 }