From 4174b0f77d0dceb68973efecbaf13d6e17faec09 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 16 Oct 2018 11:41:30 -0700 Subject: [PATCH] Move add printer logic to Part -> Print button - Later make reusable from Add Hardware and Print button - Issue MatterHackers/MCCentral#4294 --- .../ApplicationView/ApplicationController.cs | 10 +--------- .../Widgets/HardwarePage/HardwareTabPage.cs | 16 ++++++++-------- .../PartPreviewWindow/ViewControls3D.cs | 13 +++++++++++++ .../Settings/ProfileManager.cs | 1 - 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index cd28477fb..ac21f7899 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -1736,15 +1736,7 @@ namespace MatterHackers.MatterControl public void OnLoadActions() { bool showAuthWindow = ApplicationController.GuestUserActive?.Invoke() ?? false; - if (showAuthWindow) - { - if (ApplicationSettings.Instance.get(ApplicationSettingsKey.SuppressAuthPanel) != "True") - { - //Launch window to prompt user to sign in - UiThread.RunOnIdle(() => DialogWindow.Show(PrinterSetup.GetBestStartPage())); - } - } - else + if (!showAuthWindow) { //If user in logged in sync before checking to prompt to create printer if (ApplicationController.SyncPrinterProfiles == null) diff --git a/MatterControlLib/Library/Widgets/HardwarePage/HardwareTabPage.cs b/MatterControlLib/Library/Widgets/HardwarePage/HardwareTabPage.cs index bd4656a03..c1de8e5d4 100644 --- a/MatterControlLib/Library/Widgets/HardwarePage/HardwareTabPage.cs +++ b/MatterControlLib/Library/Widgets/HardwarePage/HardwareTabPage.cs @@ -119,14 +119,14 @@ namespace MatterHackers.MatterControl.PrintLibrary StyledMessageBox.ShowMessageBox( (deletePrinter) => { - if (deletePrinter) - { - if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) - { - ProfileManager.Instance.DeletePrinter(printerInfo.ID, true); - } - } - }, + if (deletePrinter) + { + if (treeView.SelectedNode.Tag is PrinterInfo printerInfo) + { + ProfileManager.Instance.DeletePrinter(printerInfo.ID, true); + } + } + }, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, diff --git a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs index ec817005d..1bc549c0c 100644 --- a/MatterControlLib/PartPreviewWindow/ViewControls3D.cs +++ b/MatterControlLib/PartPreviewWindow/ViewControls3D.cs @@ -41,6 +41,7 @@ using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.Library; +using MatterHackers.MatterControl.PrinterControls.PrinterConnections; using MatterHackers.MatterControl.PrintLibrary; using MatterHackers.VectorMath; @@ -215,6 +216,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (showPrintButton) { var printButton = new TextButton("Print", theme); + printButton.Click += (s, e) => + { + bool showAuthWindow = ApplicationController.GuestUserActive?.Invoke() ?? false; + if (showAuthWindow) + { + if (ApplicationSettings.Instance.get(ApplicationSettingsKey.SuppressAuthPanel) != "True") + { + //Launch window to prompt user to sign in + UiThread.RunOnIdle(() => DialogWindow.Show(PrinterSetup.GetBestStartPage())); + } + } + }; this.AddChild(printButton); } diff --git a/MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs b/MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs index 6f526d03b..a910ac9c3 100644 --- a/MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs +++ b/MatterControlLib/SlicerConfiguration/Settings/ProfileManager.cs @@ -134,7 +134,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public void DeletePrinter(string printerID, bool markedForDelete) { - bool isActivePrinter = printerID == this.ActiveProfile?.ID; var printerInfo = ProfileManager.Instance[printerID];