Suppress invalid Save dialog, disable Slice on stand-alone GCODE files

- Wire up listeners to keep button states in sync with content
This commit is contained in:
John Lewin 2022-09-01 13:24:08 -07:00
parent b11dbf2d2c
commit c8c938f562
4 changed files with 26 additions and 4 deletions

View file

@ -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,

View file

@ -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:

View file

@ -2163,7 +2163,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
sceneContext.Scene.UndoBuffer.ClearHistory();
}
else
{
{
this.SelectAll();
SceneActions.DeleteSelection(Scene);
}

@ -1 +1 @@
Subproject commit 2cfd64bdeacd33f5be83556f54757b15101af146
Subproject commit ae83bc8ff30bc77e0cc3c2596beeda0c560d5e36