/* Example of subscribing/unsubscribing to sim account reset events from an Add On. The concept can be carried over to any NinjaScript object you may be working on. */
public class MyAddOnTab : NTTabPage
{
public MyAddOnTab()
{
// Subscribe to sim account resets
Account.SimulationAccountReset += OnSimulationAccountReset;
}
/* This method is fired on sim account reset events. It is important to recreate bar requests
after a reset on the Playback connection */
private void OnSimulationAccountReset(object sender, EventArgs e)
{
Account simAccount = (sender as Account);
// If the account was reset due to a rewind/fast forward of the Playback connection
if (simAccount != null && simAccount.Provider == Provider.Playback)
{
// Redo our bars requests here
}
}
// Called by **TabControl** when tab is being removed or window is closed
public override void Cleanup()
{
// Make sure to unsubscribe to the simulation account reset subscription
Account.SimulationAccountReset -= OnSimulationAccountReset;
}
// Other required **NTTabPage** members left out for demonstration purposes. Be sure to add them in your own code.
}