Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buttons-StackPanels-DockPanels

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

    #31
    Originally posted by -=Edge=- View Post
    I believe Matthew updated the file in his original post #21.. Just re-download it..
    It would seem there is still a small nuance in displaying a button in NT's toolbar, "Only on the Chart/Tab the indicator is Applied To". Using the MainTabControl works great in most every situation except one.. I'm not sure how I missed this in B3, but this is not unique to B4..

    Using the exact indicator Matthew provided in post #21

    Open a new workspace..
    Create a new Chart..
    Add or Duplicate another tab/chart

    You should now have a single window with 2 charts/tabs (it doesn't matter what instrument or dataseries are applied to the charts)

    Add the indicator to your 2nd tabbed chart.. (The button appears, click events work, and all is well!)

    Now click on the first tabbed chart.. (the button is collapsed thru the use of the MainTabControl.SelectionChanged event as expected and all is still well).. So far, Clicking back and forth between the two chart/tabs works great!

    Now here is the problem..

    Click on the first tabbed chart..
    Close NT8 and save the workspace..
    Now Re-Open NT8..

    You'll now notice that the button appears on the 1st tabbed chart, even though it is only applied to the 2nd.. It will actually be displayed on every chart if you had more..

    Once you click on the second tab and back to first again, it is gone, and everythings ok again, but the selectionchanged event doesn't catch this the first time the workspace is opened..


    Any idea's on how we can get around this issue?


    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #32
      Hello -=Edge=-,

      The button just needs to start with the visibility as collapsed if the indicator is not added to the active tab.

      Basically change line 74 so that the button starts as collapsed, then after this line set it to visible if the active tab contains the indicator.

      Code:
      exampleButton = new Button { Content = "Example Button", Visibility = Visibility.Collapsed };
      
      foreach (TabItem tab in chartWindow.MainTabControl.Items)
      	if ((tab.Content as ChartTab).ChartControl == ChartControl && tab == chartWindow.MainTabControl.SelectedItem)
      		exampleButton.Visibility = Visibility.Visible;

      (I tried to do this with linq but for some reason can't get a where or a find on this object.. but this does just fine.)
      Last edited by NinjaTrader_ChelseaB; 09-16-2015, 02:56 PM.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #33
        Originally posted by NinjaTrader_ChelseaB View Post
        Basically change line 74 so that the button starts as collapsed, then after this line set it to visible if the active tab contains the indicator.
        Works like a champ! Thank You Very Much!


        -=Edge=-
        NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

        Comment


          #34
          The link to the most recent example file in post 21 seems to be broken, I don't get anything using Chrome and only a .php file using IE.

          Comment


            #35
            Originally posted by palinuro View Post
            The link to the most recent example file in post 21 seems to be broken, I don't get anything using Chrome and only a .php file using IE.
            Yes, tends to work that way with IE.. In IE save the file as SampleAddChartButton.cs instead of the attached.php that is gives by default.. That should work just fine..


            Here are some screen shots of a few things I've accomplished so far..



            Can You Tell I Like Buttons!!!

            Rather than cluttering up the indicator properties window and the cumbersome way of changing and/or selecting all those settings, for things like my drawbar and color palette, I'm using context menus along with my own personal property window that can all be accessed with a simple click of the indicators button icon..



            Almost ready to release a few products, just need to finalize my personal server authentication check, finish up a few more code tweaks, and should be ready to go!

            Thanks Again NinjaTrader for yet another Great Product Upgrade!


            Attached Files
            -=Edge=-
            NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

            Comment


              #36
              Got it working - it's tab-specific, but won't display on a second tab even when I add it to the second chart.

              I've also incorporated the button code from post 21 into an indicator, and can see the indicator on the second chart but not the button.

              Any suggestions?

              Comment


                #37
                Originally posted by palinuro View Post
                Got it working - it's tab-specific, but won't display on a second tab even when I add it to the second chart. Any suggestions?
                Yes, in that particular example, the isToolBarButtonAdded bool is being set prematurely to true, because it found the automation property from the first time the indicator was added.. Which ends up causing the button code below it to never run..

                The setting and checking of those Automation Properties aren't really necessary unless you have a special case where you need to access them outside the indicator code..

                I've attached a much better example of adding a ToolBar Button..

                I've also tried to include enough comments to make everything fairly understandable..


                Attached Files
                -=Edge=-
                NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                Comment


                  #38
                  How did you set the width of the individual buttons for your docked panel?

                  Comment


                    #39
                    Originally posted by -=Edge=- View Post
                    Yes, in that particular example, the isToolBarButtonAdded bool is being set prematurely to true, because it found the automation property from the first time the indicator was added.. Which ends up causing the button code below it to never run..

                    The setting and checking of those Automation Properties aren't really necessary unless you have a special case where you need to access them outside the indicator code..

                    I've attached a much better example of adding a ToolBar Button..

                    I've also tried to include enough comments to make everything fairly understandable..


                    Thanks very much, all's working now - you've probably saved me days of poking around trying to figure it out...

                    Comment


                      #40
                      Originally posted by jhowinvest View Post
                      How did you set the width of the individual buttons for your docked panel?
                      btn.Width = (int);
                      btn.Height = (int);


                      -=Edge=-
                      NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                      Comment


                        #41
                        Originally posted by palinuro View Post
                        Thanks very much, all's working now - you've probably saved me days of poking around trying to figure it out...

                        Your Welcome! and thanks for the note of appreciation!


                        -=Edge=-
                        NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                        Comment


                          #42
                          Originally posted by -=Edge=- View Post
                          Yes, in that particular example, the isToolBarButtonAdded bool is being set prematurely to true, because it found the automation property from the first time the indicator was added.. Which ends up causing the button code below it to never run..

                          The setting and checking of those Automation Properties aren't really necessary unless you have a special case where you need to access them outside the indicator code..

                          I've attached a much better example of adding a ToolBar Button..

                          I've also tried to include enough comments to make everything fairly understandable..


                          Thank you for the great work

                          Is there a way to change the font and the background color on these buttons????

                          Thank you in advance

                          Comment


                            #43
                            [QUOTE=-=Edge=-;429228]btn.Width = (int);
                            btn.Height = (int);


                            Thanks Edge. I have been able to use that property to make the buttons wider but not make them more narrow. There seems to be a default set somehow that will not allow the buttons to be more narrow. Maybe in the dockpanel? I have worked with the horizontalalignment and horizontalcontentalignment and see the difference there but making the buttons really narrow/skinny is evading me. Any ideas? Thanks again for all of your work on this topic.

                            Comment


                              #44
                              Font I'm not sure on but you should be able to use

                              btn1.Background = Brushes.White; for white background
                              btn1.Background = Brushes.Blue; for blue background etc.

                              Comment


                                #45
                                btn.FontFamily and btn.FontSize

                                FYI, You may or may not need to set the Style to null for button so you can override the style's fonts and colors. NT isn't in front of me currently to test this out

                                Ref: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by bortz, 11-06-2023, 08:04 AM
                                47 responses
                                1,606 views
                                0 likes
                                Last Post aligator  
                                Started by jaybedreamin, Today, 05:56 PM
                                0 responses
                                8 views
                                0 likes
                                Last Post jaybedreamin  
                                Started by DJ888, 04-16-2024, 06:09 PM
                                6 responses
                                18 views
                                0 likes
                                Last Post DJ888
                                by DJ888
                                 
                                Started by Jon17, Today, 04:33 PM
                                0 responses
                                4 views
                                0 likes
                                Last Post Jon17
                                by Jon17
                                 
                                Started by Javierw.ok, Today, 04:12 PM
                                0 responses
                                13 views
                                0 likes
                                Last Post Javierw.ok  
                                Working...
                                X