public bool EditGcodeContent() { string temp_gcodePath = MainParameter.AppdataPath + MainParameter.AssemblyFileVersion + "\\composition\\tempgcode.gcode"; //string temp_gcodePath = Application.CommonAppDataPath + "\\composition\\tempgcode.gcode"; string content = ""; string checker = "non-sintered powder"; FileStream fs = File.Open(temp_gcodePath, FileMode.Create); EnglishStreamWriter2 writer = new EnglishStreamWriter2(fs); if (!File.Exists(gcodePath)) { return(false); } try { using (StreamReader streamReader = new StreamReader(gcodePath /*, Encoding.UTF8*/)) { //var est_factor = Main.main.threedview.ui.ProfileSettings_UI.EstimatedTime_Factor; //asd double est_time = 0;// Main.main.totalEstimatedTime; //if (!Main.main.IsComputeMarkingTime) // est_time = 0.00; while (!streamReader.EndOfStream) { content = streamReader.ReadLine(); writer.Write(content + "\n"); if (content.Contains(checker)) { writer.Write("; total dxf file size (kb): " + Convert.ToInt64(MainParameter.TotalDXFFileSize) + "\n"); writer.Write("; total Estimated Marking time (ms): " + est_time.ToString("0.00") + "\n"); //writer.WriteLine("; total dxf file size (kb): " + Math.Round(Main.main.TotalDXFFileSize, 2) + "\n"); //writer.Write("; total Estimated Marking time (ms): " + est_time.ToString("0.00") + "\n"); } } writer.Flush(); writer.Close(); } File.Delete(gcodePath); File.Move(temp_gcodePath, gcodePath); return(true); } catch (Exception ex) { SVGTo3WL.logFile.writer.WriteLine("3WL Data, Error encountered: EditGcodeContent."); SVGTo3WL.logFile.writer.WriteLine("3WL Data exception: {0}", ex.ToString()); SVGTo3WL.logFile.writer.Flush(); Console.WriteLine("3WL Data, Error encountered: EditGcodeContent"); Console.WriteLine("3WL Data exception: {0}", ex.ToString()); gCode.Release(); return(false); } }
public bool GenerateHeaderFile() { //string headerFile = Application.CommonAppDataPath + "\\composition\\Header.txt"; string headerFile = MainParameter.AppdataPath + MainParameter.AssemblyFileVersion + "\\composition\\Header.txt"; FileStream fs = File.Open(headerFile, FileMode.Create); EnglishStreamWriter2 writer = new EnglishStreamWriter2(fs); try { writer.WriteLine("; total dxf file size (kb): " + Math.Round(MainParameter.TotalDXFFileSize, 2)); writer.Write("; total Estimated Marking time (secs): " + Math.Round(MainParameter.totalEstimatedTime, 4)); writer.Flush(); writer.Close(); return(true); } catch (Exception ex) { SVGTo3WL.logFile.writer.WriteLine("3WL Data, Error encountered: GenerateHeaderFile."); SVGTo3WL.logFile.writer.WriteLine("3WL Data exception: {0}", ex.ToString()); SVGTo3WL.logFile.writer.Flush(); Console.WriteLine("3WL Data, Error encountered: GenerateHeaderFile"); Console.WriteLine("3WL Data exception: {0}", ex.ToString()); gCode.Release(); return(false); } }