Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Getting compile button of NinjaScript Editor in Addon

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting compile button of NinjaScript Editor in Addon

    Hello,
    I'm trying to close all my addon windows after clicking on compile button from ninja script editor. I used the following code to get the button from the code but it's not working:

    Code:
    NinjaTrader.Gui.NinjaScript.Editor.EditorView ev = window as NinjaTrader.Gui.NinjaScript.Editor.EditorView;
    if (ev!=null)
    {
    Button compile =ev.FindFirst("Compile") as Button;
    
    }
    Actually i get the following error:

    System.InvalidOperationException: ''NinjaTrader.Gui.NinjaScript.Editor.ScriptItem' is not a Visual or Visual3D.'

    Could you please help?
    Best regards,
    Last edited by zakoun; 02-10-2021, 06:12 PM.

    #2
    Hello zakoun,

    You could write an addon for that purpose or also just put some logic in your existing addon to close its self when terminated.

    When you compile an addon it is terminated and will run its State.Active again, thats why you will see the menu item flash if you look in the control center. You could at that point loop through the open windows and close any existing windows of your type.

    You can loop through the NinjaTrader.Core.Globals.AllWindows collection of windows to find any of your windows.

    If you were doing this from the addon its self that code would go in the base addon class in its State.Terminated, from our sample thats the: public class AddOnFramework : AddOnBase.


    The code could look like the following:

    Code:
    if (State == State.Terminated)
    {
           foreach(NTWindow window in NinjaTrader.Core.Globals.AllWindows)
          {
             window.Dispatcher.InvokeAsync(() =>{
             if(window is AddOnFrameworkWindow)
             {
                window.Close();
             }
          });
       }
    }

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,279 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Working...
    X