• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Does NT8 SimpleFont support underline or strikethrough?

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

    Does NT8 SimpleFont support underline or strikethrough?

    Hi there,

    In NT8's help guide reference for SimpleFont, it references bold, italics, etc. But not underline or strikethrough. I'm looking at this page:

    https://ninjatrader.com/support/help...font_class.htm

    How would I designate a SimpleFont with an underline?
    Thanks in advance!

    #2
    Hello Spiderbird,

    I'm not aware that SimpleFont has these properties.

    I am happy to submit a feature request on your behalf for the NinjaTrader Development to consider this for a future version of NinjaTrader if you would like.

    In the meantime, you could achieve this with custom rendering.

    Below is a public link to an example of custom rendering text.
    https://ninjatrader.com/support/foru...609#post541609
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Thanks for the quick response! I believe there's an existing request from the Beta stage for underline text support for SimpleFont, so no need to send it through as a feature request again.

      For the example you posted, I'm looking at the following code:
      // create a new TextFormat object using information from the chart labels
      SharpDX.DirectWrite.TextFormat textFormat = new SharpDX.DirectWrite.TextFormat(Core.Globals.Direct WriteFactory, chartTextFormat.FontFamilyName, chartTextFormat.FontWeight, chartTextFormat.FontStyle, fontSize);

      // calculate the which will be rendered at each plot using it the plot name and its price
      string textToRender = "Some text to render";

      // calculate the layout of the text to be drawn
      SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(Core.Globals.Direct WriteFactory,
      textToRender, textFormat, 300, textFormat.FontSize);
      Is this what I should be considering when attempting to underline chart text?

      Comment


        #4
        Hello Spiderbird,

        Use the .SetUnderline from a TextLayout object and use a TextRange object created with the TextLayout.Metrics.Width.

        Below is a public link to a 3rd party website that has an example.
        https://csharp.hotexamples.com/examp...-examples.html

        As well as public links to the documentation. (Unfortunately the SharpDX wiki is not well maintained and looks pretty bad)
        http://sharpdx.org/wiki/class-library-api/directwrite/
        https://msdn.microsoft.com/en-us/lib.../dd371518.aspx

        Code:
        SharpDX.DirectWrite.TextFormat textFormat = font.ToDirectWriteTextFormat();
        SharpDX.DirectWrite.TextLayout textLayout =
        new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Globals.DirectWriteFactory,
        text, textFormat, chartPanel.X + chartPanel.W,
        textFormat.FontSize);
        SharpDX.Vector2 TextPlotPoint = new System.Windows.Point(pointX, pointY-textLayout.Metrics.Height/2).ToVector2();
        
        float newW = textLayout.Metrics.Width; 
                float newH = textLayout.Metrics.Height;
                SharpDX.RectangleF PLBoundRect = new SharpDX.RectangleF((float)pointX+2, (float)pointY-textLayout.Metrics.Height/2, newW+5, newH+2);
                renderTarget.FillRectangle(PLBoundRect, areaBrush);
        
        SharpDX.DirectWrite.TextRange textRange = new SharpDX.DirectWrite.TextRange(0, (int)textLayout.Metrics.Width);
        
        textLayout.SetUnderline(true, textRange);
        
        renderTarget.DrawTextLayout(TextPlotPoint, textLayout, brush, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
        textLayout.Dispose();
        textFormat.Dispose();
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Wonderful! Thanks for your help Chelsea. I’ll give that a shot.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by pjsmith, Today, 02:20 AM
          0 responses
          2 views
          0 likes
          Last Post pjsmith
          by pjsmith
           
          Started by faisamtrader, Yesterday, 10:03 PM
          0 responses
          3 views
          0 likes
          Last Post faisamtrader  
          Started by johnnybegoode, Yesterday, 08:11 PM
          0 responses
          2 views
          0 likes
          Last Post johnnybegoode  
          Started by Bionian, Yesterday, 02:47 PM
          2 responses
          21 views
          0 likes
          Last Post Bionian
          by Bionian
           
          Started by RickB60, Yesterday, 01:55 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Working...
          X