Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buttons-StackPanels-DockPanels

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

    Buttons-StackPanels-DockPanels

    I'm starting this thread to possibly get some collaboration started with the utilization of Buttons/StackPanels/DockPanels.. I'm sure that most if not all the developers are interested in this endeavor. Ultimately I believe the biggest interest will be in adding a button to an indicator and placing this in NT's existing toolbar. But as I'm still not quite sure how this is going to work with the ability to have multiple charts utilizing the same window, and possibly not even having that same indicator on every chart, I thought that I might start off and try to duplicate a manual order entry bar that I currently use in NT7 with several of my indicators.. With each button I create and submit a manual OIF entry order that has a specific ATM strategy template attached to it. An example of this can be seen in the attached pic below..

    With NT7 I accomplished this by adding multiple buttons to a ToolStrip and add that toolstrip to the chartcontrol controls, docking it at the bottom... Now with NT8 and WPF, this will be handled with Dock and Stack Panels and I believe usercontrols vs controls.. Idealistically I'd ultimately like to utilize my existing WinForms code for the toolstip and add that thru the use of Windows.Forms.Integration and WindowsFormHost (I've successfully accomplished this in a WPF project in VS, a discussion here for later), but for now I'm playing with the idea of just adding buttons to a dockpanel and placing that dockpanel at the bottom of the chartpanel independently in whatever window the indicator is added..

    So far I've tried going two routes, each with its own success, yet each ultimately failing in a different way.. The first approach is creating a couple buttons, adding each button to its own stackpanel (doing this mainly because it was the only way so far I found that I could successfully change the size of the buttons being displayed), then adding each stackpanel to the dockpanel, then adding the dockpanel to a usercontrol, then adding that usercontrol as a child of the chartcontrol.. This seems to work, in that it adds the buttons and the routed event of each button work(open an output window and the button name will be printed on each click), But the dockpanel seems to be being added as a completely separate object/control, offsetting the bars and chartpanel on both the left and right side the width of the dockpanel itself..

    The second approach I took was pretty much the same in every aspect, except instead of adding the usercontrol as a child to the chartcontrol, adding the usercontrol as content to the chartpanel.. Now aesthetically this works perfectly.. But now the problem comes that none of the buttons are clickable and am unable to accomplish any routable events..

    I've provided a code sample below. It could definitely be done more efficiently, and contains no comments, but I've tried to keep the flow in a way I believe it should be easily understood. The Dispatcher is used for threading issues. The indicator contains only one bool property.. setting it to true will add the usercontrol as a child to the chartcontrol, and setting it to false will add the usercontrol to the content of the chartpanel.. By changing this in the properties from true to false and so forth, you should very easily be able to see and understand what I've tried to explain above..

    Now I could be totally off base here with my approach, but would be very interested in hearing if anyone has been successful with this endeavor, has possibly taken a different approach, or has any suggestions, hints, ideas on what I'm doing wrong (not doing) and/or the proper way of accomplishing this..


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

    #2
    That's good work there!

    This should get easier once we get an Automation ID for the toolbar in the next release.

    Otherwise great job working that out

    Comment


      #3
      Originally posted by Calonious View Post
      That's good work there!

      This should get easier once we get an Automation ID for the toolbar in the next release.

      Otherwise great job working that out
      Thanks.. Just wish it worked.. .. As for this particular project, just want the buttons on the chart..

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

      Comment


        #4
        I researched a bit and your approach of adding buttons directly to the chart control will not work in current form since as you might have noticed each time the panel configuration changes in the chart all children are removed. NT re-adds its own stuff but your custom buttons wont get re-added.

        Which means the buttons needed to be added to the caption bar (Using the automation ID or other method) or we needed to implement a feature to allow you to add buttons to the chart.

        My first approach is the toolbar and if that does not satisfy the use case we could expand further based on demand.

        Beta 2 I expect to release sometime mid next week. Thanks for your patience.
        BrettNinjaTrader Product Management

        Comment


          #5
          OK.. so now that we know that the toolbar's automation id is "ChartWindowToolBar", ChartTraders aid is "ChartWindowChartTrader", both being a child of the ChartWindow aid "ChartWindow", which seems to be a child of a Winform window without an aid..

          Has anyone been successful and/or know how to use this information to add a button to either/both? (toolbar/charttrader)


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

          Comment


            #6
            Hello,
            Any clue on how to implement a single buton in the Toolbar ?

            -----------------------------------------------
            Christophe - Ninja-Addons.com
            CEO Azur Investment Technologies "AzurITEC" sas
            http://www.ninja-addons.com
            3rd Party Add-On Vendor

            Comment


              #7
              Quick update, we looked into getting the button added which is possible. However it turns out the button is on the caption bar instead of the tab. As such the button is not tab sensitive which means code needed to be added to make it tab sensitive, we have added code in beta 3 to make it possible to make the button tab sensitive like our existing buttons. However I'm doing a final review and will post back shortly as the solution is not 100% yet.
              BrettNinjaTrader Product Management

              Comment


                #8
                Maybe removing the button from the visible toolbar if a chart tab/chart is in focus that does not have the indicator applied would be a good option. If the button is visible for all tabs but does not function for all, what then?

                Dan
                eDanny
                NinjaTrader Ecosystem Vendor - Integrity Traders

                Comment


                  #9
                  That is exactly what I had done but requires beta 3 since the needed items to listen to the active tab was not public so you guys can't access it right now. I provided a version of the code to the OP and he is going to update with what he has so far so you guys could get started with whats there. I'll be providing more info at a later date.
                  BrettNinjaTrader Product Management

                  Comment


                    #10
                    Super job Brett, that would be course I would have taken too, remove the nonworking buttons.

                    Dan
                    eDanny
                    NinjaTrader Ecosystem Vendor - Integrity Traders

                    Comment


                      #11
                      Here is some sample code that will add a Button to the Toolbar.. But as Brett has just mentioned, there is a small problem with the current implementation, in that yes, it does add the button, but the button is not tab specific.. Meaning if you have a chart, with multiple tabs, and add this indicator to just one of the tabs, the button will remain displayed in the toolbar on each and every tab.. Please be aware of this limitation!!!

                      Although this is not necessarily ideal for most situations, I have found some useful scenarios for this.. One example might be adding a button for screen capturing.. Even though the indicator(button) is only applied to one specific tab, the button will remain displayed on all tabs, and the code behind the button click still executes and seems to work just fine on any tab.. (this might not always be the case!)

                      This being just one example of how only having to apply the button to just one tab might be useful and time saving.. I'd be interested in hearing other idea's as well! Keep in mind there will be many limitations to this current implementation... Such as, be aware when duplicating tabs where this indicator is applied.. As it will add yet another button to the toolbar that will also be displayed on every tab..


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

                      Comment


                        #12
                        After reading another thread and playing a bit more, apparently there was a much easier way to get the ChartWindow.. I left the original code as it might help get you thinking about other things.. But this also seems to work and is a bit more efficient, although same limitations apply..

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

                        Comment


                          #13
                          Thanks a lot for sharing this code -=Edge=- (these codes actually).
                          Obviously my knowledge of WPF needs to be improved. I was not far but one line was missing in my code :
                          SearchObject = ChartControl as DependencyObject;

                          Originally posted by -=Edge=- View Post
                          After reading another thread and playing a bit more, apparently there was a much easier way to get the ChartWindow.. I left the original code as it might help get you thinking about other things.. But this also seems to work and is a bit more efficient, although same limitations apply..
                          Thanks again.

                          -----------------------------------------------
                          Christophe - Ninja-Addons.com
                          CEO Azur Investment Technologies "AzurITEC" sas
                          http://www.ninja-addons.com
                          3rd Party Add-On Vendor

                          Comment


                            #14
                            Stay In Draw Mode

                            Stay In Draw Mode is missing an Automation ID..


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

                            Comment


                              #15
                              Originally posted by -=Edge=- View Post
                              Stay In Draw Mode is missing an Automation ID..


                              Will be added in B3
                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ketostrongdiet, Today, 12:34 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post ketostrongdiet  
                              Started by ketostrongdiet, Today, 12:33 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post ketostrongdiet  
                              Started by mattdowns1234, Yesterday, 06:57 PM
                              0 responses
                              16 views
                              0 likes
                              Last Post mattdowns1234  
                              Started by dgee949, Yesterday, 06:26 PM
                              0 responses
                              26 views
                              0 likes
                              Last Post dgee949
                              by dgee949
                               
                              Started by dgee949, Yesterday, 05:58 PM
                              0 responses
                              32 views
                              0 likes
                              Last Post dgee949
                              by dgee949
                               
                              Working...
                              X