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

ImageBrush

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

    ImageBrush

    Is it possible to use ImageBrush in xaml skins files?
    I tried replacing in the ChartControl.xaml
    Code:
    <SolidColorBrush	x:Key="ChartControl.ChartBackground"				Color="#1e1e1e"			po:Freeze="true" />
    to
    Code:
    <ImageBrush ImageSource="image1.jpg"	x:Key="ChartControl.ChartBackground"	po:Freeze="true" />
    but I get an error

    The calling thread cannot access this object because a different thread owns it.

    #2
    Hello jshapen,

    Thanks for your post.

    I've done some testing to try and accomplish this both in skin and in code. I see the threading error you are referring to and I also see that I currently cannot set ChartControl.Background to the ImageBrush in code and achieve the intended result. (In code, we would use ChartControl.Properties.BackgroundBrush, but this will not accept an ImageBrush)

    I'm currently checking with other teammates to see if the threading error is expected and if there are any suggested ways to set a background image for the entire ChartControl.

    Thanks in advance for your patience.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello jshapen,

      I have gotten some clarification from Product Management.

      The entire area on a chart (ChartControl, all ChartPanels, and Price/Time Scales) is rendered via SharpDX. When ChartControl.Background is set in skin, ChartControl.Properties.BackgroundBrush will inherit the SolidColorBrush from ChartControl.Background. An ImageBrush could not be used since ImageBrushes do not exist for SharpDX rendering.

      The threading error is different considering the thread in which the ImageBrush is created and the UI thread that would use it. A Dispatcher could be used to create and set the brush on the appropriate thread, however we have other documented/supported means to set ChartControl's background brush to a supported brush. (ImageBrushes still could not be used for this instance)

      In short, setting an ImageBrush for ChartControl.Background through the skin xaml is not possible because that part of the window is rendered with DirectX.

      Furthermore, SharpDX rendering internally will clip all rendering to the NinjaScript's ChartPanel. This will need to be circumvented to render to the entire ChartControl area.

      In order to accomplish the goal of setting the background to an image, you would have to use SharpDX rendering, use unsupported code to pop out of the clip rect and use your own, draw the image, and then set the clip rect back to the ChartPanel bounds.

      Popping out of the clip rect is highly unsupported and will break hit testing with the NinjaScript among other things like gridlines. It will work enough for a standalone indicator, but I would not recommend doing this with an actual indicator.

      Unsupported code attached, use at your own risk! (image1.jpg needs to be in Documents/NinjaTrader 8/)

      We have a pending feature request to be able to apply images to ChartControl.Background, and I'll make sure we have your interest tracked on this item since the approach to accomplish this is not supported. I'll also note your interest to set via skin. The ticket ID is SFT-554.

      We cannot offer an ETA or promise of fulfillment, but we are tracking interest and the ticket ID number will be noted in the help guide when a new build gets released with the feature implemented.

      Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

      If there is another item we can provide assistance with, please let us know.
      Attached Files
      JimNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Jim View Post

        Unsupported code attached, use at your own risk! (image1.jpg needs to be in Documents/NinjaTrader 8/)
        Hi Jim,

        Great! Now I can blog my trades from Pacific islands

        Cheers!
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,265 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X