diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 42ad91b43..50980a297 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -239,7 +239,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (File.Exists(printItem.FileLocation)) { string gcodePathAndFileName = printItem.GetGCodePathAndFileName(); - bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); if (printItem.SlicingHadError) { @@ -250,7 +249,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow firstProcessingMessage = pressGenerateMessage; } - if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) + if (File.Exists(gcodePathAndFileName)) { gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName)); } diff --git a/Queue/PrintItemWrapper.cs b/Queue/PrintItemWrapper.cs index a733dd628..8d47a979d 100644 --- a/Queue/PrintItemWrapper.cs +++ b/Queue/PrintItemWrapper.cs @@ -278,42 +278,9 @@ namespace MatterHackers.MatterControl.PrintQueue } } - public bool IsGCodeFileComplete(string gcodePathAndFileName) - { - if (Path.GetExtension(FileLocation).ToUpper() == ".GCODE") - { - return true; - } - - bool gCodeFileIsComplete = false; - if (File.Exists(gcodePathAndFileName)) - { - string gcodeFileContents = ""; - using (FileStream fileStream = new FileStream(gcodePathAndFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) - { - using (StreamReader gcodeStreamReader = new StreamReader(fileStream)) - { - gcodeFileContents = gcodeStreamReader.ReadToEnd(); - } - } - - // check if there is a known line at the end of the file (this will let us know if slicer finished building the file). - if (gcodeFileContents.Contains("filament used =")) - { - gCodeFileIsComplete = true; - } - } - - return gCodeFileIsComplete; - } - public void OnSlicingOutputMessage(EventArgs e) { - StringEventArgs message = e as StringEventArgs; - if (SlicingOutputMessage != null) - { - SlicingOutputMessage(this, message); - } + SlicingOutputMessage?.Invoke(this, e as StringEventArgs); } } } \ No newline at end of file diff --git a/SlicerConfiguration/SlicingQueue.cs b/SlicerConfiguration/SlicingQueue.cs index e3c3618fc..c73d3a02c 100644 --- a/SlicerConfiguration/SlicingQueue.cs +++ b/SlicerConfiguration/SlicingQueue.cs @@ -348,14 +348,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration itemCurrentlySlicing = itemToSlice; MatterHackers.MatterSlice.LogOutput.GetLogWrites += SendProgressToItem; - SliceFile(itemToSlice.FileLocation, gcodeFilePath, itemToSlice.IsGCodeFileComplete(gcodeFilePath), reporter); + SliceFile(itemToSlice.FileLocation, gcodeFilePath, reporter); MatterHackers.MatterSlice.LogOutput.GetLogWrites -= SendProgressToItem; itemCurrentlySlicing = null; } else { - SliceFile(itemToSlice.FileLocation, gcodeFilePath, itemToSlice.IsGCodeFileComplete(gcodeFilePath), reporter); + SliceFile(itemToSlice.FileLocation, gcodeFilePath, reporter); } } @@ -382,30 +382,27 @@ namespace MatterHackers.MatterControl.SlicerConfiguration await Task.Run(() => SliceFile( printItem.FileLocation, gcodeFilePath, - printItem.IsGCodeFileComplete(gcodeFilePath), progressReporter)); } - public static async Task SliceFileAsync(string sourceFile, string gcodeFilePath, bool gcodeFileIsComplete, IProgress progressReporter) + public static async Task SliceFileAsync(string sourceFile, string gcodeFilePath, IProgress progressReporter) { - await Task.Run(() => SliceFile(sourceFile, gcodeFilePath, gcodeFileIsComplete, progressReporter)); + await Task.Run(() => SliceFile(sourceFile, gcodeFilePath, progressReporter)); } - private static void SliceFile(string sourceFile, string gcodeFilePath, bool gcodeFileIsComplete, IProgress progressReporter) + private static void SliceFile(string sourceFile, string gcodeFilePath, IProgress progressReporter) { string mergeRules = ""; string[] stlFileLocations = GetStlFileLocations(sourceFile, ref mergeRules); string fileToSlice = stlFileLocations[0]; - // check that the STL file is currently on disk - if (File.Exists(fileToSlice)) { string configFilePath = Path.Combine( ApplicationDataStorage.Instance.GCodeOutputPath, string.Format("config_{0}.ini", ActiveSliceSettings.Instance.GetLongHashCode().ToString())); - if (!File.Exists(gcodeFilePath) || !gcodeFileIsComplete) + if (!File.Exists(gcodeFilePath)) { string commandArgs;