Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Mizzouman1, Today, 07:35 AM
      4 responses
      18 views
      0 likes
      Last Post Mizzouman1  
      Started by philmg, Today, 01:17 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by cre8able, Today, 01:01 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by manitshah915, Today, 12:59 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by ursavent, Today, 12:54 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X