Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Update brush immediately after changing the property

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

    Update brush immediately after changing the property

    Hi, I have the problem that the brush does not update immediately after the property is changed.

    Code:
    internal Dictionary<string, DxMediaMap> dxmBrushes;
    
    dxmBrushes = new Dictionary<string, DxMediaMap>();
                foreach (string brushName in new string[] { "TestBrush" })
                {
                    dxmBrushes.Add(brushName, new DxMediaMap());
                }
    Code:
    [XmlIgnore]
    [Display(ResourceType = typeof(Resource), Order = 0, GroupName = "TestBrush", Name = "TestBrush", Description = "")]
    public Brush SellPriceLadderAreaBrush
    {
         get { return dxmBrushes["TestBrush"].MediaBrush; }
         set
            {
                dxmBrushes["TestBrush"].MediaBrush = value;
    
                //with the opacity property the call works as desired
                if (ChartControl != null)
                {
                    ChartControl.Dispatcher.InvokeAsync(() => ChartControl.InvalidateVisual());
                }
             }
    }
    I have made a video about this: http://www.youtube.com/watch?v=AzQrmv5YuA8

    as you can see very well in the video, the brush is only updated after the chart has the focus again, and it has been moved. With the opacity property, this happens immediately and without the chart having the focus or being moved. What can I do to make the brush change color immediately?
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    Thanks for your post.

    We have received your inquiry and are researching this matter further. We will get back to you as soon as we have more information available.

    Thanks for your patience. I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello sidlercom80,

      Thanks for your patience.

      Are you changing the color of the brush in the UI?

      If so, you would need to click OK or Apply for the script to reload with the new selected color.

      If you are setting the brush from code, the SharpDX brush should be created and re-created in OnRenderTargetChanged.

      OnRenderTargetChanged: https://ninjatrader.com/support/help...rtargetchanged

      You could view this indicator from the NinjaTrader Ecosystem User App Share. When you change the color of a brush in the UI and click OK or Apply, the brush is updated on the chart to reflect the new color. This indicator could be compared with your script to see where there might be differences.

      JtRealStats: https://ninjatraderecosystem.com/use...i-tick-volume/

      Let me know if I may assist further.

      The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Hi BrandonH, I set the color from my own window. If I understood you correctly, the reason why the color does not change immediately is that the "OnRenderTargetChanged" is not called immediately after the color is changed. Is there any way to make this call manual or force it?

        I just tried it with the call directly when the color is changed via the property, seems to work.

        Code:
        public Brush SellPriceLadderAreaBrush
                {
                    get { return dxmBrushes["SellPriceLadderAreaBrush"].MediaBrush; }
                    set
                    {
                        dxmBrushes["SellPriceLadderAreaBrush"].MediaBrush = value;
        
                        OnRenderTargetChanged();
                    }
                }
        Hope that is correct?
        Last edited by sidlercom80; 10-11-2022, 03:31 AM.
        sidlercom80
        NinjaTrader Ecosystem Vendor - Sidi Trading

        Comment


          #5
          Hello sidlercom80,

          Thanks for your note.

          This would not be a supported way of using OnRenderTargetChanged(). However, this would likely not cause any issues in the script other than the possibility of using extra resources. Note that this would not actually cause the RenderTarget to change.

          It will not be possible to trigger OnRenderTargetChanged() as this is an event handler method that triggers only when the render target is changed.

          Since you are setting a brush from code, within that code where the brush is set, check if the RenderTarget is null and create the SharpDx Brush from the windows media brush. Also, dispose and recreate the Brush in OnRenderTargetChanged().

          If you would like to have chart visuals re-rendered, you could consider using ForceRefresh(). Note that this does not destroy the RenderTarget.

          See this help guide page for more information and sample code: https://ninjatrader.com/support/help...rcerefresh.htm

          Please let me know if I may assist further.
          Last edited by NinjaTrader_BrandonH; 10-11-2022, 08:02 AM.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          672 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X