I found this article in your help guide:
There's a lot of good stuff there, but unfortunately it doesn't include a compilable version of the code. I've tried assembling it myself but to no avail.
Can you please point me to the code for an add-on I can install, or can you please include a complete, compilable version of the example provided in your help guide?
Thank you,
Ryan
By the way, this is where I gave up:
#region Using declarations using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media; using System.Xml.Serialization; using System.Xml.Linq; using NinjaTrader.Cbi; using NinjaTrader.Gui; using NinjaTrader.Gui.Chart; using NinjaTrader.Gui.SuperDom; using NinjaTrader.Gui.Tools; using NinjaTrader.Data; using NinjaTrader.NinjaScript; using NinjaTrader.Core.FloatingPoint; using NinjaTrader.Gui.Tools; #endregion //This namespace holds Add ons in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.AddOns { public class MyCustomAddOn : NinjaTrader.NinjaScript.AddOnBase { protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"Enter the description for your new custom Add on here."; Name = "MyCustomAddOn"; } else if (State == State.Configure) { } } protected override void OnWindowCreated(Window window) { // We want to place our AddOn in the Control Center's menus ControlCenter cc = window as ControlCenter; if (cc == null) return; /* Determine we want to place our AddOn in the Control Center's "New" menu Other menus can be accessed via the control's "Automation ID". For example: toolsMenuItem, workspacesMenuItem, connectionsMenuItem, helpMenuItem. */ existingMenuItemInControlCenter = cc.FindFirst("ControlCenterMenuItemNew") as NTMenuItem; if (existingMenuItemInControlCenter == null) return; // 'Header' sets the name of our AddOn seen in the menu structure addOnFrameworkMenuItem = new NTMenuItem { Header = "AddOn Framework", Style = Application.Current.TryFindResource("MainMenuItem") as Style }; // Add our AddOn into the "New" menu existingMenuItemInControlCenter.Items.Add(addOnFrameworkMenuItem); // Subscribe to the event for when the user presses our AddOn's menu item addOnFrameworkMenuItem.Click += OnMenuItemClick; } protected override void OnWindowDestroyed(Window window) { if (addOnFrameworkMenuItem != null && window is ControlCenter) { if (existingMenuItemInControlCenter != null && existingMenuItemInControlCenter.Items.Contains(addOnFrameworkMenuItem)) existingMenuItemInControlCenter.Items.Remove(addOnFrameworkMenuItem); addOnFrameworkMenuItem.Click -= OnMenuItemClick; addOnFrameworkMenuItem = null; } } // Open our AddOn's window when the menu item is clicked on private void OnMenuItemClick(object sender, RoutedEventArgs e) { Core.Globals.RandomDispatcher.BeginInvoke(new Action(() => new AddOnFrameworkWindow().Show())); } } /* This is where we define our AddOn window. The actual content is contained inside the tabs of the window defined in a custom class inheriting from NTTabPage. We must create a new window class which inherits from Tools.NTWindow for styling and implements the IWorkspacePersistence interface for the ability to save/restore from workspaces.*/ public class AddOnFrameworkWindow : NTWindow, IWorkspacePersistence { public AddOnFrameworkWindow() { // set Caption property (not Title), since Title is managed internally to properly combine selected Tab Header and Caption for display in the windows taskbar // This is the name displayed in the top-left of the window Caption = "AddOn Framework"; // Set the initial dimensions of the window Width = 1085; Height = 900; // TabControl should be created for window content if tab features are wanted TabControl tc = new TabControl(); // Attached properties defined in TabControlManager class should be set to achieve tab moving, adding/removing tabs TabControlManager.SetIsMovable(tc, true); TabControlManager.SetCanAddTabs(tc, true); TabControlManager.SetCanRemoveTabs(tc, true); // if ability to add new tabs is desired, TabControl has to have attached property "Factory" set. TabControlManager.SetFactory(tc, new AddOnFrameworkWindowFactory()); Content = tc; /* In order to have link buttons functionality, tab control items must be derived from Tools.NTTabPage They can be added using extension method AddNTTabPage(NTTabPage page) */ tc.AddNTTabPage(new AddOnFrameworkTab()); // WorkspaceOptions property must be set Loaded += (o, e) => { if (WorkspaceOptions == null) WorkspaceOptions = new WorkspaceOptions("AddOnFramework-" + Guid.NewGuid().ToString("N"), this); }; } // IWorkspacePersistence member. Required for restoring window from workspace public void Restore(XDocument document, XElement element) { if (MainTabControl != null) MainTabControl.RestoreFromXElement(element); } // IWorkspacePersistence member. Required for saving window to workspace public void Save(XDocument document, XElement element) { if (MainTabControl != null) MainTabControl.SaveToXElement(element); } // IWorkspacePersistence member public WorkspaceOptions WorkspaceOptions { get; set; } } /* Class which implements Tools.INTTabFactory must be created and set as an attached property for TabControl in order to use tab page add/remove/move/duplicate functionality */ public class AddOnFrameworkWindowFactory : INTTabFactory { // INTTabFactory member. Required to create parent window public NTWindow CreateParentWindow() { return new AddOnFrameworkWindow(); } // INTTabFactory member. Required to create tabs public NTTabPage CreateTabPage(string typeName, bool isTrue) { return new NinjaTraderAddOnProject.AddOnPage(); } } /* This is where we define the actual content of the tabs for our AddOn window. Note: Class derived from Tools.NTTabPage has to be created if instrument link or interval link functionality is desired. Tools.IInstrumentProvider and/or Tools.IIntervalProvider interface(s) should be implemented. Also NTTabPage provides additional functionality for properly naming tab headers using properties and variables such as @FUNCTION, @INSTRUMENT, etc. */ public class AddOnFrameworkTab : NTTabPage, NinjaTrader.Gui.Tools.IInstrumentProvider, NinjaTrader.Gui.Tools.IIntervalProvider { public AddOnFrameworkTab() { Content = AddOnFrameworkWindowFactory.CreateTabPage("AddOnPage",true); } } }
Comment