I'm creating an addon which creates a toggle button on the title bar, and then sets its IsChecked state from the workspace file. I'm having a problem because I'm expecting that the OnWindowCreated executes before the OnWindowRestored, as it discusses in the help file under OnWindowRestored. This allows me to create the button first in OnWindowCreated, and then set the state in OnWindowRestored. However, they seem to be executing in reverse order.
My code is:
int TestVariable = 2;
protected override void OnWindowCreated(Window window)
{
TestVariable = 5 * TestVariable;
if (window.GetType() == typeof(NinjaTrader.Gui.Chart.Chart)) LogMessage ("OnWindowCreated", window, TestVariable.ToString());
}
protected override void OnWindowRestored(Window window, XElement element)
{
TestVariable = TestVariable * TestVariable;
if (window.GetType() == typeof(NinjaTrader.Gui.Chart.Chart)) LogMessage ("OnWindowRestored", window, TestVariable.ToString());
}
The excerpt from the log file is:
2019-01-14 16:56:15:937|1|16|56:15 OnWindowRestored 25391661 4
2019-01-14 16:56:16:802|1|16|56:16 OnWindowCreated 25391661 20
I expected that the two statements be in opposite order, and that the numbers would be 10 and 100.
Can you tell me what I may be doing wrong? Thank you.
Comment