Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting Draw Object's Default Template Properties

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

    Getting Draw Object's Default Template Properties

    Hello,

    Is there a better way to retrieve default template properties? My current method is to create a draw object and assign it to the 'Default' template. From there, grab the information from the object's properties and then remove the object. It works but is it possible to avoid the creation of an object?

    Code:
    private NinjaTrader.Gui.Tools.SimpleFont defaultTextTemplateFont;
    private Brush defaultTextTemplateTextBrush;
    private TextAlignment defaultTextTemplateTextAlignment;
    private Brush defaultTextTemplateOutlineBrush;
    private Brush defaultTextTemplateAreaBrush;
    private int deafultTextTemplateAreaOpacity;
    
    ...
    
    Text defaultTemplateText = Draw.Text(this, "defaultText", "defaultText", 0, Close[0], true, "Default");
    
    defaultTextTemplateFont = new NinjaTrader.Gui.Tools.SimpleFont(defaultTemplateTe xt.Font.Family.ToString(), defaultTemplateText.Font.Size)
    {
      Bold = defaultTemplateText.Font.Bold,
      Italic = defaultTemplateText.Font.Italic
    };
    
    defaultTextTemplateTextBrush = defaultTemplateText.TextBrush;
    defaultTextTemplateTextAlignment = defaultTemplateText.Alignment;
    defaultTextTemplateOutlineBrush = defaultTemplateText.OutlineStroke.Brush;
    defaultTextTemplateAreaBrush = defaultTemplateText.AreaBrush;
    deafultTextTemplateAreaOpacity = defaultTemplateText.AreaOpacity;
    
    RemoveDrawObject("@defaultText");
    Thanks
    unsuitable
    NinjaTrader Ecosystem Vendor - Unsuitable

    #2
    Hello Unsuitable,

    The supported way would just be to drawn an object using an xml template, and then see what properties the template applied to the object.

    The unsupported way would be to read the xml file using unsupported C# code from the Documents\NinjaTrader 8\templates\Drawing folder.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      That's what I figured. No xml file reading for me!. Anyways I implemented a feature where the user can submit a custom template via a string name. I made sure to implement a Try and Catch in case it's empty or no template with that name is found. However, it seems that NT handles that.

      "The name of the drawing tool template the object will use to determine various visual properties (empty string could be used to just use the UI default visuals instead)"
      https://ninjatrader.com/de/support/h...?draw_text.htm

      So no need for a Try and Catch then?

      Thanks
      unsuitable
      NinjaTrader Ecosystem Vendor - Unsuitable

      Comment


        #4
        Hello Unsuitable,

        A try and catch would not be necessary.

        A string is a non nullable type, if a string variable is not set it will have a value of string.Empty.

        If the object type was a nullable type, then you should check the variable holding the object is not null before using it.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi ChelseaB,

          Originally posted by NinjaTrader_ChelseaB View Post
          A string is a non nullable type, if a string variable is not set it will have a value of string.Empty.
          Makes sense. Do you know how NT handles templates that don't exist? Does it just set the template to "" and use UI default visuals?

          Thanks
          unsuitable
          NinjaTrader Ecosystem Vendor - Unsuitable

          Comment


            #6
            Hello Unsuitable,

            A drawing template that doesn't exist will not be loaded and the default values for the object will be used.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea_B,

              By default values do you mean the default template? If so what if that's deleted?
              unsuitable
              NinjaTrader Ecosystem Vendor - Unsuitable

              Comment


                #8
                Hello Unsuitable,

                I mean the default values as if there was no template applied.

                As if you did not have a template, and then manually drew an object.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea_B,

                  Wouldn't that use the "Default" template? What if the user deleted the Default template, will it use NT's default values?
                  unsuitable
                  NinjaTrader Ecosystem Vendor - Unsuitable

                  Comment


                    #10
                    Hello Unsuitable,

                    No, this would not instead load a template named Default. No, the default template loading would not be the same as no template loading. Please give it a try and let us know the results.

                    Yes, the drawing object will use the default properties, even if the user does not delete a template named Default.

                    The default text brush for text drawing objects when using the default Slate Gray skin is Brushes.White.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi ChelseaB,

                      I went ahead and deleted the template name "Default". When drawing a new text object, the backup default values set the text to Arial Black
                      unsuitable
                      NinjaTrader Ecosystem Vendor - Unsuitable

                      Comment


                        #12
                        Hello Unsuitable,

                        Are you using the default skin: Slate Gray? (If so, that would be unexpected for this skin. I've just tested on my end and the color was white. I've also checked the skin and the value is white in the skin file.)

                        *It's close to white. It's actually 'Slate Gray - Text Color' which is #CCCCCC instead of #FFFFFF.
                        Last edited by NinjaTrader_ChelseaB; 10-19-2020, 03:29 PM.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi ChelseaB,

                          NT uses the chart properties. In my case, I have one of the dark themes but my chart background is set to white and the chart text is set to black.
                          unsuitable
                          NinjaTrader Ecosystem Vendor - Unsuitable

                          Comment


                            #14
                            Hello Unsuitable,

                            That is correct. Manually changing color values will override the values from the skin.

                            By you setting the color, that will be the default color for text drawing objects on that chart. If you do not override the colors and use the default values, these will come from the skin.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by ntbone, Yesterday, 10:31 PM
                            2 responses
                            14 views
                            0 likes
                            Last Post ntbone
                            by ntbone
                             
                            Started by 7robert, Yesterday, 11:38 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_ChrisSch  
                            Started by dpolyakov, Yesterday, 09:58 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Jason  
                            Started by Rainmakersg, Today, 12:34 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post Rainmakersg  
                            Started by Bidder, Yesterday, 09:07 PM
                            1 response
                            12 views
                            0 likes
                            Last Post NinjaTrader_Jason  
                            Working...
                            X