diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index e54216021..520ece7b8 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -69,6 +69,8 @@ namespace MatterHackers.MatterControl public event EventHandler LoadedGCodeChanged; + private PrintItemWrapper printItem => ApplicationController.Instance.ActivePrintItem; + public View3DConfig RendererOptions { get; } = new View3DConfig(); private GCodeFile loadedGCode; @@ -132,6 +134,15 @@ namespace MatterHackers.MatterControl public GCodeRenderInfo RenderInfo { get; set; } + public string GCodePath + { + get + { + bool isGCode = Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE"; + return isGCode ? printItem.FileLocation : printItem.GetGCodePathAndFileName(); + } + } + internal void Render3DLayerFeatures() { if (this.RenderInfo != null) diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 905d208f1..9253366a4 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -33,16 +33,13 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.GCodeVisualizer; using MatterHackers.Localizations; -using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow { public class ViewGcodeBasic : GuiWidget { private TextWidget gcodeProcessingStateInfoText; - private PrintItemWrapper printItem => ApplicationController.Instance.ActivePrintItem; private GuiWidget gcodeDisplayWidget; @@ -50,8 +47,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private EventHandler unregisterEvents; - public delegate Vector2 GetSizeFunction(); - private string gcodeLoading = "Loading G-Code".Localize(); private string slicingErrorMessage = "Slicing Error.\nPlease review your slice settings.".Localize(); private string fileNotFoundMessage = "File not found on disk.".Localize(); @@ -105,17 +100,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Stretch }; - if (printItem != null) - { - SetProcessingMessage("Loading G-Code...".Localize()); - - bool isGCode = Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE"; - - string gcodeFilePath = isGCode ? printItem.FileLocation : printItem.GetGCodePathAndFileName(); - if (!File.Exists(gcodeFilePath)) - { - SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name)); - } + if (!File.Exists(printer.Bed.GCodePath)) + { + SetProcessingMessage($"{fileNotFoundMessage}\n'{printer.Bed.GCodePath}'"); } mainContainerTopToBottom.AddChild(gcodeDisplayWidget); @@ -126,15 +113,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow SetProcessingMessage(""); if (loadedGCode == null) { - // If we have finished loading the gcode and the source file exists but we don't have any loaded gcode it is because the loader decided to not load it. - if (File.Exists(printItem.FileLocation)) - { - SetProcessingMessage(string.Format(fileTooBigToLoad, printItem.Name)); - } - else - { - SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, Path.GetFileName(printItem.FileLocation))); - } + SetProcessingMessage($"{fileNotFoundMessage}\n'{printer.Bed.GCodePath}'"); } if (loadedGCode?.LineCount > 0)