Moved to EventHandler
Connection Failed DestinationChanged
This commit is contained in:
parent
82a7eb2587
commit
5d6be0c4bf
8 changed files with 33 additions and 26 deletions
|
|
@ -60,12 +60,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.PopupContent = this.GetPopupContent(ApplicationController.Instance.MenuTheme);
|
||||
|
||||
void DisplayTemp(object s, EventArgs e)
|
||||
void BedTemperatureRead(object s, EventArgs e)
|
||||
{
|
||||
DisplayCurrentTemperature();
|
||||
}
|
||||
printer.Connection.BedTemperatureRead += DisplayTemp;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= DisplayTemp;
|
||||
printer.Connection.BedTemperatureRead += BedTemperatureRead;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= BedTemperatureRead;
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printer.Connection.ActualBedTemperature;
|
||||
|
|
|
|||
|
|
@ -201,12 +201,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.PopupContent = this.GetPopupContent(ApplicationController.Instance.MenuTheme);
|
||||
|
||||
void DisplayTemp(object s, EventArgs e)
|
||||
void BedTemperatureRead(object s, EventArgs e)
|
||||
{
|
||||
DisplayCurrentTemperature();
|
||||
}
|
||||
printer.Connection.BedTemperatureRead += DisplayTemp;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= DisplayTemp;
|
||||
printer.Connection.BedTemperatureRead += BedTemperatureRead;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= BedTemperatureRead;
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printer.Connection.GetActualHotendTemperature(this.hotendIndex);
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
public BedStatusWidget(PrinterConfig printer, bool smallScreen, ThemeConfig theme)
|
||||
: base(printer, smallScreen ? "Bed".Localize() : "Bed Temperature".Localize(), theme)
|
||||
{
|
||||
void DisplayTemp(object s, EventArgs e)
|
||||
void BedTemperatureRead(object s, EventArgs e)
|
||||
{
|
||||
UpdateTemperatures();
|
||||
}
|
||||
printer.Connection.BedTemperatureRead += DisplayTemp;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= DisplayTemp;
|
||||
printer.Connection.BedTemperatureRead += BedTemperatureRead;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= BedTemperatureRead;
|
||||
}
|
||||
|
||||
public override void UpdateTemperatures()
|
||||
|
|
|
|||
|
|
@ -41,12 +41,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
this.extruderIndex = extruderIndex;
|
||||
|
||||
void DisplayTemp(object s, EventArgs e)
|
||||
void BedTemperatureRead(object s, EventArgs e)
|
||||
{
|
||||
UpdateTemperatures();
|
||||
}
|
||||
printer.Connection.BedTemperatureRead += DisplayTemp;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= DisplayTemp;
|
||||
printer.Connection.BedTemperatureRead += BedTemperatureRead;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= BedTemperatureRead;
|
||||
}
|
||||
|
||||
public override void UpdateTemperatures()
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.Closed += (s, e) => printer.Connection.CommunicationStateChanged -= CommunicationStateChanged;
|
||||
|
||||
printer.Connection.EnableChanged.RegisterEvent((s, e) => SetVisibleStates(), ref unregisterEvents);
|
||||
printer.Connection.ConnectionFailed.RegisterEvent((s, e) =>
|
||||
|
||||
void ConnectionFailed(object s, EventArgs e)
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// TODO: Someday this functionality should be revised to an awaitable Connect() call in the Connect button that
|
||||
|
|
@ -171,7 +172,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
#endif
|
||||
listenForConnectFailed = false;
|
||||
}, ref unregisterEvents);
|
||||
}
|
||||
printer.Connection.ConnectionFailed += ConnectionFailed;
|
||||
this.Closed += (s, e) => printer.Connection.ConnectionFailed -= ConnectionFailed;
|
||||
|
||||
this.SetVisibleStates();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
public EventHandler CommunicationStateChanged;
|
||||
|
||||
public RootedObjectEventHandler ConnectionFailed = new RootedObjectEventHandler();
|
||||
public EventHandler ConnectionFailed;
|
||||
|
||||
public RootedObjectEventHandler ConnectionSucceeded = new RootedObjectEventHandler();
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
PauseOnLayer?.Invoke(this, namedItemEventArgs);
|
||||
}
|
||||
|
||||
public RootedObjectEventHandler DestinationChanged = new RootedObjectEventHandler();
|
||||
public event EventHandler DestinationChanged;
|
||||
|
||||
public RootedObjectEventHandler EnableChanged = new RootedObjectEventHandler();
|
||||
|
||||
|
|
@ -245,7 +245,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
this.printer = printer;
|
||||
|
||||
TerminalLog = new TerminalLog(this);
|
||||
TerminalLog = new TerminalLog(printer);
|
||||
|
||||
MonitorPrinterTemperature = true;
|
||||
|
||||
|
|
@ -1230,7 +1230,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
communicationPossible = false;
|
||||
|
||||
var eventArgs = new ConnectFailedEventArgs(reason);
|
||||
ConnectionFailed.CallEvents(this, eventArgs);
|
||||
ConnectionFailed?.Invoke(this, eventArgs);
|
||||
|
||||
CommunicationState = CommunicationStates.Disconnected;
|
||||
OnEnabledChanged(eventArgs);
|
||||
|
|
@ -1503,7 +1503,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
//if (currentDestination != positionRead)
|
||||
{
|
||||
currentDestination = lastReportedPosition;
|
||||
DestinationChanged.CallEvents(this, null);
|
||||
DestinationChanged?.Invoke(this, null);
|
||||
if (totalGCodeStream != null)
|
||||
{
|
||||
totalGCodeStream.SetPrinterPosition(currentDestination);
|
||||
|
|
@ -2061,7 +2061,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|| currentDestination.extrusion != newDestination.extrusion)
|
||||
{
|
||||
currentDestination = newDestination;
|
||||
DestinationChanged.CallEvents(this, null);
|
||||
DestinationChanged?.Invoke(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,10 +209,12 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
});
|
||||
});
|
||||
|
||||
printer.Connection.DestinationChanged.RegisterEvent((object sender, EventArgs e) =>
|
||||
void BedTemperatureRead(object s, EventArgs e)
|
||||
{
|
||||
reportDestinationChanged.CallEvent();
|
||||
}, ref unregisterEvents);
|
||||
}
|
||||
printer.Connection.BedTemperatureRead += BedTemperatureRead;
|
||||
this.Closed += (s, e) => printer.Connection.BedTemperatureRead -= BedTemperatureRead;
|
||||
|
||||
return hwDestinationBar;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,13 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public TerminalLog(PrinterConnection printerConnection)
|
||||
public TerminalLog(PrinterConfig printer)
|
||||
{
|
||||
printerConnection.ConnectionFailed.RegisterEvent(Instance_ConnectionFailed, ref unregisterEvents);
|
||||
printerConnection.LineReceived += Printer_LineReceived;
|
||||
printerConnection.LineSent += Printer_LineSent;
|
||||
printer.Connection.ConnectionFailed += Instance_ConnectionFailed;
|
||||
printer.Disposed += (s, e) => printer.Connection.ConnectionFailed -= Instance_ConnectionFailed;
|
||||
|
||||
printer.Connection.LineReceived += Printer_LineReceived;
|
||||
printer.Connection.LineSent += Printer_LineSent;
|
||||
|
||||
if (Is32Bit)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue