Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
2fae50dd2e
1 changed files with 16 additions and 18 deletions
|
|
@ -298,44 +298,42 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Printer GetAutoConnectProfile(out bool connectionAvailable)
|
||||
{
|
||||
string query = string.Format("SELECT * FROM Printer;");
|
||||
IEnumerable<Printer> printer_profiles = (IEnumerable<Printer>)Datastore.Instance.dbSQLite.Query<Printer>(query);
|
||||
string[] comportNames = FrostedSerialPort.GetPortNames();
|
||||
|
||||
Printer printerToSelect = null;
|
||||
connectionAvailable = false;
|
||||
Printer printerToSelect = null;
|
||||
connectionAvailable = false;
|
||||
|
||||
foreach (Printer printer in printer_profiles)
|
||||
foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue