NTTabPage Class
This is where the actual content for tabs inside the custom add on NTWindow can be defined.
A class derived from NTTabPage has to be created if instrument link or interval link functionality is desired. IInstrumentProvider and IIntervalProvider interfaces should be implemented as well to ensure proper linking.
| Method | Description |
|---|---|
| Cleanup() | Unregisters LinkControls and calls Cleanup() on ICleanable controls on the NTTabPage |
| GetHeaderPart() | Indicates the tab header name. |
| Restore() | Restores any elements in our NTTabPage from the workspace. |
| Save() | Saves elements in our NTTabPage to the workspace. |
Examples
1 public class MyWindowTabPage : NTTabPage, NinjaTrader.Gui.Tools.IInstrumentProvider, IIntervalProvider 2 { 3 private Instrument instrument; 4 5 public MyWindowTabPage() 6 { 7 /* Define the content for our NTTabPage. We can load loose XAML to define controls and layouts 8 if we so choose here as well. 9 10 Note: XAML with event handlers defined inside WILL FAIL when attempted to load. 11 Note: XAML with "inline code" WILL FAIL when attempted to load */ 12 } 13 14 // Called by TabControl when a tab is being removed or window is closed 15 public override void Cleanup() 16 { 17 /* Unsubscribe and clean up resources used by the tab that just closed. You may have 18 resources you don't want to clean up just yet because the window is still being used */ 19 } 20 21 // NTTabPage member. Required for determining the tab header name 22 protected override string GetHeaderPart(string variable) 23 { 24 // Determine the text for the tab header name 25 return variable; 26 } 27 28 // NTTabPage member. Required for restoring elements from workspaces 29 protected override void Restore(System.Xml.Linq.XElement element) 30 { 31 if (element == null) 32 return; 33 34 // Restore any elements you may have saved. e.g. selected accounts or instruments 35 } 36 37 // NTTabPage member. Required for saving elements to workspaces 38 protected override void Save(System.Xml.Linq.XElement element) 39 { 40 if (element == null) 41 return; 42 43 // Save any elements you may want persisted. e.g. selected accounts or instruments 44 } 45 46 // IInstrumentProvider member 47 public Instrument Instrument 48 { 49 get { return instrument; } 50 set 51 { 52 if (instrument != null) 53 { 54 // Unsubscribe to subscriptions to previously selected instrument 55 } 56 57 if (value != null) 58 { 59 // Create subscriptions for the newly selected instrument 60 } 61 62 instrument = value; 63 64 // Update the tab header name 65 RefreshHeader(); 66 } 67 } 68 69 // IIntervalProvider member 70 public BarsPeriod BarsPeriod { get; set; } 71 }

