コード例 #1
0
        private void AddToModBulk(string[] files, Action <Progress> ProgressChanged = null)
        {
            if (editingBulk)
            {
                return;
            }
            int    i        = 0;
            string phaseStr = "Importing {0} of {1} files/folders - {2}";

            foreach (string filePath in files)
            {
                Action <Progress> PhasedProgressChanged = Progress.BuildPhasedProgressChanged(ProgressChanged, phaseStr, i++, files.Length);

                string fileExtension = Path.GetExtension(filePath);
                string fileName      = Path.GetFileName(filePath);
                string longFilePath  = ModInstallations.EnsureLongPathSupport(filePath);

                if (Directory.Exists(longFilePath))
                {
                    ModInstallations.AddFolder(editedMod, filePath, true, PhasedProgressChanged);
                }
                else if ((new string[] { ".ba2", ".zip", ".rar", ".tar", ".7z" }).Contains(fileExtension.ToLower()))
                {
                    ModInstallations.AddArchive(editedMod, filePath, PhasedProgressChanged);
                }
                else
                {
                    PhasedProgressChanged.Invoke(Progress.Indetermined($"Copying '{fileName}'..."));
                    File.Copy(longFilePath, Path.Combine(editedMod.ManagedFolderPath, fileName), true);
                }
            }
            ProgressChanged?.Invoke(Progress.Done("File(s)/folder(s) added."));
        }
コード例 #2
0
 private void AddArchiveToModThreaded(string filePath)
 {
     RunThreaded(() => {
         DisableUI();
     }, () => {
         try
         {
             ModInstallations.AddArchive(editedMod, filePath, UpdateProgress);
         }
         catch (Archive2RequirementsException exc)
         {
             MsgBox.ShowID("archive2InstallRequirements", MessageBoxIcon.Error);
             return(false);
         }
         catch (Archive2Exception exc)
         {
             MsgBox.ShowID("archive2Error", MessageBoxIcon.Error);
             return(false);
         }
         catch (Exception exc)
         {
             MsgBox.Get("failed").FormatText(exc.Message).Show(MessageBoxIcon.Error);
             return(false);
         }
         return(true);
     }, (success) => {
         EnableUI();
         UpdateSidePanel();
     });
 }