• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - how to make dropshadows within SharpDX?

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

    NT8 - how to make dropshadows within SharpDX?

    Hello,

    how can I create a dropshadow in SharpDX? Their website suggests:

    'SharpDX.Direct2D1.Effects' - Shadow Class. However NinjaScript does not seem to have access to this.

    As you can see by the image I have successfully made a drop shadow on my test buttons:

    Code:
                    btn1.Effect = new DropShadowEffect
                    {
                        Color = new Color {A = 1, R = 0, G = 0, B = 0},
                        Direction = 270,
                        ShadowDepth = 5,
                        Opacity = 0.25,
                        BlurRadius = 20
                    };
    But now I wish to make drop shadows on my 'OnRender' plots such as chartStyles and my own custom indicators. How should I go about this?

    Thank you,

    Simon.
    Attached Files

    #2
    Can you show me an example script in which you are trying to do the same thing with a different object, and are not able to? That should point me in the right direction to find more information.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      You can see by the image that I made a 'shadow' by simply replicating another Draw.Line behind the 'real' bar but as you can see it has no 'organic' look to it. I thought of something more complicated by creating a linear gradient brush that might replicate the blurry effect of shadow. However I discovered I could use System.Windows.Media.Effects (it used to be bitmap effect) on my buttons and thought of how I could use this on my SharpDX drawn bars instead of my 'work-around' bodge-job.

      My issue is trying to come to terms with the new WPF/C#/SharpDX concepts. I have experimented several ways with a rectangle:

      Option1. I understand the .xaml coding for dropshadow but do not know how to draw this dynamically on a NT chart. Should I explore this option by learning Visual Studio and creating code-behind + .xaml file?

      Option 2. Make a Rectangle via System.Windows.Shapes:

      Code:
      System.Windows.Shapes.Rectangle myRect  = new System.Windows.Shapes.Rectangle();
                      myRect.Effect = new DropShadowEffect
                      {};
      But I cannot seem to convert this shape to a SharpDX rectangle to plot under 'OnRender' such as this one:

      Code:
               SharpDX.RectangleF myRect       = new  SharpDX.RectangleF((float)ChartPanel.X, (float)ChartPanel.Y,      (float)width, (float)height);
              RenderTarget.FillRectangle(myRect, myBrushDx);
      The Shapes.Rectangle allows me to add a dropshadow effect to it. But I cannot specify a location, only height and width and alignment (WPF style). It's all changed since System.Drawing has been made obsolete. So in other words I can make a shadow on this object but cannot 'Draw' it in NT8 since it needs to be converted to a SharpDX object.

      Option 3. Make a rectangle via SharpDX. I can specify x, y and height and width on this but I do not know how to add an effect to this as I can with Controls or Shapes. Like I said the SharpDX website offered a shadow effect but it was not showing in Intellisense in the editor. The information on the web for SharpDX is very sparse and I can only work this out via NT samples (which are sparse too).

      I know this is long-winded but I'm pretty much pulling my hair out and spending way too much time on this concept.

      A simple nudge in the right direction would be great,

      Thank you,

      Simon.
      Attached Files
      Last edited by Sim22; 12-05-2015, 12:55 AM.

      Comment


        #4
        Hello,

        Thank you for clarifying. I've done a bit of research on my end around each of your ideas.

        1. So far this seems to be the best option, based on what I'm finding online. Take a look at the thread below for information on using .xaml with your NinjaScript scripts:

        http://ninjatrader.com/support/forum...ad.php?t=77383

        2. I have not found a way to accomplish this in my research, unfortunately. I have not found anything as convenient as our ToDxBrush() method which could be used for drawn shapes. You could of course create a helper method that would do this, but that would bring you back to Square One of trying to convert the Effect to SharpDX.

        3. From what I've seen, it appears that SharpDX Effects (including Shadow) are generally used on images, rather than simple shapes. Given the general philosophy of SharpDX, it's a good bet that they intend for you to draw your own shadows dynamically for shapes and custom drawing. I could be mistaken there, but everything I'm seeing online points in that direction.
        Dave I.NinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by bosajin, Today, 06:27 PM
        0 responses
        2 views
        0 likes
        Last Post bosajin
        by bosajin
         
        Started by saltminer, Today, 06:11 PM
        0 responses
        2 views
        0 likes
        Last Post saltminer  
        Started by epitoma, Today, 05:21 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by BatBart, Today, 01:24 PM
        1 response
        23 views
        0 likes
        Last Post NinjaTrader_Melissa  
        Started by ezrakoper, Today, 03:05 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X