The official NinjaTrader help guide warns in multiple places that a custom System.Windows.Media.Brush should be frozen using Brush.Freeze(). Here is the warning on the "Working with Brushes" help page at https://ninjatrader.com/support/help...th_brushes.htm :
// predefined brush
BackBrush = Brushes.Blue;
[B]// if you are using a custom brush to e.g., modify the opacity
SolidColorBrush opaqueBlue = new SolidColorBrush(Colors.Blue) {Opacity = .25f};[/B]
// or just using at custom color not available in pre-defined brushes class
SolidColorBrush coolGreen = new SolidColorBrush(Color.FromRgb(30, 255, 128));
// you must freeze these brushes after they are constructed!
opaqueBlue.Freeze();
coolGreen.Freeze();
Question #1:Is it safe to create two Strokes with the same frozen brush as shown below if the Strokes are created with different Opacity values via the Stroke constructor that has an "int opacity" input parameter like this one, where the 25 sets one Stroke's Opacity to 25% and 75 sets the other Stroke's Opacity to 75%, or does the Stroke() object internally create two separate custom Brush objects that might not both be frozen, resulting in a threading error?
// One properly frozen Brush, two Stroke objects created with it. Is this safe? SolidColorBrush mySolidColorBrush = new SolidColorBrush(Color.FromRgb(30, 255, 128)); mySolidColorBrush.Freeze(); NinjaTrader.Gui.Stroke myStroke = new NinjaTrader.Gui.Stroke(mySolidColorBrush, DashStyleHelper.Solid, 1, 25); NinjaTrader.Gui.Stroke myStroke2 = new NinjaTrader.Gui.Stroke(mySolidColorBrush, DashStyleHelper.Solid, 1, 75);
For instance, I see that NinjaTrader_ChelseaB wrote the following at https://forum.ninjatrader.com/forum/...16#post1300016 :
Plots[0].Opacity = PlotOpacity;
Does the above line of code ever cause problems if the Brush of the Plots[0] Plot object is a custom brush with a custom color that was properly frozen?
I ask because I have the concern that setting the Opacity public property of the Plot object might possibly create a second Brush after the fact that I would not have frozen in my code that calls it and I would have no way to freeze it because it would be internal to the Plot object.
Thanks in advance!
EquityTrader

Comment