public async Task GetAndWriteAllCommus(PatchZipFile patchZipFile, IProgress <ProgressData> progress1 = null, IProgress <ProgressData> progress2 = null)
        {
            var commuSheets = xlsx.Sheets.Descendants <Sheet>().Where(sheet => CommuLine.commuSheetNames.Contains(sheet.Name));
            int total1      = commuSheets.Count();
            int count1      = 0;

            foreach (Sheet sheet in commuSheets)
            {
                count1++;
                progress1?.Report(new ProgressData {
                    count = count1, total = total1, filename = sheet.Name
                });
                IEnumerable <CommuLine> lines = await Task.Run(() => xlsx.GetRows <CommuLine>(sheet, progress2));

                IEnumerable <string> commuFilenames = lines.Select(line => line.file).Distinct();
                int total2 = commuFilenames.Count();
                int count2 = 0;
                foreach (string filename in commuFilenames)
                {
                    count2++;
                    var fileLines = lines.Where(line => line.file == filename);
                    if (!patchZipFile.HasFile(filename) && fileLines.Any(line => !string.IsNullOrWhiteSpace(line.message)))
                    {
                        progress2?.Report(new ProgressData {
                            count = count2, total = total2, filename = filename
                        });
                        await Task.Run(() => patchZipFile.AddCommu(filename, fileLines));
                    }
                }
            }
        }
Exemple #2
0
 public async Task EditPatchTest(string refFile, string filename, string newFileName)
 {
     File.Copy(refFile, filename, true);
     using PatchZipFile patchZipFile = new PatchZipFile(filename, PatchZipMode.Update);
     using FileStream fileStream     = new FileStream(newFileName, FileMode.Open, FileAccess.Read);
     await patchZipFile.AddFile(fileStream, "im2nx_font.par");
 }
 public PatchZipModel(IReport parent, string inPath, IGetFileName getFileName)
     : base(parent, inPath.Substring(inPath.LastIndexOf('\\') + 1), getFileName)
 {
     try
     {
         _patchZipFile = new PatchZipFile(inPath, PatchZipMode.Update);
         SetBrowserEntries();
     }
     catch
     {
         Dispose();
         throw;
     }
 }
Exemple #4
0
        public async Task AddToPatchTest(
            string filename,
            string newFileName,
            string parameterName,
            string lyricDir,
            string commuName,
            string gtfDir)
        {
            using PatchZipFile patchZipFile = new PatchZipFile(filename, PatchZipMode.Create);
            patchZipFile.AddFile(newFileName, "im2nx_font.par");
            patchZipFile.AddParameterFiles(parameterName);
            await patchZipFile.AddLyrics(lyricDir);

            await patchZipFile.AddCommus(commuName, null, new System.Progress <ProgressData>(data => System.Console.WriteLine(data.ToString())));

            await patchZipFile.AddGtfs(gtfDir);
        }
Exemple #5
0
        static async Task MakePatch(MakePatchOptions o)
        {
            var progress = o.Verbose ? consoleProgress : null;

            using PatchZipFile patchZipFile = new PatchZipFile(o.Patch, o.Overwrite ? PatchZipMode.Create : PatchZipMode.Update);
            if (o.Files.Any())
            {
                List <string> files = o.Files.ToList();
                if (files.Count % 2 != 0)
                {
                    Console.Error.WriteLine("Odd number of --file command-line parameters.");
                    return;
                }
                else
                {
                    for (int i = 0; i < files.Count; i += 2)
                    {
                        progress?.Report(string.Format("Adding file {0} as {1}.", files[i], files[i + 1]));
                        patchZipFile.AddFile(files[i], files[i + 1]);
                    }
                }
            }
            if (o.Commu != null)
            {
                progress?.Report("Adding commus.");
                await patchZipFile.AddCommus(o.Commu, progress, progress);
            }
            if (o.Parameter != null)
            {
                progress?.Report("Adding parameter files.");
                patchZipFile.AddParameterFiles(o.Parameter);
            }
            if (o.Image != null)
            {
                progress?.Report("Adding images.");
                await patchZipFile.AddGtfs(o.Image, progress);
            }
            if (o.Lyrics != null)
            {
                progress?.Report("Adding lyrics.");
                await patchZipFile.AddLyrics(o.Lyrics, progress);
            }
            progress?.Report("Done.");
        }
Exemple #6
0
 public async Task CreatePatchTest(string filename, string newFileName)
 {
     using PatchZipFile patchZipFile = new PatchZipFile(filename, PatchZipMode.Create);
     using FileStream fileStream     = new FileStream(newFileName, FileMode.Open, FileAccess.Read);
     await patchZipFile.AddFile(fileStream, "im2nx_font.par");
 }
Exemple #7
0
 public void OpenPatchTest(string filename)
 {
     using PatchZipFile patchZipFile = new PatchZipFile(filename, PatchZipMode.Read);
 }