Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stroke BrushDX null?

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

    Stroke BrushDX null?

    I have a stroke property defined as:

    Code:
    [Description("Some stroke stuff")]
    public Stroke SomeStroke { get; set; }
    I set a default value:

    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
           SomeStroke =  new Stroke(Brushes.Red);
    Later on in a method called from OnRender() I make the following call:

    Code:
    RenderTarget.DrawLine(
    pointA,
    pointB,
    stroke.BrushDX,
    stroke.Width,
    stroke.StrokeStyle);
    This causes NinjaTrader to crash. Re-trying and debugging I can see that SomeStroke is a valid object after instantiation BUT SomeStroke.BrushDX is null which I imagine is causing the DrawLine() method to fail.

    Is it expected that stroke.BrushDX would be null? Do I have to do something to initialize it?
    Last edited by overflowing; 02-01-2016, 03:12 AM.

    #2
    I found this thread where it seems gomifromparis encountered the same issue:

    Exposing Pens as properties ?


    But no one seems to explain why BrushDX is null.

    Comment


      #3
      Hello,

      Thank you for the question.

      As there are a few different types with OnRender now I couldn't determine by your post on what Type this is being used in, could you instead provide a export or .cs version of the script that demonstrates this?

      If this can reproduce a crash I could certainly submit that to development for further review.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Not sure what you mean by "Type" in this context but it's for an indicator. Here you go, minimal example indicator
        Attached Files

        Comment


          #5
          Hello,

          Thank you for the sample, By type I was simply referring to the type of file I.E. indicator as there are now many types that use OnRender so it may be different depending on the location.

          I was able to see this on my end so I have submitted this to development for further review.

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Any resolution?

            Jesse,

            I am still having this problem in beta 11. Do you have a fix planned?

            What causes the Stroke.BrushDX property to have a valid brush(dx) and once there, will it stay?

            Gary

            Comment


              #7
              Hello,

              Thank you for bringing this up.

              I noted that the error still exists, but the documentation surrounding this property has not yet been updated. Mainly the error is now handled internally but what the test was showing was still in error logically. What is happening is the property is being used before it has a RenderTarget set.

              To use this property the RenderTarget would need to be set for the stroke before it is used.

              The following would be the solution:

              Code:
              MyStroke.RenderTarget = RenderTarget;
              RenderTarget.DrawLine(pointA, pointB, MyStroke.BrushDX, MyStroke.Width, MyStroke.StrokeStyle);
              To avoid using two lines for a single line statement, you could also use the following:
              Code:
              RenderTarget.DrawLine(pointA, pointB, MyStroke.Brush.ToDxBrush(RenderTarget), MyStroke.Width, MyStroke.StrokeStyle);
              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mestor, 03-10-2023, 01:50 AM
              16 responses
              388 views
              0 likes
              Last Post z.franck  
              Started by rtwave, 04-12-2024, 09:30 AM
              4 responses
              31 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Started by yertle, Yesterday, 08:38 AM
              7 responses
              29 views
              0 likes
              Last Post yertle
              by yertle
               
              Started by bmartz, 03-12-2024, 06:12 AM
              2 responses
              22 views
              0 likes
              Last Post bmartz
              by bmartz
               
              Started by funk10101, Today, 12:02 AM
              0 responses
              7 views
              0 likes
              Last Post funk10101  
              Working...
              X