• 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

ImageBrush

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

  • jshapen
    started a topic ImageBrush

    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.

  • aligator
    replied
    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

    Leave a comment:


  • NinjaTrader_Jim
    replied
    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

    Leave a comment:


  • NinjaTrader_Jim
    replied
    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.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by n8dogg59, Today, 03:07 PM
0 responses
1 view
0 likes
Last Post n8dogg59  
Started by Newtrader101, Today, 10:31 AM
1 response
16 views
0 likes
Last Post koganam
by koganam
 
Started by nepenthean, Today, 12:36 PM
1 response
8 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by sun0781, Yesterday, 05:02 PM
1 response
24 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by Emma1, Today, 12:14 PM
1 response
4 views
0 likes
Last Post NinjaTrader_ChrisL  
Working...
X