Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender DashStyle

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

    OnRender DashStyle

    Is this a correct way to change DashStyle in OnRender?


    Code:
    private Stroke myStroke;
    
    if (State == State.SetDefaults)
    {
         myStroke = new Stroke(Brushes.Blue, my_DashStyleHelper, 1);
    }
    
    
    
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
       Dash_Stroke.RenderTarget = RenderTarget;
       RenderTarget.DrawLine(startPoint , endPoint, my_BrushDx, 5, myStroke.StrokeStyle);​
    }
    
    
    public override void OnRenderTargetChanged()
    {
       if (my_BrushDx!= null) { my_BrushDx.Dispose(); }
    
       if (RenderTarget != null)
       {
          try
          {
             my_BrushDx = my_Brush.ToDxBrush(RenderTarget);
          }
          catch (Exception e ) { }
    }
    
    
    
    
    [Display(Name = "my_DashStyleHelper")]
    public DashStyleHelper my_DashStyleHelper { get; set; }
    Last edited by Marty125; 01-06-2025, 11:30 AM.

    #2
    Hello Marty125,

    That could looks like it would work fine, as it's using the <Stroke>.StrokeStyle as the StrokeStyle parameter.
    Are you finding this is not working as expected?

    You could specify a new SharpDX.Direct2D1.StrokeStyle object.


    RenderTarget.DrawLine(Vector2 point0, Vector2 point1, Brush brush, float strokeWidth, StrokeStyle strokeStyle)
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      It works fine, I´m just making sure I´m not doing something in a bad way, because this is kinda sketchy for me - RenderTarget parametres are SharpDX type and Stroke the way I make it is NinjaTrader.Gui.Stroke type. Ok, thanks for clarifying.

      Comment


        #4
        I am rendering multiple rectangles with RenderTarget.DrawRectangle() and I am experiencing worse performance when using StrokeStyle set to Dash, is it normal? That a few rectangle outlines with dash StrokeStyle are making BIG impact on performance? Or should I try to use SharpDX.Direct2D1.StrokeStyle instead? Thanks

        Comment


          #5
          Hello Marty125,

          Unfortunately, I wouldn't be an expert in how much time DirectX renders a dashed line on graphic hardware.

          Are you finding this is slower than when using an instantiated SharpDX.Direct2D1.StrokeStyle saved to a variable?

          I would imagine that a dashed line would require more calculations than a solid line.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X