I am working with a custom drawing tool. I am encountering this error and I think I have narrowed it down to the SolidColorBrush I am using to fill the anchor points. I have read on various forum threads and also on the help guide that the .Freeze() method works to fix this problem. The examples in the help guide work well with brushes created in Strategies and Indicators, however I am writing a Drawing Tool that uses SharpDX objects for rendering. Also, the SolidColorBrush is adjustable in the UI if the user wishes to change the look of the anchors. I will provide a snippet of how the SolidColorBrush is created and used and I would greatly appreciate another set of eye to see why this error is occurring and where the .Freeze() method would fit in.
public class MyDrawingTool: DrawingTool { private SolidColorBrush anchorFillColor = new SolidColorBrush(); //Set Anchor Fill Color [NinjaScriptProperty] [XmlIgnore] [Display(ResourceType = typeof(Custom.Resource), Name = "Anchor Fill", GroupName = "Anchors", Order = 13)] public SolidColorBrush anchorFill { get { return anchorFillColor; } set { anchorFillColor = value; } } //Serialize the anchorFill Color [Browsable(false)] public string anchorFillColorSerializable { get { return anchorFill.ToString(); } set { anchorFill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value)); } } if (State.Defaults) { anchorFillColor = Brushes.White; } OnRender() { var mediaColor = anchorFill.Color; var dxColor = new SharpDX.Color4(mediaColor.ScR, mediaColor.ScG, mediaColor.ScB, mediaColor.ScA); SharpDX.Direct2D1.SolidColorBrush customDXBrush = new SharpDX.Direct2D1.SolidColorBrush(RenderTarget, dxColor); RenderTarget.... //Render Anchor Points​ } }
Comment