Example #1
0
 /// <summary>
 /// Deletes all files of the mod and removes it from the list.
 /// Saves the xml file afterwards.
 /// </summary>
 public static void DeleteMod(ManagedMods mods, int index, Action <Progress> ProgressChanged = null)
 {
     ModActions.DeleteFiles(mods[index]);
     mods.RemoveAt(index);
     mods.Save();
     ProgressChanged?.Invoke(Progress.Done("Mod deleted."));
 }
Example #2
0
        /// <summary>
        /// Deletes multiple mods and removes them from the list.
        /// Saves the xml file afterwards.
        /// </summary>
        public static void DeleteMods(ManagedMods mods, List <int> indices, Action <Progress> ProgressChanged = null)
        {
            indices = indices.OrderByDescending(i => i).ToList();
            int fi    = 0;
            int count = indices.Count();

            foreach (int index in indices)
            {
                ProgressChanged?.Invoke(Progress.Ongoing($"Deleting mod {++fi} of {count}.", (float)(fi - 1) / (float)count));
                ModActions.DeleteFiles(mods[index]);
                mods.RemoveAt(index);
                mods.Save();
            }
            ProgressChanged?.Invoke(Progress.Done($"{count} mods deleted."));
        }