// Will be called as a new NTWindow is created. It will be called in the thread of that window 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; }
// Will be called as a new NTWindow is created. It will be called in the thread of that window protected override void OnWindowCreated(Window window) { /* * The following checks if the control center window is present. * If the control center is found, the MainMenu is checked for existing menu items with the same name as this addon. * If no existing items are found, a new menu item is added for this addon. */ // We want to place our AddOn in the Control Center's menus ControlCenter controlCenter = window as ControlCenter; if (controlCenter == 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 = controlCenter.FindFirst("ControlCenterMenuItemNew") as NTMenuItem; if (existingMenuItemInControlCenter == null) { return; } // This is the new menu item to be created, this assigns the menu text and will be used to Add this item to the Main Menu. // 'Header' sets the name of our AddOn seen in the menu structure AddonShellMenuItem = new NTMenuItem { Header = "Addon Shell", Style = Application.Current.TryFindResource("MainMenuItem") as Style }; // Add our AddOn into the "New" menu existingMenuItemInControlCenter.Items.Add(AddonShellMenuItem); // The new menu item will do nothing by its self, a click handler is added to complete the menu item and allow for clicks. // Subscribe to the event for when the user presses our AddOn's menu item AddonShellMenuItem.Click += OnMenuItemClick; }