From ce6628712019dffebf65a10e01a6624eb7139340 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Thu, 17 Apr 2014 18:03:30 -0700 Subject: [PATCH] Made better slice error feedback (it was broke). Took out some dead code. Made explicit having a slice error on a print item wrapper. More strings into localization. --- .../BaseClasses/PartPreviewWidget.cs | 1 - PartPreviewWindow/GcodeViewBasic.cs | 37 ++++++------------- PrintQueue/PrintItemWrapper.cs | 17 +++++++-- StaticData/Translations/Master.txt | 12 ++++++ 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs b/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs index f19140f18..46bc43ff8 100644 --- a/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs +++ b/PartPreviewWindow/BaseClasses/PartPreviewWidget.cs @@ -86,7 +86,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow expandMenuOptionFactory.hoverFillColor = new RGBA_Bytes(255, 255, 255, 50); expandMenuOptionFactory.pressedFillColor = new RGBA_Bytes(255, 255, 255, 50); expandMenuOptionFactory.disabledFillColor = new RGBA_Bytes(255, 255, 255, 50); - checkboxButtonFactory.fontSize = 11; checkboxButtonFactory.FixedWidth = SideBarButtonWidth; diff --git a/PartPreviewWindow/GcodeViewBasic.cs b/PartPreviewWindow/GcodeViewBasic.cs index 5d1ea1abd..2e058464f 100644 --- a/PartPreviewWindow/GcodeViewBasic.cs +++ b/PartPreviewWindow/GcodeViewBasic.cs @@ -54,11 +54,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow FlowLayoutWidget layerSelectionButtonsPannel; FlowLayoutWidget modelOptionsContainer; - FlowLayoutWidget layerOptionsContainer; FlowLayoutWidget displayOptionsContainer; CheckBox expandModelOptions; - CheckBox expandLayerOptions; CheckBox expandDisplayOptions; GuiWidget gcodeDispalyWidget; @@ -80,9 +78,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow CreateAndAddChildren(null); } + static string slicingErrorMessage = "Slicing Error.\nPlease review your slice settings.".Localize(); + static string pressGenerateMessage = "Press 'generate' to view layers".Localize(); + static string fileNotFoundMessage = "File not found on disk.".Localize(); void CreateAndAddChildren(object state) { RemoveAllChildren(); + gcodeViewWidget = null; + gcodeProcessingStateInfoText = null; FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; @@ -134,13 +137,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow string gcodePathAndFileName = printItem.GCodePathAndFileName; bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName); - if (gcodeProcessingStateInfoText.Text == "Slicing Error") + if (printItem.SlicingHadError) { - SetProcessingMessage(LocalizedString.Get("Slicing Error. Please review your slice settings.")); + SetProcessingMessage(slicingErrorMessage); } else { - SetProcessingMessage(LocalizedString.Get("Press 'generate' to view layers")); + SetProcessingMessage(pressGenerateMessage); } if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete) @@ -154,7 +157,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } else { - SetProcessingMessage(string.Format("{0}\n'{1}'", LocalizedString.Get("File not found on disk."), printItem.Name)); + SetProcessingMessage(string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name)); } } } @@ -196,7 +199,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { BorderDouble buttonMargin = new BorderDouble(top: 3); - string label = "MODEL".Localize().ToUpper(); + string label = "Model".Localize().ToUpper(); expandModelOptions = expandMenuOptionFactory.GenerateCheckBoxButton(label, "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandModelOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandModelOptions); @@ -207,15 +210,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow //modelOptionsContainer.Visible = false; buttonRightPanel.AddChild(modelOptionsContainer); - expandLayerOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Layer".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); - expandLayerOptions.Margin = new BorderDouble(bottom: 2); - //buttonRightPanel.AddChild(expandLayerOptions); - - layerOptionsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); - layerOptionsContainer.HAnchor = HAnchor.ParentLeftRight; - layerOptionsContainer.Visible = false; - buttonRightPanel.AddChild(layerOptionsContainer); - expandDisplayOptions = expandMenuOptionFactory.GenerateCheckBoxButton("Display".Localize().ToUpper(), "icon_arrow_right_no_border_32x32.png", "icon_arrow_down_no_border_32x32.png"); expandDisplayOptions.Margin = new BorderDouble(bottom: 2); buttonRightPanel.AddChild(expandDisplayOptions); @@ -242,7 +236,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void CreateOptionsContent() { AddModelInfo(modelOptionsContainer); - //AddLayerInfo(layerOptionsContainer); AddDisplayControls(displayOptionsContainer); } @@ -590,8 +583,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void AddHandlers() { expandModelOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandModelOptions_CheckedStateChanged); - expandLayerOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandScaleOptions_CheckedStateChanged); - expandDisplayOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandMirrorOptions_CheckedStateChanged); + expandDisplayOptions.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(expandDisplayOptions_CheckedStateChanged); } void expandModelOptions_CheckedStateChanged(object sender, EventArgs e) @@ -599,16 +591,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow modelOptionsContainer.Visible = expandModelOptions.Checked; } - void expandMirrorOptions_CheckedStateChanged(object sender, EventArgs e) + void expandDisplayOptions_CheckedStateChanged(object sender, EventArgs e) { displayOptionsContainer.Visible = expandDisplayOptions.Checked; } - void expandScaleOptions_CheckedStateChanged(object sender, EventArgs e) - { - layerOptionsContainer.Visible = expandLayerOptions.Checked; - } - public override void OnClosed(EventArgs e) { if (printItem != null) diff --git a/PrintQueue/PrintItemWrapper.cs b/PrintQueue/PrintItemWrapper.cs index 2e3dcfa6b..7f0c07c2b 100644 --- a/PrintQueue/PrintItemWrapper.cs +++ b/PrintQueue/PrintItemWrapper.cs @@ -36,6 +36,7 @@ using System.Threading; using System.Runtime.InteropServices; using System.Diagnostics; +using MatterHackers.Localizations; using MatterHackers.Agg.UI; using MatterHackers.Agg; using MatterHackers.MatterControl.DataStorage; @@ -63,7 +64,10 @@ namespace MatterHackers.MatterControl.PrintQueue public bool CurrentlySlicing { get; set; } - public PrintItemWrapper(DataStorage.PrintItem printItem) + bool slicingHadError = false; + public bool SlicingHadError { get { return slicingHadError; } } + + public PrintItemWrapper(DataStorage.PrintItem printItem) { this.PrintItem = printItem; this.fileType = Path.GetExtension(printItem.FileLocation).ToUpper(); @@ -80,6 +84,9 @@ namespace MatterHackers.MatterControl.PrintQueue } bool doneSlicing; + static string slicingError = "Slicing Error".Localize(); + static string readyToPrint = "Ready to Print".Localize(); + static string fileNotFound = "File Not Found\n'{0}'".Localize(); public bool DoneSlicing { get @@ -94,7 +101,8 @@ namespace MatterHackers.MatterControl.PrintQueue doneSlicing = value; if (doneSlicing) { - string message = "Slicing Error"; + string message = slicingError; + slicingHadError = true; if (File.Exists(FileLocation)) { string gcodePathAndFileName = GetGCodePathAndFileName(); @@ -104,13 +112,14 @@ namespace MatterHackers.MatterControl.PrintQueue // This is really just to make sure it is bigger than nothing. if (info.Length > 10) { - message = "Ready to Print"; + message = readyToPrint; + slicingHadError = false; } } } else { - message = string.Format("File Not Found\n'{0}'", FileLocation); + message = string.Format(fileNotFound, FileLocation); } OnSlicingOutputMessage(new StringEventArgs(message)); diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index f91467e14..8bd36c786 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1983,3 +1983,15 @@ Translated:Press 'Add' to select an item. English:Shop Translated:Shop +English:Slicing Error +Translated:Slicing Error + +English:Ready to Print +Translated:Ready to Print + +English:File Not Found\n'{0}' +Translated:File Not Found\n'{0}' + +English:Slicing Error.\nPlease review your slice settings. +Translated:Slicing Error.\nPlease review your slice settings. +