private static bool ExtractIntFile(IntArgs args, LogInfo log) { Console.Clear(); DrawLogo(); WriteLog(log, false); Console.WriteLine($"Extracting {args.IntFile}:"); LogMessage(log, $"Extracting {args.IntFile}", args.Game); string inputDir = args.InputDir; if (string.IsNullOrEmpty(args.InputDir)) { inputDir = args.Game?.Path; } string outputDir = args.OutputDir; if (!string.IsNullOrEmpty(args.OutputDirAfter)) { outputDir = Path.Combine(args.OutputDir, args.Game.Name(), args.OutputDirAfter); } int line = Console.CursorTop; int lastLineLength = 0; try { Extracting.ExtractInt(inputDir, args.IntFile, args.Game.GetExtractExe(inputDir), outputDir, (a) => { WriteProgress(line, ref lastLineLength, a); return(false); }); LogMessage(log, "Finished!"); Beep(); return(true); } catch (Exception ex) { if (args.Game != null) { log.GamesFailed.Add(args.Game); } WriteError(ex); LogMessage(log, $"Error: {ex.Message}", args.Game); log.WriteLine(ex.ToString()); Beep(300, 750); Thread.Sleep(1500); return(false); } }
private void IntEventArgsHandler(object sender, IntEventArgs e) { // If _bytesCount is not set, we can't update the progress. if (_bytesCount == 0) { return; } var pold = (int)(_bytesWrittenOld * 100 / _bytesCount); _bytesWritten += e.Value; var pnow = (int)(_bytesWritten * 100 / _bytesCount); if (pnow > pold) { if (pnow > 100) { pold = pnow = 0; } _bytesWrittenOld = _bytesWritten; Extracting?.Invoke(this, new ProgressEventArgs((byte)pnow, (byte)(pnow - pold))); } }
private bool OnExtracting(CancelEventArgs e) { Extracting?.Invoke(this, e); return(e.Cancel); }
public void Main() { var res = Extracting.ExtractDigits(Source); Assert.AreEqual(Numbers, res); }
public void Main() { var res = Extracting.ExtractRussianEnglishDigitsSpaceAndPunctuation(Source); Assert.AreEqual(RusEngLetNumSpaceAndPunct, res); }
private static bool ResortPngs(PngArgs args, LogInfo log) { Console.Clear(); DrawLogo(); WriteLog(log, false); if (args.Game != null) { Console.WriteLine($"Resorting {args.Game.Name()} Pngs:"); } else { Console.WriteLine("Resorting Pngs:"); } LogMessage(log, "Resorting Pngs", args.Game); string resortDir = args.ResortDir; if (!string.IsNullOrEmpty(args.ResortDirAfter)) { resortDir = Path.Combine(args.ResortDir, args.Game.Name(), args.ResortDirAfter); } int line = Console.CursorTop; int lastLineLength = 0; bool error = false; Extracting.ResortPngs(resortDir, (a) => { WriteProgress(line, ref lastLineLength, a); return(false); }, (ex, a) => { if (!error) { LogMessage(log, $"Error on {a.FileName}: {ex.Message}", args.Game); log.WriteLine(ex.ToString()); /*if (args.StopOnError) { * a.TotalErrors = 0; * WriteProgress(line, ref lastLineLength, a); * Console.WriteLine(); * WriteError(ex); * Beep(300, 750); * Thread.Sleep(1500); * log.GamesFailed.Add(args.Game); * LogMessage(log, "Stopping due to error!"); * return true; * } * else*/ log.GamesWithErrors.Add(args.Game); } error = true; WriteProgress(line, ref lastLineLength, a); return(false); }); if (!error /* && !args.StopOnError*/) { LogMessage(log, "Finished!"); Beep(); } return(!error); }
private static bool ConvertHg3s(Hg3Args args, LogInfo log) { Console.Clear(); DrawLogo(); WriteLog(log, false); if (args.Game != null) { Console.WriteLine($"Converting {args.Game.Name()} Hg3s to Pngs:"); } else { Console.WriteLine("Converting Hg3s to Pngs:"); } LogMessage(log, "Converting Hg3s to Pngs", args.Game); string inputDir = args.InputDir; if (!string.IsNullOrEmpty(args.InputDirAfter)) { inputDir = Path.Combine(args.InputDir, args.Game.Name(), args.InputDirAfter); } string outputDir = args.OutputDir; if (!string.IsNullOrEmpty(args.OutputDirAfter)) { outputDir = Path.Combine(args.OutputDir, args.Game.Name(), args.OutputDirAfter); } int line = Console.CursorTop; int lastLineLength = 0; bool error = false; Extracting.ExtractHg3s(inputDir, outputDir, args.Sorting, args.Pattern, (a) => { WriteProgress(line, ref lastLineLength, a); return(false); }, (ex, a) => { if (!error) { LogMessage(log, $"Error on {a.FileName}: {ex.Message}", args.Game); log.WriteLine(ex.ToString()); if (args.StopOnError) { a.TotalErrors = 0; WriteProgress(line, ref lastLineLength, a); Console.WriteLine(); WriteError(ex); Beep(300, 750); Thread.Sleep(1500); log.GamesFailed.Add(args.Game); LogMessage(log, "Stopping due to error!"); return(true); } else { log.GamesWithErrors.Add(args.Game); } } error = true; WriteProgress(line, ref lastLineLength, a); return(false); }); if (!error && !args.StopOnError) { LogMessage(log, "Finished!"); Beep(); } return(!error); }
public void ShowExtractionProgress(FileProcessingProgressEventArgs eventArgs) { Extracting?.Invoke(this, eventArgs); }