Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How Draw Rectangle Gradient Brush?

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

    How Draw Rectangle Gradient Brush?

    I want draw Rectangle use Gradient Brush.

    Code:
            
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale) {
    LinearGradientBrush linGrBrush = new LinearGradientBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0),System.Windows.Media.Color.FromArgb(255, 0, 0, 255), new System.Windows.Point(0, 10),  new System.Windows.Point(200, 10));  
     RenderTarget.FillRectangle(new RectangleF(10, 10, 300, 300),SharpDX.Direct2D1.Brush( linGrBrush)); }
    In line RenderTarget.FillRectangle(new RectangleF(10, 10, 300, 300), SharpDX.Direct2D1.Brush( linGrBrush)); the compiler generates an error.
    How I can use Gradient Brush? How I can draw Rectangle with Gradient Brush?
    Thank you.

    #2
    Hello _Roman,
    Thanks for your post.

    It looks like you need to convert the LinearGradientBrush to be a SharpDX brush using ToDxBrush(). Something like the following snippet seemed to resolve the compile error on my end:
    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        LinearGradientBrush linGrBrush = new LinearGradientBrush(System.Windows.Media.Color.FromArgb(255, 255, 0, 0),System.Windows.Media.Color.FromArgb(255, 0, 0, 255), new System.Windows.Point(0, 10),  new System.Windows.Point(200, 10));
        SharpDX.Direct2D1.Brush dxBrush = linGrBrush.ToDxBrush(RenderTarget);
        RenderTarget.FillRectangle(new RectangleF(10, 10, 300, 300), dxBrush); 
    }
    Please see the following link for more information on ToDxBrush(): https://ninjatrader.com/support/help..._todxbrush.htm
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_JoshG View Post
      It looks like you need to convert the LinearGradientBrush to be a SharpDX brush using ToDxBrush(). Something like the following snippet seemed to resolve the compile error on my end:
      Yes. It is resolved this issue.
      Thank you, very, very very much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      636 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      568 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X