Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender drawline

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

    OnRender drawline

    Can someone help me on converting this to NT8?

    Point[][] linePoints = new Point[flines][];

    for (i = 0; i <flines; i++)
    graphics.DrawLines(linePrices[i].Pen, linePoints[i]);

    It would result a continuous line.

    #2
    Hello luxurious_04,

    Thank you for the post.

    You will need to use SharpDX in NinjaTrader 8. For an example on how to render lines in OnRender, have a look at the "SampleCustomRender" indicator. That script demonstrates how to use SharpDX in the context of a NinjaScript, notice how the line is drawn with RenderTarget.DrawLine(...).

    Here is the help guide page on using SharpDX for custom plotting:


    Please let me know if I can assist further.

    Comment


      #3
      Ok I have check that already my problem how can I convert Points[][] linePoints or what is the equivalent of linePoints[i] in OnRender.Drawline? In OnRender.Drawline it needs to vector points while in graphics.Drawlines in NT7 it only use points of array like linePoints[i].

      Comment


        #4
        Hello luxurious_04,

        Thank you for the reply.

        The DrawLines method takes two Points. This is the equivalent of the Point array to draw.

        Below is a public link to three examples of how to use DrawLine



        Please let me know if I can assist further.

        Comment


          #5
          Code:
          internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
          {
          var rect = line.GetBoundingRect(rootElement).ToSharpDX();
          //var fill = line.Fill.ToSharpDX(renderTarget, rect);
          var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);
          
          if (stroke == null ||
          line.StrokeThickness <= 0)
          {
          return;
          }
          
          //var layer = new Layer(renderTarget);
          //var layerParameters = new LayerParameters();
          //layerParameters.ContentBounds = rect;
          //renderTarget.PushLayer(ref layerParameters, layer);
          
          renderTarget.DrawLine(
          new DrawingPointF(
          rect.Left + (float)line.X1,
          rect.Top + (float)line.Y1),
          new DrawingPointF(
          rect.Left + (float)line.X2,
          rect.Top + (float)line.Y2),
          stroke,
          (float)line.StrokeThickness,
          line.GetStrokeStyle(compositionEngine.D2DFactory));
          
          //renderTarget.PopLayer();
          }​
          Code:
          internal static async Task Render(CompositionEngine compositionEngine, SharpDX.Direct2D1.RenderTarget renderTarget, FrameworkElement rootElement, Line line)
          {
          var rect = line.GetBoundingRect(rootElement).ToSharpDX();
          var stroke = await line.Stroke.ToSharpDX(renderTarget, rect);
          
          if (stroke == null ||
          line.StrokeThickness <= 0)
          {
          return;
          }
          
          var layer = line.CreateAndPushLayerIfNecessary(renderTarget, rootElement);
          
          renderTarget.DrawLine(
          new Vector2(
          rect.Left + (float)line.X1,
          rect.Top + (float)line.Y1),
          new Vector2(
          rect.Left + (float)line.X2,
          rect.Top + (float)line.Y2),
          stroke,
          (float)line.StrokeThickness,
          line.GetStrokeStyle(compositionEngine.D2DFactory));
          
          if (layer != null)
          {
          renderTarget.PopLayer();
          layer.Dispose();
          }
          }​
          Code:
          public void Draw(SharpDX.Direct2D1.RenderTarget d2dRenderTarget)
          {
          //if (DrawnParticles == null)
          // return;
          GameForm.solidColorBrush.Color = Colors.AliceBlue;
          for (int i = 0; i < Particles.Count; i++)
          {
          Particles[i].Draw(d2dRenderTarget);
          }
          var x = Lines.ToArray();
          GameForm.solidColorBrush.Color = Colors.Yellow;
          for (int i = 0; i < x.Count() - 1; i++)
          d2dRenderTarget.DrawLine(x[i], x[i + 1], GameForm.solidColorBrush);
          }​

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          597 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          555 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X