Beispiel #1
0
        /// <summary>
        /// By using the selected index, we move the item to the top of the mru, shifting any other items down.
        /// </summary>
        /// <param name="index"></param>

        public void Use(string item, string outputDir)
        {
            for (int i = 0; i < items.Count; ++i)
            {
                if (items[i].filename == item)
                {
                    items.RemoveAt(i);
                    break;
                }
            }

            fileOutputDir tmp = new fileOutputDir();

            tmp.filename  = item;
            tmp.outputDir = outputDir;

            items.Insert(0, tmp);

            int itemsToKill = items.Count - itemsMax;

            if (itemsToKill > 0)
            {
                items.RemoveRange(itemsMax, itemsToKill);
            }
        }
Beispiel #2
0
 public void Load(IFileSystemService fsSvc, string fileLocation)
 {
     if (!fsSvc.FileExists(fileLocation))
     {
         return;     // Save ourselves the pain of an exception.
     }
     try
     {
         using (var reader = new StreamReader(fileLocation, new UTF8Encoding(false)))
         {
             string line = reader.ReadLine();
             while (line != null && items.Count < items.Capacity)
             {
                 fileOutputDir tmp = new fileOutputDir();
                 tmp.filename  = line.TrimEnd('\r', '\n');
                 line          = reader.ReadLine();
                 tmp.outputDir = line.TrimEnd('\r', '\n');
                 this.items.Add(tmp);
                 line = reader.ReadLine();
             }
         }
     }
     catch (FileNotFoundException)
     {
     }
 }