Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kevinenergy, 02-17-2023, 12:42 PM
      117 responses
      2,764 views
      1 like
      Last Post jculp
      by jculp
       
      Started by Mongo, Today, 11:05 AM
      5 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by SightCareAubetter, Today, 12:55 PM
      0 responses
      3 views
      0 likes
      Last Post SightCareAubetter  
      Started by traderqz, Today, 12:06 AM
      8 responses
      16 views
      0 likes
      Last Post traderqz  
      Started by SightCareAubetter, Today, 12:50 PM
      0 responses
      1 view
      0 likes
      Last Post SightCareAubetter  
      Working...
      X