static void Main(string[] args) { if (args.Count() < 1) { Console.WriteLine("Usage: DirtyPCB_BoardStats.exe <infile>|<infolder>|<inzip>"); return; } Stats TheStats = new Stats(); if (Directory.Exists(args[0])) { GerberLibrary.GerberImageCreator GIC = new GerberLibrary.GerberImageCreator(); foreach (var L in Directory.GetFiles(args[0]).ToList()) { TheStats.AddFile(L); } } else if (File.Exists(args[0])) { if (Path.GetExtension(args[0]).ToLower() == ".zip") { using (ZipFile zip1 = ZipFile.Read(args[0])) { foreach (ZipEntry e in zip1) { MemoryStream MS = new MemoryStream(); if (e.IsDirectory == false) { e.Extract(MS); MS.Seek(0, SeekOrigin.Begin); TheStats.AddFile(MS, e.FileName); } } } } else { TheStats.AddFile(args[0]); } } TheStats.Complete(); var json = new JavaScriptSerializer().Serialize(TheStats); Console.WriteLine(json); }
public void doStuff() { GerberLibrary.GerberImageCreator GIC = new GerberLibrary.GerberImageCreator(); GerberLibrary.BoardRenderColorSet Colors = new GerberLibrary.BoardRenderColorSet(); Colors.BoardRenderColor = GerberLibrary.Gerber.ParseColor(SolderMaskColor); Colors.BoardRenderSilkColor = GerberLibrary.Gerber.ParseColor(SilkScreenColor); Colors.BoardRenderPadColor = GerberLibrary.Gerber.ParseColor(CopperColor); SetProgress("Image generation started", -1); GIC.SetColors(Colors); GerberLibrary.Gerber.SaveIntermediateImages = true; bool fixgroup = true; string ext1 = Path.GetExtension(Files[0]); if (Files.Count == 1 && ext1 != ".zip") { fixgroup = false; } GIC.AddBoardsToSet(Files, fixgroup, this); if (GIC.Errors.Count > 0) { foreach (var a in GIC.Errors) { Errors.Add(String.Format("Error: {0}", a)); } } try { if (GIC.Count() > 1) { if (Files.Count() == 1) { string justthefilename = Path.Combine(Path.GetDirectoryName(Files[0]), Path.GetFileNameWithoutExtension(Files[0])); GIC.WriteImageFiles(justthefilename, 400, true, this); } else { GIC.WriteImageFiles(Path.GetDirectoryName(Files[0]) + ".png", 400, true, this); } // GIC.DrawAllFiles(Path.GetDirectoryName(Files[0]) + "_Layer", 200, this); } else { GIC.DrawAllFiles(Files[0] + "_Layer", 200, this); } } catch (Exception E) { Errors.Add("Some errors:"); while (E != null) { Errors.Add(E.Message); E = E.InnerException; } } SetProgress("Done!", -1); if (Errors.Count > 0) { SetProgress("Encountered some problems during image generation:", -1); } foreach (var a in Errors) { SetProgress(a, -1); } }