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

Correct Way to Close an NTTabPage

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

    Correct Way to Close an NTTabPage

    An AddOn creates several individual tabs in a window. At some point, tabs will be closed programatically by a Close button on the tab.

    Currently, I do this using ThisTabControl.Items.RemoveAt(ThisTabControl.Selec tedIndex) where ThisTabControl is the TabControl for the window. It certainly closes and removes the specific tab, but it does not appear to invoke Cleanup() for the tab. It seems one has to close the NTWindow for Cleanup of all individual tabs to be invoked.

    What is the appropriate way to programatically close an NTTabPage and ensure Cleanup is invoked at time of closure? Is it as simple as explicitly invoking Cleanup in the close method?

    Thanks.

    Aside: No matter how many times I edit the above, the Forum software adds a space in the middle of SelectedIndex. Hmmmm.
    Last edited by jeronymite; 08-17-2020, 04:44 AM.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Hello jeronymite,

    I am looking into this for you.

    I appreciate your patience.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Chelsea. Much appreciated.

      The other matter that requires consideration in these scenarios is Workspace persistence and how that is handled.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Our development has suggested to call the CleanUp() and then remove the tab from the TabControl.Items.

        Code:
        TabControl tc = this.Parent as TabControl;
        if (this.Content is NTTabPage tabPage)
        {
        if (!ConfirmClosing(true))
        return;
        
        Cleanup();
        }
        tc.Items.Remove(tab);
        Below is a link to an example of workspace persistance.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks, Chelsea. I appreciate your assistance with this.

          That is already the way I am achieving the goal, so I'm pleased it is affirmed by Development.

          As for Workspace persistence, creating appropriate Save/Restore methods is fine. It is the timing that I would like advice on when closing the tab before closing the window, in like manner as Cleanup -- does one somehow simply call the Save method before Cleanup, and if so, with what parameter? Seeking your further advice.

          Thanks.
          Multi-Dimensional Managed Trading
          jeronymite
          NinjaTrader Ecosystem Vendor - Mizpah Software

          Comment


            #6
            Hello jeronymite,

            I'm not clear I am understanding. You are trying to save a tab that you are closing in the workspace?

            I don't think that is going to work.. The workspace methods run when the workspace is saved, or the workspace is re-opened, but only for open windows and tabs. You shouldn't have to call Save or Restore yourself as NinjaTrader will be running these methods when the workspace is saved or opened.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks, Chelsea.

              What happens when one closes an AddOn window? Presumably, the relevant Save method is called and the currently open Workspace (not the on-disk copy) is updated? If the AddOn-related aspects of the Workspace are only updated when a save to the on-disk Workspace occurs, how is the Workspace-persistence of an AddOn effected after the AddOn window is closed? ... And my apologies too if I am misunderstanding how all this does/should work.

              Thanks.
              Multi-Dimensional Managed Trading
              jeronymite
              NinjaTrader Ecosystem Vendor - Mizpah Software

              Comment


                #8
                Hello jeronymite,

                When one closes an Addon window the window is closed.

                No, a workspace is not saved when you close a window. The workspace is saved when you save it. (A good way to restore an accidentally closed window that is saved in the workspace is to close the workspace without saving it and then re-open.)

                The workspace persistence is not affected after any window is closed. That windows is closed, no further code is running in it.

                Below is a link to the help guide on saving workspaces.


                And a link to the Workspaces 101 training video.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks, Chelsea. Very familiar with Workspaces in the general sense. It's the operation of the Save/Restore methods in AddOns that I want to be clear on.

                  It seems that Save and Restore are automatically invoked by Tab creation (Save) and Tab closure (Restore). So, Save, in particular, should not need to be explicitly invoked at any point. The mere fact of closing a Tab, even while the window remains open, will cause the relevant Workspace persistence, via Save, to be done automatically. Is that correct?

                  Thanks.
                  Multi-Dimensional Managed Trading
                  jeronymite
                  NinjaTrader Ecosystem Vendor - Mizpah Software

                  Comment


                    #10
                    Hello jeronymite,

                    Yes on tab restore. No workspace methods trigger until save/restore. Not on tab creation that I know of.

                    And no, these do not need to be invoked by yourself.

                    I'm actually surprised there isn't a close method. NT7 didn't have a supported addon system like this. I think under original development of NT8 they were writing pretty quick and weren't fully flushing out a few things for client development control as this was the first foray.

                    I've put in a personal feature request on this, because it makes sense to.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks, Chelsea. I agree and appreciate you initiating this. Thanks!

                      As a software engineer myself, I know that development runs a fine line between "Wouldn't that be great to have!" and "Why isn't this released yet?". So, fully understand the nature of the matter.

                      I suspect the NinjaTrader-internal Features Requests list bears testament to that particular effect.

                      Thanks again for all your kind assistance.
                      Multi-Dimensional Managed Trading
                      jeronymite
                      NinjaTrader Ecosystem Vendor - Mizpah Software

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by FrancisMorro, Today, 03:24 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post FrancisMorro  
                      Started by Segwin, 05-07-2018, 02:15 PM
                      10 responses
                      1,769 views
                      0 likes
                      Last Post Leafcutter  
                      Started by Rapine Heihei, 04-23-2024, 07:51 PM
                      2 responses
                      30 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Started by Shansen, 08-30-2019, 10:18 PM
                      24 responses
                      943 views
                      0 likes
                      Last Post spwizard  
                      Started by Max238, Today, 01:28 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post Max238
                      by Max238
                       
                      Working...
                      X