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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      30 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      17 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      9 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      16 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      19 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X