From c8c938f56282fa538677f37d4b1f746deb9d1273 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 1 Sep 2022 13:24:08 -0700 Subject: [PATCH] Suppress invalid Save dialog, disable Slice on stand-alone GCODE files - Wire up listeners to keep button states in sync with content --- .../View3D/PrinterBar/PrintPopupMenu.cs | 7 +++++-- .../View3D/PrinterBar/SliceButton.cs | 19 +++++++++++++++++++ .../PartPreviewWindow/View3D/View3DWidget.cs | 2 +- Submodules/agg-sharp | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index 86c91bf20..1f02019db 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -335,8 +335,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow UiThread.RunOnIdle(async () => { - // Save any pending changes before starting print operation - await ApplicationController.Instance.Tasks.Execute("Saving Changes".Localize(), printer, printer.Bed.SaveChanges); + // For non-gcode files, save pending changes before starting print operation + if (!printer.Bed.EditContext.IsGGCodeSource) + { + await ApplicationController.Instance.Tasks.Execute("Saving Changes".Localize(), printer, printer.Bed.SaveChanges); + } await ApplicationController.Instance.PrintPart( printer.Bed.EditContext, diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs index 059be0dbc..a4429dbeb 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs @@ -56,10 +56,21 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // Register listeners printer.Connection.CommunicationStateChanged += Connection_CommunicationStateChanged; + printer.Bed.SceneLoaded += Scene_Loaded; SetButtonStates(); } + private void Scene_Loaded(object sender, EventArgs e) + { + // Slicing disabled when loaded content is stand-alone GCODE file + if (printer.Bed.EditContext.IsGGCodeSource) + { + this.Enabled = false; + return; + } + } + protected override async void OnClick(MouseEventArgs mouseEvent) { base.OnClick(mouseEvent); @@ -70,6 +81,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { // Unregister listeners printer.Connection.CommunicationStateChanged -= Connection_CommunicationStateChanged; + printer.Bed.SceneLoaded -= Scene_Loaded; base.OnClosed(e); } @@ -81,6 +93,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private void SetButtonStates() { + // Slicing disabled when loaded content is stand-alone GCODE file + if (printer.Bed.EditContext.IsGGCodeSource) + { + this.Enabled = false; + return; + } + switch (printer.Connection.CommunicationState) { case CommunicationStates.PreparingToPrint: diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index b4220267e..e4245783f 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -2163,7 +2163,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow sceneContext.Scene.UndoBuffer.ClearHistory(); } else - { + { this.SelectAll(); SceneActions.DeleteSelection(Scene); } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 2cfd64bde..ae83bc8ff 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 2cfd64bdeacd33f5be83556f54757b15101af146 +Subproject commit ae83bc8ff30bc77e0cc3c2596beeda0c560d5e36