From de337be1d5c05ecde5b0c85342d92bb2d04d1c8a Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 26 Jul 2016 12:42:03 -0700 Subject: [PATCH] Added ability to start a print when MatterControl initially loads. * Check to see if there is a specially named file on disk * If the file exists we skip the PrinterSetupWizard * Then we connect to a printer, add a file to the queue, slice, then start printing --- ApplicationView/MainApplicationWidget.cs | 47 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index fc011c771..f55094730 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -474,23 +474,31 @@ namespace MatterHackers.MatterControl { //UiThread.RunOnIdle(() => WizardWindow.Show("SoftwareLicense", "Software License Agreement")); } - bool showAuthWindow = WizardWindow.ShouldShowAuthPanel?.Invoke() ?? false; - if (showAuthWindow) + + if (!System.IO.File.Exists(@"/storage/sdcard0/Download/LaunchTestPrint.stl")) { - //Launch window to prompt user to log in - UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup()); - } - else - { //If user in logged in sync before checking to prompt to create printer - ApplicationController.SyncPrinterProfiles().ContinueWith((task) => + bool showAuthWindow = WizardWindow.ShouldShowAuthPanel?.Invoke() ?? false; + if (showAuthWindow) { - ApplicationController.Instance.ReloadAdvancedControlsPanel(); - if (!ProfileManager.Instance.ActiveProfiles.Any()) + //Launch window to prompt user to log in + UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup()); + } + else + { //If user in logged in sync before checking to prompt to create printer + ApplicationController.SyncPrinterProfiles().ContinueWith((task) => { + ApplicationController.Instance.ReloadAdvancedControlsPanel(); + if (!ProfileManager.Instance.ActiveProfiles.Any()) + { // Start the setup wizard if no profiles exist UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup()); - } - }); + } + }); + } + } + else + { + StartPrintingTest(); } if (ActiveSliceSettings.Instance.PrinterSelected @@ -503,5 +511,20 @@ namespace MatterHackers.MatterControl }, 2); } } + private EventHandler unregisterEvent; + public void StartPrintingTest() + { + QueueData.Instance.RemoveAll(); + QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem("LaunchTestPrint", @"/storage/sdcard0/Download/LaunchTestPrint.stl"))); + PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); + + PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((sender, e) => + { + if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Connected) + { + PrinterConnectionAndCommunication.Instance.PrintActivePartIfPossible(); + } + }, ref unregisterEvent); + } } } \ No newline at end of file