Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Properties for OnRender custom object

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

    Properties for OnRender custom object

    HI,

    Anyone Knows if with a custom OnRender object, like a rectangle, is possible to add properties like the type of borderline (dash, dotted...), the size of borderline also, etc...?

    Thank you in advance
    DAYTRADERPROFESIONAL
    NinjaTrader Ecosystem Vendor - DAYTRADERPROFESIONAL

    #2
    try https://ninjatrader.com/support/foru...-onrender-help

    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    // implicitly recreate and dispose of brush on each render pass
    using (SharpDX.Direct2D1.SolidColorBrush dxBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, SharpDX.Color.Blue))
    {
    RenderTarget.FillRectangle(new SharpDX.RectangleF(ChartPanel.X, ChartPanel.Y, ChartPanel.W, ChartPanel.H), dxBrush);
    }
    }
    Last edited by Emma1; 08-11-2019, 08:20 AM. Reason: update

    Comment


      #3
      Hello DAYTRADERPROFESIONAL,

      Thanks for posting.

      Emma1's linked post and information provided will be very beneficial.

      I may recommend checking the available overloads for your drawing routines, and then checking the available parameters and then how those objects are built and what properties exist within those objects. For example, you could observe how a StrokeStyle is created which would then describe a dotted line.

      Code:
      public void DrawRectangle(SharpDX.Direct2D1.RenderTarget renderTarget, SharpDX.RectangleF rect, SharpDX.Direct2D1.Brush brush, float strokeWidth, DashStyleHelper dashStyle)
      {
          // Create StrokeStyleProperties
          SharpDX.Direct2D1.StrokeStyleProperties ssProps = new SharpDX.Direct2D1.StrokeStyleProperties();
      
          switch (dashStyle)
          {
              case DashStyleHelper.Dash:             ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dash;         break;
              case DashStyleHelper.DashDot:         ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDot;     break;
              case DashStyleHelper.DashDotDot:    ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.DashDotDot;    break;
              case DashStyleHelper.Dot:            ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Dot;        break;
              case DashStyleHelper.Solid:            ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid;        break;
              default:                             ssProps.DashStyle = SharpDX.Direct2D1.DashStyle.Solid;        break;
          }
      
          // Create StrokeStyle from StrokeStyleProperties
          SharpDX.Direct2D1.StrokeStyle strokeStyle = new SharpDX.Direct2D1.StrokeStyle(Core.Globals.D2DFactory, ssProps);
          renderTarget.DrawRectangle(rect, brush, strokeWidth, strokeStyle);
      }
      If you would like to draw a filled rectangle with a border, this would involve a FillRectangle call and a DrawRectangle call.

      Please let us know if we can be of further assistance.
      Last edited by NinjaTrader_Jim; 08-12-2019, 08:30 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      566 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 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
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X