From 231adae24647105e64450eb77a14b8e638213f7c Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 23 Feb 2016 09:53:27 -0800 Subject: [PATCH 1/2] More concise db query --- PrinterCommunication/ActivePrinterProfile.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/PrinterCommunication/ActivePrinterProfile.cs b/PrinterCommunication/ActivePrinterProfile.cs index 222fa88f7..087897e08 100644 --- a/PrinterCommunication/ActivePrinterProfile.cs +++ b/PrinterCommunication/ActivePrinterProfile.cs @@ -313,14 +313,12 @@ namespace MatterHackers.MatterControl public static Printer GetAutoConnectProfile(out bool connectionAvailable) { - string query = string.Format("SELECT * FROM Printer;"); - IEnumerable printer_profiles = (IEnumerable)Datastore.Instance.dbSQLite.Query(query); string[] comportNames = FrostedSerialPort.GetPortNames(); Printer printerToSelect = null; connectionAvailable = false; - foreach (Printer printer in printer_profiles) + foreach (Printer printer in Datastore.Instance.dbSQLite.Query("SELECT * FROM Printer;")) { if (printer.AutoConnectFlag) { From 7567110bfb14c9dd095215370de8ef029b88dcd0 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 23 Feb 2016 09:54:13 -0800 Subject: [PATCH 2/2] Fix whitespace --- PrinterCommunication/ActivePrinterProfile.cs | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/PrinterCommunication/ActivePrinterProfile.cs b/PrinterCommunication/ActivePrinterProfile.cs index 087897e08..5b0168416 100644 --- a/PrinterCommunication/ActivePrinterProfile.cs +++ b/PrinterCommunication/ActivePrinterProfile.cs @@ -298,16 +298,16 @@ namespace MatterHackers.MatterControl public static void CheckForAndDoAutoConnect() { - bool connectionAvailable; - DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable); + bool connectionAvailable; + DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable); if (autoConnectProfile != null) { ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile; - if (connectionAvailable) - { - PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); - PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); - } + if (connectionAvailable) + { + PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); + PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); + } } } @@ -315,25 +315,25 @@ namespace MatterHackers.MatterControl { string[] comportNames = FrostedSerialPort.GetPortNames(); - Printer printerToSelect = null; - connectionAvailable = false; + Printer printerToSelect = null; + connectionAvailable = false; - foreach (Printer printer in Datastore.Instance.dbSQLite.Query("SELECT * FROM Printer;")) + foreach (Printer printer in Datastore.Instance.dbSQLite.Query("SELECT * FROM Printer;")) { if (printer.AutoConnectFlag) { - printerToSelect = printer; - bool portIsAvailable = comportNames.Contains(printer.ComPort); + printerToSelect = printer; + bool portIsAvailable = comportNames.Contains(printer.ComPort); if (portIsAvailable) { - // We found a printer that we can select and connect to. - connectionAvailable = true; - return printer; + // We found a printer that we can select and connect to. + connectionAvailable = true; + return printer; } } } - // return a printer we can connect to even though we can't connect + // return a printer we can connect to even though we can't connect return printerToSelect; } }