From 55a6f0fdc78b29398659cb015cd07b08c5043ca5 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 27 Jan 2022 16:49:46 -0800 Subject: [PATCH] On print complete text show printer name --- MatterControlLib/ApplicationView/ApplicationController.cs | 8 ++++---- MatterControlLib/ApplicationView/Config/PrinterConfig.cs | 4 +++- MatterControlLib/ApplicationView/PartWorkspace.cs | 2 +- MatterControlLib/CustomWidgets/ConfigurePrinterWidget.cs | 4 ++-- MatterControlLib/EeProm/EePromRepetierWindow.cs | 2 +- MatterControlLib/History/PrintHistoryEditor.cs | 2 +- MatterControlLib/History/PrintRecovery.cs | 2 +- .../Providers/MatterControl/PlatingHistoryContainer.cs | 2 +- .../Library/Providers/Printer/OpenPrintersContainer.cs | 2 +- .../Library/Providers/Printer/PrinterContainer.cs | 2 +- MatterControlLib/Library/Widgets/HardwareTreeView.cs | 2 +- MatterControlLib/PartPreviewWindow/MainViewWidget.cs | 6 +++--- .../View3D/PrinterBar/PrinterActionsBar.cs | 2 +- MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs | 2 +- .../PrinterCommunication/Io/PauseHandlingStream.cs | 4 ++-- .../PrinterCommunication/PrintPauseEventArgs.cs | 7 +++++-- .../PrinterCommunication/PrinterConnection.cs | 6 +++--- .../PrinterControls/EditLevelingSettingsPage.cs | 2 +- StaticData/Translations/Master.txt | 3 +++ Submodules/agg-sharp | 2 +- .../MatterControl.AutomationTests/PrinterDropDownTests.cs | 2 +- .../MatterControl/MatterControlUtilities.cs | 2 +- 22 files changed, 39 insertions(+), 31 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 67fafe70d..63165e233 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -340,7 +340,7 @@ namespace MatterHackers.MatterControl AggContext.FileDialogs.SaveFileDialog( new SaveFileDialogParams("MatterControl Printer Export|*.printer", title: "Export Printer Settings") { - FileName = printer.Settings.GetValue(SettingsKey.printer_name) + FileName = printer.PrinterName }, (saveParams) => { @@ -1060,7 +1060,7 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(() => { - var prinerName = printerConnection.Printer.Settings.GetValue(SettingsKey.printer_name); + var prinerName = printerConnection.Printer.PrinterName; var messageBox = new StyledMessageBox.MessageBoxPage((clickedOk) => { if (clickedOk && printerConnection.Paused) @@ -2143,7 +2143,7 @@ namespace MatterHackers.MatterControl using (var zip = new ZipArchive(file, ZipArchiveMode.Create)) { zip.CreateEntryFromFile(sourcePath, "PrinterPlate.mcx"); - zip.CreateEntryFromFile(settingsFilePath, printer.Settings.GetValue(SettingsKey.printer_name) + ".printer"); + zip.CreateEntryFromFile(settingsFilePath, printer.PrinterName + ".printer"); zip.CreateEntryFromFile(gcodeFilePath, "sliced.gcode"); } } @@ -2295,7 +2295,7 @@ namespace MatterHackers.MatterControl AnyPrintStarted?.Invoke(sender, e); } - public void Connection_PrintFinished(object sender, string e) + public void Connection_PrintFinished(object sender, (string printerName, string itemName) e) { if (sender is PrinterConnection printerConnection) { diff --git a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs index 130954565..dcbe0af71 100644 --- a/MatterControlLib/ApplicationView/Config/PrinterConfig.cs +++ b/MatterControlLib/ApplicationView/Config/PrinterConfig.cs @@ -96,6 +96,8 @@ namespace MatterHackers.MatterControl public PrinterSettings Settings { get; } = PrinterSettings.Empty; + public string PrinterName => Settings?.GetValue(SettingsKey.printer_name) ?? "unknown"; + [JsonIgnore] public PrinterConnection Connection { get; } @@ -180,7 +182,7 @@ namespace MatterHackers.MatterControl this.Bed.BedShape = this.Settings.GetValue(SettingsKey.bed_shape); } - private void Connection_PrintFinished(object s, string printName) + private void Connection_PrintFinished(object s, (string printerName, string itemName) e) { // clear single use setting on print completion foreach (var keyValue in this.Settings.BaseLayer) diff --git a/MatterControlLib/ApplicationView/PartWorkspace.cs b/MatterControlLib/ApplicationView/PartWorkspace.cs index 173e42bb4..a562bc16f 100644 --- a/MatterControlLib/ApplicationView/PartWorkspace.cs +++ b/MatterControlLib/ApplicationView/PartWorkspace.cs @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl { wrappedLibrary.ExtraContainers.Add( new DynamicContainerLink( - printer.Settings.GetValue(SettingsKey.printer_name), + printer.PrinterName, StaticData.Instance.LoadIcon(Path.Combine("Library", "folder.png")), StaticData.Instance.LoadIcon(Path.Combine("Library", "printer_icon.png")), () => new PrinterContainer(printer)) diff --git a/MatterControlLib/CustomWidgets/ConfigurePrinterWidget.cs b/MatterControlLib/CustomWidgets/ConfigurePrinterWidget.cs index f5b6bdb98..eee0c21b7 100644 --- a/MatterControlLib/CustomWidgets/ConfigurePrinterWidget.cs +++ b/MatterControlLib/CustomWidgets/ConfigurePrinterWidget.cs @@ -40,7 +40,7 @@ namespace MatterHackers.MatterControl public ConfigurePrinterWidget(SettingsContext settingsContext, PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) { - var inlineNameEdit = new InlineStringEdit(printer.Settings.GetValue(SettingsKey.printer_name), theme, "Printer Name", boldFont: true); + var inlineNameEdit = new InlineStringEdit(printer.PrinterName, theme, "Printer Name", boldFont: true); inlineNameEdit.ValueChanged += (s, e) => { printer.Settings.SetValue(SettingsKey.printer_name, inlineNameEdit.Text); @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl && stringEvent?.Data == SettingsKey.printer_name) { // Try to find a printer tab for the given printer - inlineNameEdit.Text = printerSettings.GetValue(SettingsKey.printer_name); + inlineNameEdit.Text = printer.PrinterName; } } diff --git a/MatterControlLib/EeProm/EePromRepetierWindow.cs b/MatterControlLib/EeProm/EePromRepetierWindow.cs index 0ae7a52b5..c45a09044 100644 --- a/MatterControlLib/EeProm/EePromRepetierWindow.cs +++ b/MatterControlLib/EeProm/EePromRepetierWindow.cs @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.EeProm protected string GetSanitizedPrinterName() { // TODO: Determine best file name sanitization implementation: this, MakeValidFileName, something else? - string printerName = printer.Settings.GetValue(SettingsKey.printer_name).Replace(" ", "_"); + string printerName = printer.PrinterName.Replace(" ", "_"); return nameSanitizer.Replace(printerName, ""); } diff --git a/MatterControlLib/History/PrintHistoryEditor.cs b/MatterControlLib/History/PrintHistoryEditor.cs index ed58099a6..2036e5ccb 100644 --- a/MatterControlLib/History/PrintHistoryEditor.cs +++ b/MatterControlLib/History/PrintHistoryEditor.cs @@ -457,7 +457,7 @@ Support and tutorials:" + articles; : base("Close".Localize()) { this.WindowTitle = windowTitle; - this.HeaderText = printer.Settings.GetValue(SettingsKey.printer_name) + ": " + windowTitle; + this.HeaderText = printer.PrinterName + ": " + windowTitle; this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 440 * GuiWidget.DeviceScale); var scrollable = new ScrollableWidget(autoScroll: true) diff --git a/MatterControlLib/History/PrintRecovery.cs b/MatterControlLib/History/PrintRecovery.cs index e356a785b..cfa4392fd 100644 --- a/MatterControlLib/History/PrintRecovery.cs +++ b/MatterControlLib/History/PrintRecovery.cs @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.PrintHistory }, "It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?".Localize() + (safeHomingDirection ? "" : "\n\n" + printRecoveryWarningMessage), - "Recover Last Print".Localize() + " - " + printer.Settings.GetValue(SettingsKey.printer_name), + "Recover Last Print".Localize() + " - " + printer.PrinterName, StyledMessageBox.MessageType.YES_NO, "Recover Print".Localize(), "Cancel".Localize(), diff --git a/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs index b81279a49..2f12f2387 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PlatingHistoryContainer.cs @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.Library internal ILibraryItem NewBedPlate(BedConfig bedConfig) { - var name = bedConfig.Printer.Settings.GetValue(SettingsKey.printer_name); + var name = bedConfig.Printer.PrinterName; string now = DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"); var filename = ApplicationController.Instance.SanitizeFileName($"{name} - {now}.mcx"); string mcxPath = Path.Combine(this.FullPath, filename); diff --git a/MatterControlLib/Library/Providers/Printer/OpenPrintersContainer.cs b/MatterControlLib/Library/Providers/Printer/OpenPrintersContainer.cs index d84bd053e..7975441a7 100644 --- a/MatterControlLib/Library/Providers/Printer/OpenPrintersContainer.cs +++ b/MatterControlLib/Library/Providers/Printer/OpenPrintersContainer.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.Library { this.ChildContainers.Add( new DynamicContainerLink( - printer.Settings.GetValue(SettingsKey.printer_name), + printer.PrinterName, StaticData.Instance.LoadIcon(Path.Combine("Library", "folder.png")), StaticData.Instance.LoadIcon(Path.Combine("Library", "printer_icon.png")), () => new PrinterContainer(printer), diff --git a/MatterControlLib/Library/Providers/Printer/PrinterContainer.cs b/MatterControlLib/Library/Providers/Printer/PrinterContainer.cs index d009c0024..94de53927 100644 --- a/MatterControlLib/Library/Providers/Printer/PrinterContainer.cs +++ b/MatterControlLib/Library/Providers/Printer/PrinterContainer.cs @@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.Library this.printer = printer; this.ChildContainers = new SafeList(); this.Items = new SafeList(); - this.Name = printer.Settings.GetValue(SettingsKey.printer_name); + this.Name = printer.PrinterName; } public override void Load() diff --git a/MatterControlLib/Library/Widgets/HardwareTreeView.cs b/MatterControlLib/Library/Widgets/HardwareTreeView.cs index e5998d1f9..dcd25b4bc 100644 --- a/MatterControlLib/Library/Widgets/HardwareTreeView.cs +++ b/MatterControlLib/Library/Widgets/HardwareTreeView.cs @@ -191,7 +191,7 @@ namespace MatterHackers.MatterControl.PrintLibrary // Add the menu items to the menu itself foreach (var printer in ApplicationController.Instance.ActivePrinters) { - string printerName = printer.Settings.GetValue(SettingsKey.printer_name); + string printerName = printer.PrinterName; var printerNode = new TreeNode(theme) { diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 46d2c8382..0a843539a 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -707,8 +707,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } var printerTab = new ChromeTab( - printer.Settings.GetValue(SettingsKey.printer_name), - printer.Settings.GetValue(SettingsKey.printer_name), + printer.PrinterName, + printer.PrinterName, tabControl, new PrinterTabPage(workspace, theme, "unused_tab_title"), theme, @@ -778,7 +778,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow new InputBoxPage( "Rename Item".Localize(), "Name".Localize(), - printer.Settings.GetValue(SettingsKey.printer_name), + printer.PrinterName, "Enter New Name Here".Localize(), "Rename".Localize(), (newName) => diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs index e7a048fb8..9cda9b635 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs @@ -437,7 +437,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ProfileManager.Instance.DeletePrinter(printer.Settings.ID); } }, - "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printer.Settings.GetValue(SettingsKey.printer_name)), + "Are you sure you want to delete printer '{0}'?".Localize().FormatWith(printer.PrinterName), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize()); diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 5ebdb1767..03168d8f4 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -1057,7 +1057,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } // Switch to printer - ApplicationController.Instance.MainView.TabControl.SelectedTabKey = printer.Settings.GetValue(SettingsKey.printer_name); + ApplicationController.Instance.MainView.TabControl.SelectedTabKey = printer.PrinterName; // Save any pending changes before starting print operation await ApplicationController.Instance.Tasks.Execute("Saving Changes".Localize(), printer, printer.Bed.SaveChanges); diff --git a/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs b/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs index 1fcc55782..edea4c6d3 100644 --- a/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs +++ b/MatterControlLib/PrinterCommunication/Io/PauseHandlingStream.cs @@ -182,11 +182,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io case PauseReason.PauseLayerReached: case PauseReason.GCodeRequest: - printer.Connection.OnPauseOnLayer(new PrintPauseEventArgs(printer.Bed.EditContext?.SourceItem?.Name ?? "Unknown", false, layerNumber)); + printer.Connection.OnPauseOnLayer(new PrintPauseEventArgs(printer.PrinterName, printer.Bed.EditContext?.SourceItem?.Name ?? "Unknown", false, layerNumber)); break; case PauseReason.FilamentRunout: - printer.Connection.OnFilamentRunout(new PrintPauseEventArgs(printer.Bed.EditContext?.SourceItem?.Name ?? "Unknown", true, layerNumber)); + printer.Connection.OnFilamentRunout(new PrintPauseEventArgs(printer.PrinterName, printer.Bed.EditContext?.SourceItem?.Name ?? "Unknown", true, layerNumber)); break; } diff --git a/MatterControlLib/PrinterCommunication/PrintPauseEventArgs.cs b/MatterControlLib/PrinterCommunication/PrintPauseEventArgs.cs index c5a23a155..8ab08db45 100644 --- a/MatterControlLib/PrinterCommunication/PrintPauseEventArgs.cs +++ b/MatterControlLib/PrinterCommunication/PrintPauseEventArgs.cs @@ -56,13 +56,16 @@ namespace MatterHackers.MatterControl.PrinterCommunication public class PrintPauseEventArgs : EventArgs { - public PrintPauseEventArgs(string name, bool filamentRunout, int layerNumber) + public PrintPauseEventArgs(string printerName, string itemName, bool filamentRunout, int layerNumber) { - this.ItemName = name; + this.PrinterName = printerName; + this.ItemName = itemName; this.FilamentRunout = filamentRunout; this.LayerNumber = layerNumber; } + public string PrinterName { get; } + public string ItemName { get; } public bool FilamentRunout { get; } diff --git a/MatterControlLib/PrinterCommunication/PrinterConnection.cs b/MatterControlLib/PrinterCommunication/PrinterConnection.cs index a50b5faaa..1930b7200 100644 --- a/MatterControlLib/PrinterCommunication/PrinterConnection.cs +++ b/MatterControlLib/PrinterCommunication/PrinterConnection.cs @@ -152,7 +152,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication FilamentRunout?.Invoke(this, printPauseEventArgs); } - public event EventHandler PrintFinished; + public event EventHandler<(string printerName, string itemName)> PrintFinished; public event EventHandler PrintStarted; @@ -611,7 +611,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication timePrinting.Stop(); if (Printer.Bed?.EditContext?.SourceItem.Name != null) { - PrintFinished?.Invoke(this, Printer.Bed.EditContext.SourceItem.Name); + PrintFinished?.Invoke(this, (Printer.PrinterName, Printer.Bed.EditContext.SourceItem.Name)); } } else @@ -2190,7 +2190,7 @@ Make sure that your printer is turned on. Some printers will appear to be connec PrintStart = DateTime.Now, PrinterId = this.Printer.Settings.ID.GetHashCode(), PrintName = activePrintItem.PrintItem.Name, - PrinterName = this.Printer.Settings.GetValue(SettingsKey.printer_name), + PrinterName = this.Printer.PrinterName, Guid = Guid.NewGuid().ToString(), PrintingGCodeFileName = gcodeFileNameForTask, PrintComplete = false, diff --git a/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs b/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs index fbac0250b..c22e0c436 100644 --- a/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs +++ b/MatterControlLib/PrinterControls/EditLevelingSettingsPage.cs @@ -169,7 +169,7 @@ namespace MatterHackers.MatterControl new SaveFileDialogParams("Bed Leveling Data|*.csv") { Title = "Export Bed Leveling Data".Localize(), - FileName = $"{printer.Settings.GetValue(SettingsKey.printer_name)} Leveling Data" + FileName = $"{printer.PrinterName} Leveling Data" }, (saveParams) => { diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 5c62df422..32ff00f98 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3403,6 +3403,9 @@ Translated:Surfaced Editors English:Switch Translated:Switch +English:Switch to new G-Code on next layer? +Translated:Switch to new G-Code on next layer? + English:Switch to new G-Code?\n\nBefore you switch, check that you are seeing the changes you expect. Translated:Switch to new G-Code?\n\nBefore you switch, check that you are seeing the changes you expect. diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 940c157f7..95a5397e4 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 940c157f73bb807176c08e799bf0bb55ba08f2df +Subproject commit 95a5397e4bca6346344451da499eb0af4dfa249f diff --git a/Tests/MatterControl.AutomationTests/PrinterDropDownTests.cs b/Tests/MatterControl.AutomationTests/PrinterDropDownTests.cs index ed82e1c19..d478bdff2 100644 --- a/Tests/MatterControl.AutomationTests/PrinterDropDownTests.cs +++ b/Tests/MatterControl.AutomationTests/PrinterDropDownTests.cs @@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl.Tests.Automation Assert.AreEqual(newName, printerTab.Title); // Validate that the settings layer reflects the new name - Assert.AreEqual(newName, printer.Settings.GetValue(SettingsKey.printer_name)); + Assert.AreEqual(newName, printer.PrinterName); return Task.CompletedTask; }); diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index 6884b58b4..1dc692034 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -628,7 +628,7 @@ namespace MatterHackers.MatterControl.Tests.Automation case "SD Card Row Item Collection": if (ApplicationController.Instance.DragDropData.View3DWidget?.Printer is PrinterConfig printer) { - testRunner.DoubleClickByName($"{printer.Settings.GetValue(SettingsKey.printer_name)} Row Item Collection"); + testRunner.DoubleClickByName($"{printer.PrinterName} Row Item Collection"); testRunner.Delay();