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()
|
public static void CheckForAndDoAutoConnect()
|
||||||
{
|
{
|
||||||
bool connectionAvailable;
|
bool connectionAvailable;
|
||||||
DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable);
|
DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile(out connectionAvailable);
|
||||||
if (autoConnectProfile != null)
|
if (autoConnectProfile != null)
|
||||||
{
|
{
|
||||||
ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
|
ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
|
||||||
if (connectionAvailable)
|
if (connectionAvailable)
|
||||||
{
|
{
|
||||||
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||||
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Printer GetAutoConnectProfile(out bool connectionAvailable)
|
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();
|
string[] comportNames = FrostedSerialPort.GetPortNames();
|
||||||
|
|
||||||
Printer printerToSelect = null;
|
Printer printerToSelect = null;
|
||||||
connectionAvailable = false;
|
connectionAvailable = false;
|
||||||
|
|
||||||
foreach (Printer printer in printer_profiles)
|
foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;"))
|
||||||
{
|
{
|
||||||
if (printer.AutoConnectFlag)
|
if (printer.AutoConnectFlag)
|
||||||
{
|
{
|
||||||
printerToSelect = printer;
|
printerToSelect = printer;
|
||||||
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
||||||
if (portIsAvailable)
|
if (portIsAvailable)
|
||||||
{
|
{
|
||||||
// We found a printer that we can select and connect to.
|
// We found a printer that we can select and connect to.
|
||||||
connectionAvailable = true;
|
connectionAvailable = true;
|
||||||
return printer;
|
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;
|
return printerToSelect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue