Hook connection fail/success and update accordingly

- Issue MatterHackers/MCCentral#3457
Setup Wizard does not show error if connection fails
This commit is contained in:
jlewin 2019-05-06 15:11:05 -07:00
parent e6ca25e43b
commit 75fb57b805

View file

@ -76,6 +76,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
printerComPortError.Text = "Attempting to connect".Localize() + "...";
printerComPortError.TextColor = theme.TextColor;
printer.Connection.ConnectionFailed += Connection_CommunicationStateChanged;
printer.Connection.ConnectionSucceeded += Connection_CommunicationStateChanged;
printer.Settings.Helpers.SetComPort(GetSelectedSerialPort());
printer.Connection.Connect();
@ -114,6 +117,8 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
// Unregister listeners
printer.Connection.CommunicationStateChanged -= Connection_CommunicationStateChanged;
printer.Connection.ConnectionFailed -= Connection_CommunicationStateChanged;
printer.Connection.ConnectionSucceeded -= Connection_CommunicationStateChanged;
base.OnClosed(e);
}